aboutsummaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2015-12-21 17:51:17 -0800
committerClark Scheff <clark@cyngn.com>2015-12-22 15:13:38 -0800
commitafa4fef9ee21d060997194a9b1e446877d1f2f5e (patch)
treef1b9df74ddbf447a3765286bb1cfcb9d149907c2 /samples
parent8cc5a55f82ee417d8889ca46c907cbf4ffc36f71 (diff)
downloadvendor_cmsdk-afa4fef9ee21d060997194a9b1e446877d1f2f5e.zip
vendor_cmsdk-afa4fef9ee21d060997194a9b1e446877d1f2f5e.tar.gz
vendor_cmsdk-afa4fef9ee21d060997194a9b1e446877d1f2f5e.tar.bz2
ExtView: Add samples for using KeyguardExternalViews
This adds two samples, samples/externalviews/keyguardviewprovider which provides an example of creating a third party keyguard component, and samples/externalviews/setleygiardviewprovider which allows setting and clearing of the third party keyguard component. Change-Id: Ia9c564d602f1b6d44953eb05f2ffcf3f44663ece
Diffstat (limited to 'samples')
-rw-r--r--samples/externalviews/keyguardviewprovider/Android.mk27
-rw-r--r--samples/externalviews/keyguardviewprovider/AndroidManifest.xml32
-rw-r--r--samples/externalviews/keyguardviewprovider/res/anim/pulsing_anim.xml15
-rw-r--r--samples/externalviews/keyguardviewprovider/res/drawable-hdpi/ic_launcher.pngbin0 -> 9397 bytes
-rw-r--r--samples/externalviews/keyguardviewprovider/res/drawable-ldpi/ic_launcher.pngbin0 -> 2729 bytes
-rw-r--r--samples/externalviews/keyguardviewprovider/res/drawable-mdpi/ic_launcher.pngbin0 -> 5237 bytes
-rw-r--r--samples/externalviews/keyguardviewprovider/res/drawable-nodpi/platlogo_cm.xml55
-rw-r--r--samples/externalviews/keyguardviewprovider/res/drawable-xhdpi/ic_launcher.pngbin0 -> 14383 bytes
-rw-r--r--samples/externalviews/keyguardviewprovider/res/layout/main.xml29
-rw-r--r--samples/externalviews/keyguardviewprovider/res/values/strings.xml22
-rw-r--r--samples/externalviews/keyguardviewprovider/src/org/cyanogenmod/samples/keyguardextview/SampleKeyguardProviderService.java119
-rw-r--r--samples/externalviews/setkeyguardviewprovider/Android.mk27
-rw-r--r--samples/externalviews/setkeyguardviewprovider/AndroidManifest.xml39
-rw-r--r--samples/externalviews/setkeyguardviewprovider/README.md6
-rw-r--r--samples/externalviews/setkeyguardviewprovider/res/drawable-hdpi/ic_launcher.pngbin0 -> 9397 bytes
-rw-r--r--samples/externalviews/setkeyguardviewprovider/res/drawable-ldpi/ic_launcher.pngbin0 -> 2729 bytes
-rw-r--r--samples/externalviews/setkeyguardviewprovider/res/drawable-mdpi/ic_launcher.pngbin0 -> 5237 bytes
-rw-r--r--samples/externalviews/setkeyguardviewprovider/res/drawable-xhdpi/ic_launcher.pngbin0 -> 14383 bytes
-rw-r--r--samples/externalviews/setkeyguardviewprovider/res/layout/set_keyguard.xml19
-rw-r--r--samples/externalviews/setkeyguardviewprovider/res/values/strings.xml22
-rw-r--r--samples/externalviews/setkeyguardviewprovider/src/org/cyanogenmod/samples/keyguardextview/SetKeyguardComponentActivity.java73
21 files changed, 485 insertions, 0 deletions
diff --git a/samples/externalviews/keyguardviewprovider/Android.mk b/samples/externalviews/keyguardviewprovider/Android.mk
new file mode 100644
index 0000000..730e7bc
--- /dev/null
+++ b/samples/externalviews/keyguardviewprovider/Android.mk
@@ -0,0 +1,27 @@
+# Copyright (C) 2015 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)
+include $(CLEAR_VARS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ org.cyanogenmod.platform.sdk
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src/)
+
+LOCAL_PACKAGE_NAME := CMKeyguardExternalViewProvider
+
+# Need a permission that is signature|privileged
+LOCAL_PRIVILEGED_MODULE := true
+
+include $(BUILD_PACKAGE) \ No newline at end of file
diff --git a/samples/externalviews/keyguardviewprovider/AndroidManifest.xml b/samples/externalviews/keyguardviewprovider/AndroidManifest.xml
new file mode 100644
index 0000000..145cd92
--- /dev/null
+++ b/samples/externalviews/keyguardviewprovider/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.cyanogenmod.samples.keyguardextview"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="23" />
+
+ <!-- Required permission for third party keyguard components -->
+ <uses-permission android:name="android.permission.THIRD_PARTY_KEYGUARD" />
+
+ <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
+ <service android:name=".SampleKeyguardProviderService"
+ android:exported="true">
+ </service>
+ </application>
+</manifest>
diff --git a/samples/externalviews/keyguardviewprovider/res/anim/pulsing_anim.xml b/samples/externalviews/keyguardviewprovider/res/anim/pulsing_anim.xml
new file mode 100644
index 0000000..b43c3d0
--- /dev/null
+++ b/samples/externalviews/keyguardviewprovider/res/anim/pulsing_anim.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <scale
+ android:duration="1000"
+ android:fromXScale="1"
+ android:fromYScale="1"
+ android:toXScale="1.5"
+ android:toYScale="1.5"
+ android:pivotX="50%"
+ android:pivotY="50%"
+ android:repeatMode="reverse"
+ android:repeatCount="infinite"/>
+
+</set> \ No newline at end of file
diff --git a/samples/externalviews/keyguardviewprovider/res/drawable-hdpi/ic_launcher.png b/samples/externalviews/keyguardviewprovider/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..96a442e
--- /dev/null
+++ b/samples/externalviews/keyguardviewprovider/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/samples/externalviews/keyguardviewprovider/res/drawable-ldpi/ic_launcher.png b/samples/externalviews/keyguardviewprovider/res/drawable-ldpi/ic_launcher.png
new file mode 100644
index 0000000..9923872
--- /dev/null
+++ b/samples/externalviews/keyguardviewprovider/res/drawable-ldpi/ic_launcher.png
Binary files differ
diff --git a/samples/externalviews/keyguardviewprovider/res/drawable-mdpi/ic_launcher.png b/samples/externalviews/keyguardviewprovider/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..359047d
--- /dev/null
+++ b/samples/externalviews/keyguardviewprovider/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/samples/externalviews/keyguardviewprovider/res/drawable-nodpi/platlogo_cm.xml b/samples/externalviews/keyguardviewprovider/res/drawable-nodpi/platlogo_cm.xml
new file mode 100644
index 0000000..b863c27
--- /dev/null
+++ b/samples/externalviews/keyguardviewprovider/res/drawable-nodpi/platlogo_cm.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (c) 2015 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="48dp"
+ android:height="48dp"
+ android:viewportWidth="48.0"
+ android:viewportHeight="48.0">
+
+ <path
+ android:name="body"
+ android:fillColor="#FFFFFF"
+ android:pathData="M24,12L24,12L24,12L24,12L24,12c7.7,0,14,1.2,14.9,2.6c0,0,0,0,0,0c1,1.5,1.1,6.5,1.1,9.4s-0.1,7.8-1.1,9.4
+c0,0,0,0,0,0C38,34.8,31.7,36,24,36l0,0l0,0l0,0l0,0l0,0l0,0l0,0l0,0c-7.7,0-14-1.2-14.9-2.6c0,0,0,0,0,0C8.1,31.8,8,26.9,8,24
+s0.1-7.8,1.1-9.4c0,0,0,0,0,0C10,13.2,16.3,12,24,12L24,12L24,12L24,12L24,12z" />
+ <path
+ android:name="top"
+ android:fillColor="#EBEBEB"
+ android:pathData="M39,15c0,1.7-6.7,3-15,3S9,16.7,9,15s6.7-3,15-3S39,13.3,39,15z" />
+ <path
+ android:name="r_ant"
+ android:fillColor="#FFFFFF"
+ android:pathData="M35,15c-0.1,0-0.3,0-0.4-0.1c-0.5-0.2-0.8-0.8-0.5-1.3l2-5c0.2-0.5,0.8-0.8,1.3-0.5
+c0.5,0.2,0.8,0.8,0.5,1.3l-2,5C35.7,14.8,35.3,15,35,15z" />
+ <path
+ android:name="l_ant"
+ android:fillColor="#FFFFFF"
+ android:pathData="M13,15c0.1,0,0.3,0,0.4-0.1c0.5-0.2,0.8-0.8,0.5-1.3l-2-5c-0.2-0.5-0.8-0.8-1.3-0.5
+c-0.5,0.2-0.8,0.8-0.5,1.3l2,5C12.3,14.8,12.7,15,13,15z" />
+ <path
+ android:name="smile"
+ android:fillColor="#EBEBEB"
+ android:pathData="M22,32C22,32,22,32.1,22,32c0,0.9,0.6,1.5,1.4,1.5h1.1c0.8,0,1.5-0.7,1.5-1.5c0,0,0-0.1,0-0.1H22z" />
+ <path
+ android:name="l_eye"
+ android:fillColor="#EBEBEB"
+ android:pathData="M16,20c-2.8,0-5,2.2-5,5c0,2.8,2.2,5,5,5c2.8,0,5-2.2,5-5C21,22.2,18.8,20,16,20z" />
+ <path
+ android:name="r_eye"
+ android:fillColor="#EBEBEB"
+ android:pathData="M32,20c-2.8,0-5,2.2-5,5c0,2.8,2.2,5,5,5c2.8,0,5-2.2,5-5C37,22.2,34.8,20,32,20z" />
+</vector>
diff --git a/samples/externalviews/keyguardviewprovider/res/drawable-xhdpi/ic_launcher.png b/samples/externalviews/keyguardviewprovider/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..71c6d76
--- /dev/null
+++ b/samples/externalviews/keyguardviewprovider/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/samples/externalviews/keyguardviewprovider/res/layout/main.xml b/samples/externalviews/keyguardviewprovider/res/layout/main.xml
new file mode 100644
index 0000000..fd6ff02
--- /dev/null
+++ b/samples/externalviews/keyguardviewprovider/res/layout/main.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <ImageView
+ android:id="@+id/cid"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:src="@drawable/platlogo_cm"
+ android:scaleType="fitCenter"
+ />
+</FrameLayout>
+
diff --git a/samples/externalviews/keyguardviewprovider/res/values/strings.xml b/samples/externalviews/keyguardviewprovider/res/values/strings.xml
new file mode 100644
index 0000000..480dfe3
--- /dev/null
+++ b/samples/externalviews/keyguardviewprovider/res/values/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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>
+ <string name="app_name">Keyguard Sample</string>
+
+ <string name="btn_set_keyguard">Set keyguard component</string>
+ <string name="btn_clear_keyguard">Clear keyguard component</string>
+</resources>
diff --git a/samples/externalviews/keyguardviewprovider/src/org/cyanogenmod/samples/keyguardextview/SampleKeyguardProviderService.java b/samples/externalviews/keyguardviewprovider/src/org/cyanogenmod/samples/keyguardextview/SampleKeyguardProviderService.java
new file mode 100644
index 0000000..dc742d1
--- /dev/null
+++ b/samples/externalviews/keyguardviewprovider/src/org/cyanogenmod/samples/keyguardextview/SampleKeyguardProviderService.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2015 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.samples.keyguardextview;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.ImageView;
+import cyanogenmod.externalviews.KeyguardExternalViewProviderService;
+
+public class SampleKeyguardProviderService extends KeyguardExternalViewProviderService {
+
+ @Override
+ protected KeyguardExternalViewProviderService.Provider createExternalView(Bundle options) {
+ return new ProviderImpl(options);
+ }
+
+ private class ProviderImpl extends Provider {
+ ImageView mImageView;
+ Animation mPulseAnimation;
+
+ protected ProviderImpl(Bundle options) {
+ super(options);
+ }
+
+ /**
+ * Create a view that will be displayed within the system's lock screen (aka keyguard)
+ * @return The view to be displayed
+ */
+ @Override
+ protected View onCreateView() {
+ View view = LayoutInflater.from(SampleKeyguardProviderService.this)
+ .inflate(R.layout.main, null);
+ mImageView = (ImageView) view.findViewById(R.id.cid);
+ return view;
+ }
+
+ /**
+ * Called when the keyguard is being shown
+ * @param screenOn True if the screen is currently on
+ */
+ @Override
+ protected void onKeyguardShowing(boolean screenOn) {
+
+ }
+
+ /**
+ * Called when the user has unlocked their device and the keyguard is dismissed
+ */
+ @Override
+ protected void onKeyguardDismissed() {
+
+ }
+
+ /**
+ * Called when the state of the bouncer being shown changes
+ * @param showing True if the bouncer is showing
+ */
+ @Override
+ protected void onBouncerShowing(boolean showing) {
+
+ }
+
+ /**
+ * Called when the screen has been turned on
+ */
+ @Override
+ protected void onScreenTurnedOn() {
+ mImageView.startAnimation(mPulseAnimation);
+ }
+
+ /**
+ * Called when the screen has been turned off
+ */
+ @Override
+ protected void onScreenTurnedOff() {
+ mImageView.clearAnimation();
+ }
+
+ /**
+ * Called when the view has been attached to a window
+ */
+ @Override
+ protected void onAttach() {
+ super.onAttach();
+ // If this is an interactive component, now is a good time to
+ // call setInteractivity(true);
+ setInteractivity(false);
+ mPulseAnimation = AnimationUtils.loadAnimation(SampleKeyguardProviderService.this,
+ R.anim.pulsing_anim);
+ mImageView.startAnimation(mPulseAnimation);
+ }
+
+ /**
+ * Called when the view has been detached from the window
+ */
+ @Override
+ protected void onDetach() {
+ super.onDetach();
+ }
+ }
+}
diff --git a/samples/externalviews/setkeyguardviewprovider/Android.mk b/samples/externalviews/setkeyguardviewprovider/Android.mk
new file mode 100644
index 0000000..8ed385a
--- /dev/null
+++ b/samples/externalviews/setkeyguardviewprovider/Android.mk
@@ -0,0 +1,27 @@
+# Copyright (C) 2015 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)
+include $(CLEAR_VARS)
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ org.cyanogenmod.platform.internal
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src/)
+
+LOCAL_PACKAGE_NAME := CMSetKeyguardExternalViewProvider
+
+LOCAL_PRIVILEGED_MODULE := true
+LOCAL_CERTIFICATE := platform
+
+include $(BUILD_PACKAGE) \ No newline at end of file
diff --git a/samples/externalviews/setkeyguardviewprovider/AndroidManifest.xml b/samples/externalviews/setkeyguardviewprovider/AndroidManifest.xml
new file mode 100644
index 0000000..f5300fd
--- /dev/null
+++ b/samples/externalviews/setkeyguardviewprovider/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.cyanogenmod.samples.setkeyguardextview"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="23" />
+
+ <!-- Permissions used for setting the third party keyguard component, this is for
+ testing purposes only and should not be used when implementing third party
+ keyguard components -->
+ <uses-permission android:name="android.permission.ACCESS_KEYGUARD_SECURE_STORAGE" />
+
+ <application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
+ <activity
+ android:name=".SetKeyguardComponentActivity"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/samples/externalviews/setkeyguardviewprovider/README.md b/samples/externalviews/setkeyguardviewprovider/README.md
new file mode 100644
index 0000000..f0edd44
--- /dev/null
+++ b/samples/externalviews/setkeyguardviewprovider/README.md
@@ -0,0 +1,6 @@
+# Notice
+This sample is provided as a way to set and clear the setting that defines what
+KeyguardExternalViewProviderService the system should use. Changing this setting
+requires a permission that is only granted to system apps. As such, this sample
+is not intended to be built as a standalone application and must be built as part
+of the CyanogenMod build system. \ No newline at end of file
diff --git a/samples/externalviews/setkeyguardviewprovider/res/drawable-hdpi/ic_launcher.png b/samples/externalviews/setkeyguardviewprovider/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..96a442e
--- /dev/null
+++ b/samples/externalviews/setkeyguardviewprovider/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/samples/externalviews/setkeyguardviewprovider/res/drawable-ldpi/ic_launcher.png b/samples/externalviews/setkeyguardviewprovider/res/drawable-ldpi/ic_launcher.png
new file mode 100644
index 0000000..9923872
--- /dev/null
+++ b/samples/externalviews/setkeyguardviewprovider/res/drawable-ldpi/ic_launcher.png
Binary files differ
diff --git a/samples/externalviews/setkeyguardviewprovider/res/drawable-mdpi/ic_launcher.png b/samples/externalviews/setkeyguardviewprovider/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..359047d
--- /dev/null
+++ b/samples/externalviews/setkeyguardviewprovider/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/samples/externalviews/setkeyguardviewprovider/res/drawable-xhdpi/ic_launcher.png b/samples/externalviews/setkeyguardviewprovider/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..71c6d76
--- /dev/null
+++ b/samples/externalviews/setkeyguardviewprovider/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/samples/externalviews/setkeyguardviewprovider/res/layout/set_keyguard.xml b/samples/externalviews/setkeyguardviewprovider/res/layout/set_keyguard.xml
new file mode 100644
index 0000000..5d4f8ba
--- /dev/null
+++ b/samples/externalviews/setkeyguardviewprovider/res/layout/set_keyguard.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <Button
+ android:id="@+id/clear_keyguard"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/btn_clear_keyguard"/>
+
+ <Button
+ android:id="@+id/set_keyguard"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/btn_set_keyguard"/>
+
+</LinearLayout> \ No newline at end of file
diff --git a/samples/externalviews/setkeyguardviewprovider/res/values/strings.xml b/samples/externalviews/setkeyguardviewprovider/res/values/strings.xml
new file mode 100644
index 0000000..4ac04c4
--- /dev/null
+++ b/samples/externalviews/setkeyguardviewprovider/res/values/strings.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2015 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>
+ <string name="app_name">Keyguard Selector</string>
+
+ <string name="btn_set_keyguard">Set keyguard component</string>
+ <string name="btn_clear_keyguard">Clear keyguard component</string>
+</resources>
diff --git a/samples/externalviews/setkeyguardviewprovider/src/org/cyanogenmod/samples/keyguardextview/SetKeyguardComponentActivity.java b/samples/externalviews/setkeyguardviewprovider/src/org/cyanogenmod/samples/keyguardextview/SetKeyguardComponentActivity.java
new file mode 100644
index 0000000..961bcf0
--- /dev/null
+++ b/samples/externalviews/setkeyguardviewprovider/src/org/cyanogenmod/samples/keyguardextview/SetKeyguardComponentActivity.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2015 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.samples.setkeyguardextview;
+
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.pm.PackageManager;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+
+import org.cyanogenmod.internal.util.CmLockPatternUtils;
+
+public class SetKeyguardComponentActivity extends Activity {
+ private static final String TAG = SetKeyguardComponentActivity.class.getSimpleName();
+ private static final String KEYGUARD_PACKAGE = "org.cyanogenmod.samples.keyguardextview";
+ private static final String KEYGUARD_COMPONENT =
+ KEYGUARD_PACKAGE + ".SampleKeyguardProviderService";
+
+ private Button mClearKeyguardButton;
+ private Button mSetKeyguardButton;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.set_keyguard);
+ }
+
+ @Override
+ public void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ mClearKeyguardButton = (Button) findViewById(R.id.clear_keyguard);
+ mClearKeyguardButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ setKeyguardComponent(null);
+ }
+ });
+
+ mSetKeyguardButton = (Button) findViewById(R.id.set_keyguard);
+ mSetKeyguardButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ setKeyguardComponent(new ComponentName(KEYGUARD_PACKAGE, KEYGUARD_COMPONENT));
+ }
+ });
+ }
+
+ private void setKeyguardComponent(ComponentName cn) {
+ CmLockPatternUtils lockPatternUtils =
+ new CmLockPatternUtils(this);
+ try {
+ lockPatternUtils.setThirdPartyKeyguard(cn);
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "Unable to set third party keyguard component", e);
+ }
+ }
+} \ No newline at end of file