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
|
@ -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)
|
|
@ -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>
|
|
@ -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>
|
After Width: | Height: | Size: 9.2 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 5.1 KiB |
|
@ -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>
|
After Width: | Height: | Size: 14 KiB |
|
@ -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>
|
||||||
|
|
|
@ -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>
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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)
|
|
@ -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>
|
|
@ -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.
|
After Width: | Height: | Size: 9.2 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 14 KiB |
|
@ -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>
|
|
@ -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>
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|