summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2016-03-17 11:40:46 -0700
committerClark Scheff <clark@cyngn.com>2016-03-30 08:45:42 -0700
commit191efc4c33c3b26e3537c399fc114e5a67bd6a4a (patch)
treed69bdc532509888c0e5cd909fe25d10ce74067cc
parentbe12fad168bde08c063c880361fbe07db2c5f5ed (diff)
downloadandroid_packages_services_LiveLockScreenService-191efc4c33c3b26e3537c399fc114e5a67bd6a4a.tar.gz
android_packages_services_LiveLockScreenService-191efc4c33c3b26e3537c399fc114e5a67bd6a4a.tar.bz2
android_packages_services_LiveLockScreenService-191efc4c33c3b26e3537c399fc114e5a67bd6a4a.zip
LLS: Add live lock screen service [2/4]
Change-Id: Id623d86930e3ffea669747fe81173436a862c377
-rw-r--r--Android.mk35
-rw-r--r--AndroidManifest.xml35
-rw-r--r--proguard.flags22
-rw-r--r--res/values/strings.xml19
-rw-r--r--src/org/cyanogenmod/livelockscreen/service/LiveLockScreenManagerService.java118
5 files changed, 229 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
new file mode 100644
index 0000000..8126543
--- /dev/null
+++ b/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2016 The CyanogenMod Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+#
+# Live lock screen service
+#
+include $(CLEAR_VARS)
+
+LOCAL_PACKAGE_NAME := LiveLockScreenService
+
+LOCAL_STATIC_JAVA_LIBRARIES := org.cyanogenmod.platform.internal
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+
+LOCAL_PROGUARD_FLAG_FILES := proguard.flags
+LOCAL_PROGUARD_ENABLED := optimization
+
+LOCAL_PRIVILEGED_MODULE := true
+
+include $(BUILD_PACKAGE)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644
index 0000000..d384f99
--- /dev/null
+++ b/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.cyanogenmod.livelockscreen.service"
+ coreApp="true">
+
+ <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS"/>
+ <uses-permission android:name="cyanogenmod.permission.LIVE_LOCK_SCREEN_MANAGER_PROVIDER"/>
+
+ <application android:label="@string/app_name">
+
+ <service android:name="org.cyanogenmod.livelockscreen.service.LiveLockScreenManagerService"
+ android:enabled="true"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="cyanogenmod.app.LiveLockScreenManagerService"/>
+ </intent-filter>
+ </service>
+
+ </application>
+</manifest>
diff --git a/proguard.flags b/proguard.flags
new file mode 100644
index 0000000..d852fbc
--- /dev/null
+++ b/proguard.flags
@@ -0,0 +1,22 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /opt/android-sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+-keepattributes *Annotation*,EnclosingMethod,Signature,LineNumberTable,SourceFile
+
+-dontwarn cyanogenmod.**
+-keep class cyanogenmod.app.** { *; }
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644
index 0000000..c2996f3
--- /dev/null
+++ b/res/values/strings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2016 The CyanogenMod Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="app_name">Live lock screen service</string>
+</resources>
diff --git a/src/org/cyanogenmod/livelockscreen/service/LiveLockScreenManagerService.java b/src/org/cyanogenmod/livelockscreen/service/LiveLockScreenManagerService.java
new file mode 100644
index 0000000..d534c3e
--- /dev/null
+++ b/src/org/cyanogenmod/livelockscreen/service/LiveLockScreenManagerService.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2016 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.cyanogenmod.livelockscreen.service;
+
+import android.content.ComponentName;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.os.Message;
+import android.os.Process;
+import android.os.RemoteException;
+import android.util.Log;
+
+import cyanogenmod.app.BaseLiveLockManagerService;
+import cyanogenmod.app.LiveLockScreenInfo;
+import cyanogenmod.providers.CMSettings;
+
+import java.util.Objects;
+
+public class LiveLockScreenManagerService extends BaseLiveLockManagerService {
+ private static final String TAG = LiveLockScreenManagerService.class.getSimpleName();
+ private static final boolean DEBUG = false;
+
+ private LiveLockScreenInfo mCurrentLiveLockScreen;
+
+ private WorkerHandler mHandler;
+ private final HandlerThread mWorkerThread = new HandlerThread("worker",
+ Process.THREAD_PRIORITY_BACKGROUND);
+
+ private class WorkerHandler extends Handler {
+ private static final int MSG_UPDATE_CURRENT = 1000;
+
+ public WorkerHandler(Looper looper) {
+ super(looper);
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MSG_UPDATE_CURRENT:
+ handleUpdateCurrentLiveLockScreenLocked((LiveLockScreenInfo) msg.obj);
+ break;
+ default:
+ Log.w(TAG, "Unknown message " + msg.what);
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void enqueueLiveLockScreen(String pkg, int id, LiveLockScreenInfo lls, int[] idReceived,
+ int userId) throws RemoteException {
+ Log.i(TAG, "enqueueLiveLockScreen is not implemented");
+ }
+
+ @Override
+ public void cancelLiveLockScreen(String pkg, int id, int userId) throws RemoteException {
+ Log.i(TAG, "cancelLiveLockScreen is not implemented");
+ }
+
+ @Override
+ public LiveLockScreenInfo getCurrentLiveLockScreen() throws RemoteException {
+ return mCurrentLiveLockScreen;
+ }
+
+ @Override
+ public void updateDefaultLiveLockScreen(LiveLockScreenInfo llsInfo) throws RemoteException {
+ Message msg = mHandler.obtainMessage(WorkerHandler.MSG_UPDATE_CURRENT, llsInfo);
+ mHandler.sendMessage(msg);
+ }
+
+ public LiveLockScreenManagerService() {
+ super();
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ if (DEBUG) Log.d(TAG, "service created");
+ mWorkerThread.start();
+ mHandler = new WorkerHandler(mWorkerThread.getLooper());
+
+ mCurrentLiveLockScreen = getDefaultLiveLockScreenInternal();
+ }
+
+ private void handleUpdateCurrentLiveLockScreenLocked(LiveLockScreenInfo llsInfo) {
+ if (!Objects.equals(mCurrentLiveLockScreen, llsInfo)) {
+ mCurrentLiveLockScreen = llsInfo;
+ notifyChangeListeners(llsInfo);
+ }
+ }
+
+ private LiveLockScreenInfo getDefaultLiveLockScreenInternal() {
+ final String defComponent = CMSettings.Secure.getString(getContentResolver(),
+ CMSettings.Secure.DEFAULT_LIVE_LOCK_SCREEN_COMPONENT);
+
+ if (defComponent != null) {
+ return new LiveLockScreenInfo.Builder()
+ .setComponent(ComponentName.unflattenFromString(defComponent))
+ .build();
+ }
+ return null;
+ }
+}