Move Keyguard to SystemUI
Test: make Change-Id: I3abb67e2b022737d2aa0226bb07f3966ad68fff7
@@ -1,52 +0,0 @@
|
||||
# Copyright (C) 2013 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.
|
||||
#
|
||||
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := SystemUI-tags
|
||||
|
||||
LOCAL_SRC_FILES := src/com/android/systemui/EventLogTags.logtags
|
||||
|
||||
include $(BUILD_STATIC_JAVA_LIBRARY)
|
||||
|
||||
# ------------------
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_USE_AAPT2 := true
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-subdir-Iaidl-files)
|
||||
|
||||
LOCAL_MODULE := Keyguard
|
||||
|
||||
LOCAL_CERTIFICATE := platform
|
||||
|
||||
LOCAL_JAVA_LIBRARIES := SettingsLib
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES = SystemUI-tags
|
||||
|
||||
LOCAL_PRIVILEGED_MODULE := true
|
||||
|
||||
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
||||
|
||||
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
|
||||
|
||||
LOCAL_JAR_EXCLUDE_FILES := none
|
||||
|
||||
include $(BUILD_STATIC_JAVA_LIBRARY)
|
||||
|
||||
#include $(call all-makefiles-under,$(LOCAL_PATH))
|
||||
@@ -1,31 +0,0 @@
|
||||
# Copyright (C) 2013 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.
|
||||
#
|
||||
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_USE_AAPT2 := true
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
LOCAL_PACKAGE_NAME := KeyguardTest
|
||||
|
||||
# Remove these to verify permission checks are working correctly
|
||||
LOCAL_CERTIFICATE := platform
|
||||
LOCAL_PRIVILEGED_MODULE := true
|
||||
|
||||
# LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright 2013, 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="com.android.keyguard.test">
|
||||
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17"/>
|
||||
<uses-permission android:name="android.permission.CONTROL_KEYGUARD" />
|
||||
<application android:label="@string/app_name" android:icon="@drawable/app_icon">
|
||||
<activity android:name=".KeyguardTestActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.DeviceDefault.Light">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -1,34 +0,0 @@
|
||||
# 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.
|
||||
#
|
||||
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_USE_AAPT2 := true
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
LOCAL_PACKAGE_NAME := SampleTrustAgent
|
||||
|
||||
# Remove this to verify permission checks are working correctly
|
||||
LOCAL_CERTIFICATE := platform
|
||||
|
||||
LOCAL_MODULE_TAGS := tests
|
||||
|
||||
# LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
||||
|
||||
LOCAL_STATIC_ANDROID_LIBRARIES := android-support-v4
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
@@ -1,48 +0,0 @@
|
||||
<?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="com.android.trustagent.test">
|
||||
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17"/>
|
||||
<uses-permission android:name="android.permission.CONTROL_KEYGUARD" />
|
||||
<uses-permission android:name="android.permission.PROVIDE_TRUST_AGENT" />
|
||||
<application android:label="@string/app_name">
|
||||
<service
|
||||
android:name=".SampleTrustAgent"
|
||||
android:label="@string/app_name"
|
||||
android:permission="android.permission.BIND_TRUST_AGENT"
|
||||
android:directBootAware="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.trust.TrustAgentService" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.service.trust.trustagent"
|
||||
android:resource="@xml/sample_trust_agent"/>
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name=".SampleTrustAgentSettings"
|
||||
android:label="@string/app_name"
|
||||
android:exported="true"
|
||||
android:launchMode="singleInstance" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -1,74 +0,0 @@
|
||||
<?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
|
||||
-->
|
||||
|
||||
<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/enable_trust"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Grant trust for 30 seconds" />
|
||||
<Button android:id="@+id/revoke_trust"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Revoke trust" />
|
||||
<Button android:id="@+id/crash"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Crash" />
|
||||
<CheckBox android:id="@+id/managing_trust"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:text="Managing trust" />
|
||||
<CheckBox android:id="@+id/managing_trust_direct_boot"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:text="Managing trust direct boot"/>
|
||||
|
||||
<CheckBox android:id="@+id/report_unlock_attempts"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:text="Report unlock attempts" />
|
||||
<CheckBox android:id="@+id/report_device_locked"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:text="Report device locked or unlocked" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<Button android:id="@+id/check_device_locked"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Device locked?" />
|
||||
<TextView android:id="@+id/check_device_locked_result"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,67 +0,0 @@
|
||||
<?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
|
||||
-->
|
||||
|
||||
<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/enable_trust"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Grant trust for 30 seconds" />
|
||||
<Button android:id="@+id/revoke_trust"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Revoke trust" />
|
||||
<Button android:id="@+id/crash"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Crash" />
|
||||
<CheckBox android:id="@+id/managing_trust"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:text="Managing trust" />
|
||||
<CheckBox android:id="@+id/report_unlock_attempts"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:text="Report unlock attempts" />
|
||||
<CheckBox android:id="@+id/report_device_locked"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:text="Report device locked or unlocked" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<Button android:id="@+id/check_device_locked"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Device locked?" />
|
||||
<TextView android:id="@+id/check_device_locked_result"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?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
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="app_name">Sample Trust Agent</string>
|
||||
</resources>
|
||||
@@ -1,19 +0,0 @@
|
||||
<?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
|
||||
-->
|
||||
<trust-agent xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:settingsActivity=".SampleTrustAgentSettings"
|
||||
android:unlockProfile="true" />
|
||||
@@ -1,18 +0,0 @@
|
||||
<?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
|
||||
-->
|
||||
<trust-agent xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:settingsActivity=".SampleTrustAgentSettings" />
|
||||
@@ -1,268 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
package com.android.trustagent.test;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.PersistableBundle;
|
||||
import android.os.UserManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.service.trust.TrustAgentService;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SampleTrustAgent extends TrustAgentService
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
/**
|
||||
* If true, allows anyone to control this trust agent, e.g. using adb:
|
||||
* <pre>
|
||||
* $ adb shell am broadcast -a action.sample_trust_agent.grant_trust\
|
||||
* -e extra.message SampleTrust\
|
||||
* --el extra.duration 1000 --ez extra.init_by_user false --ez extra.dismiss_keyguard false
|
||||
* </pre>
|
||||
*/
|
||||
private static final boolean ALLOW_EXTERNAL_BROADCASTS = false;
|
||||
|
||||
LocalBroadcastManager mLocalBroadcastManager;
|
||||
|
||||
private static final String ACTION_GRANT_TRUST = "action.sample_trust_agent.grant_trust";
|
||||
private static final String ACTION_REVOKE_TRUST = "action.sample_trust_agent.revoke_trust";
|
||||
|
||||
private static final String EXTRA_MESSAGE = "extra.message";
|
||||
private static final String EXTRA_DURATION = "extra.duration";
|
||||
private static final String EXTRA_INITIATED_BY_USER = "extra.init_by_user";
|
||||
private static final String EXTRA_DISMISS_KEYGUARD = "extra.dismiss_keyguard";
|
||||
|
||||
private static final String PREFERENCE_REPORT_UNLOCK_ATTEMPTS
|
||||
= "preference.report_unlock_attempts";
|
||||
private static final String PREFERENCE_MANAGING_TRUST
|
||||
= "preference.managing_trust";
|
||||
private static final String PREFERENCE_MANAGING_TRUST_DIRECT_BOOT
|
||||
= "preference.managing_trust_direct_boot";
|
||||
private static final String PREFERENCE_REPORT_DEVICE_LOCKED = "preference.report_device_locked";
|
||||
|
||||
private static final String TAG = "SampleTrustAgent";
|
||||
|
||||
private static final BroadcastReceiver mUnlockReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private boolean mIsUserUnlocked;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
|
||||
mIsUserUnlocked = um.isUserUnlocked();
|
||||
Log.i(TAG,, "onCreate, is user unlocked=" + mIsUserUnlocked);
|
||||
mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(ACTION_GRANT_TRUST);
|
||||
filter.addAction(ACTION_REVOKE_TRUST);
|
||||
if (!mIsUserUnlocked) {
|
||||
filter.addAction(Intent.ACTION_BOOT_COMPLETED);
|
||||
}
|
||||
mLocalBroadcastManager.registerReceiver(mReceiver, filter);
|
||||
if (ALLOW_EXTERNAL_BROADCASTS) {
|
||||
registerReceiver(mReceiver, filter);
|
||||
}
|
||||
|
||||
if (!mIsUserUnlocked) {
|
||||
boolean trustManaged = getIsManagingTrustDirectBoot(this);
|
||||
Log.i(TAG, "in Direct boot." + (trustManaged ? "manage" : "cannot manage") + "trust");
|
||||
setManagingTrust(getIsManagingTrustDirectBoot(this));
|
||||
} else {
|
||||
onBootCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrustTimeout() {
|
||||
super.onTrustTimeout();
|
||||
logAndShowToast("onTrustTimeout(): timeout expired");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeviceLocked() {
|
||||
super.onDeviceLocked();
|
||||
if (getReportDeviceLocked(this)) {
|
||||
logAndShowToast("onDeviceLocked(): device is now locked");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeviceUnlocked() {
|
||||
super.onDeviceUnlocked();
|
||||
if (getReportDeviceLocked(this)) {
|
||||
logAndShowToast("onDeviceUnlocked(): device is now unlocked");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnlockAttempt(boolean successful) {
|
||||
if (getReportUnlockAttempts(this)) {
|
||||
logAndShowToast("onUnlockAttempt(successful=" + successful + ")");
|
||||
}
|
||||
}
|
||||
|
||||
private void logAndShowToast(String text) {
|
||||
Log.i(TAG, text);
|
||||
Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onConfigure(List<PersistableBundle> options) {
|
||||
if (options != null) {
|
||||
for (int i = 0; i < options.size(); i++) {
|
||||
Log.v(TAG, "Policy options received: " + options.get(i));
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "onConfigure() called with no options");
|
||||
}
|
||||
// TODO: Handle options
|
||||
return true; // inform DPM that we support it
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mLocalBroadcastManager.unregisterReceiver(mReceiver);
|
||||
if (ALLOW_EXTERNAL_BROADCASTS) {
|
||||
unregisterReceiver(mReceiver);
|
||||
}
|
||||
PreferenceManager.getDefaultSharedPreferences(this)
|
||||
.unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
private void onBootCompleted() {
|
||||
PreferenceManager.getDefaultSharedPreferences(this)
|
||||
.registerOnSharedPreferenceChangeListener(this);
|
||||
setManagingTrust(getIsManagingTrust(this));
|
||||
}
|
||||
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (ACTION_GRANT_TRUST.equals(action)) {
|
||||
int flags = 0;
|
||||
if (intent.getBooleanExtra(EXTRA_INITIATED_BY_USER, false)) {
|
||||
flags |= TrustAgentService.FLAG_GRANT_TRUST_INITIATED_BY_USER;
|
||||
}
|
||||
if (intent.getBooleanExtra(EXTRA_DISMISS_KEYGUARD, false)) {
|
||||
flags |= TrustAgentService.FLAG_GRANT_TRUST_DISMISS_KEYGUARD;
|
||||
}
|
||||
|
||||
try {
|
||||
grantTrust(intent.getStringExtra(EXTRA_MESSAGE),
|
||||
intent.getLongExtra(EXTRA_DURATION, 0), flags);
|
||||
} catch (IllegalStateException e) {
|
||||
logAndShowToast("IllegalStateException: " + e.getMessage());
|
||||
}
|
||||
} else if (ACTION_REVOKE_TRUST.equals(action)) {
|
||||
revokeTrust();
|
||||
} else if (intent.ACTION_BOOT_COMPLETED.equals(action)) {
|
||||
Log.d(TAG, "User unlocked and boot completed.");
|
||||
onBootCompleted();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static void sendGrantTrust(Context context,
|
||||
String message, long durationMs, boolean initiatedByUser) {
|
||||
Intent intent = new Intent(ACTION_GRANT_TRUST);
|
||||
intent.putExtra(EXTRA_MESSAGE, message);
|
||||
intent.putExtra(EXTRA_DURATION, durationMs);
|
||||
intent.putExtra(EXTRA_INITIATED_BY_USER, initiatedByUser);
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public static void sendRevokeTrust(Context context) {
|
||||
Intent intent = new Intent(ACTION_REVOKE_TRUST);
|
||||
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public static void setReportUnlockAttempts(Context context, boolean enabled) {
|
||||
SharedPreferences sharedPreferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
sharedPreferences.edit().putBoolean(PREFERENCE_REPORT_UNLOCK_ATTEMPTS, enabled).apply();
|
||||
}
|
||||
|
||||
public static boolean getReportUnlockAttempts(Context context) {
|
||||
SharedPreferences sharedPreferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return sharedPreferences.getBoolean(PREFERENCE_REPORT_UNLOCK_ATTEMPTS, false);
|
||||
}
|
||||
|
||||
public static void setReportDeviceLocked(Context context, boolean enabled) {
|
||||
SharedPreferences sharedPreferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
sharedPreferences.edit().putBoolean(PREFERENCE_REPORT_DEVICE_LOCKED, enabled).apply();
|
||||
}
|
||||
|
||||
public static boolean getReportDeviceLocked(Context context) {
|
||||
SharedPreferences sharedPreferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return sharedPreferences.getBoolean(PREFERENCE_REPORT_DEVICE_LOCKED, false);
|
||||
}
|
||||
|
||||
public static void setIsManagingTrust(Context context, boolean enabled) {
|
||||
SharedPreferences sharedPreferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
Log.d("AAAA", "save manage trust preference. Enabled=" + enabled);
|
||||
sharedPreferences.edit().putBoolean(PREFERENCE_MANAGING_TRUST, enabled).apply();
|
||||
}
|
||||
|
||||
public static boolean getIsManagingTrust(Context context) {
|
||||
SharedPreferences sharedPreferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(context);
|
||||
return sharedPreferences.getBoolean(PREFERENCE_MANAGING_TRUST, false);
|
||||
}
|
||||
|
||||
public static void setIsManagingTrustDirectBoot(Context context, boolean enabled) {
|
||||
Context directBootContext = context.createDeviceProtectedStorageContext();
|
||||
SharedPreferences sharedPreferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(directBootContext);
|
||||
Log.d("AAAA", "save to direct boot preference. Enabled=" + enabled);
|
||||
sharedPreferences.edit().putBoolean(PREFERENCE_MANAGING_TRUST_DIRECT_BOOT, enabled).apply();
|
||||
}
|
||||
|
||||
public static boolean getIsManagingTrustDirectBoot(Context context) {
|
||||
Context directBootContext = context.createDeviceProtectedStorageContext();
|
||||
SharedPreferences sharedPreferences = PreferenceManager
|
||||
.getDefaultSharedPreferences(directBootContext);
|
||||
return sharedPreferences.getBoolean(PREFERENCE_MANAGING_TRUST_DIRECT_BOOT, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
if (PREFERENCE_MANAGING_TRUST.equals(key)) {
|
||||
setManagingTrust(getIsManagingTrust(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
package com.android.trustagent.test;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.Activity;
|
||||
import android.app.KeyguardManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class SampleTrustAgentSettings extends Activity implements View.OnClickListener,
|
||||
CompoundButton.OnCheckedChangeListener {
|
||||
|
||||
private static final int TRUST_DURATION_MS = 30 * 1000;
|
||||
|
||||
private CheckBox mReportUnlockAttempts;
|
||||
private CheckBox mReportDeviceLocked;
|
||||
private CheckBox mManagingTrust;
|
||||
private CheckBox mManagingTrustDirectBoot;
|
||||
private TextView mCheckDeviceLockedResult;
|
||||
|
||||
private KeyguardManager mKeyguardManager;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mKeyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
|
||||
|
||||
setContentView(R.layout.sample_trust_agent_settings);
|
||||
|
||||
findViewById(R.id.enable_trust).setOnClickListener(this);
|
||||
findViewById(R.id.revoke_trust).setOnClickListener(this);
|
||||
findViewById(R.id.crash).setOnClickListener(this);
|
||||
findViewById(R.id.check_device_locked).setOnClickListener(this);
|
||||
|
||||
mReportUnlockAttempts = (CheckBox) findViewById(R.id.report_unlock_attempts);
|
||||
mReportUnlockAttempts.setOnCheckedChangeListener(this);
|
||||
|
||||
mReportDeviceLocked = (CheckBox) findViewById(R.id.report_device_locked);
|
||||
mReportDeviceLocked.setOnCheckedChangeListener(this);
|
||||
|
||||
mManagingTrust = (CheckBox) findViewById(R.id.managing_trust);
|
||||
mManagingTrust.setOnCheckedChangeListener(this);
|
||||
mManagingTrustDirectBoot = (CheckBox) findViewById(R.id.managing_trust_direct_boot);
|
||||
mManagingTrustDirectBoot.setOnCheckedChangeListener(this);
|
||||
|
||||
mCheckDeviceLockedResult = (TextView) findViewById(R.id.check_device_locked_result);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mReportUnlockAttempts.setChecked(SampleTrustAgent.getReportUnlockAttempts(this));
|
||||
mManagingTrust.setChecked(SampleTrustAgent.getIsManagingTrust(this));
|
||||
mManagingTrustDirectBoot.setChecked(
|
||||
SampleTrustAgent.getIsManagingTrustDirectBoot(this));
|
||||
updateTrustedState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
if (id == R.id.enable_trust) {
|
||||
SampleTrustAgent.sendGrantTrust(this, "SampleTrustAgent", TRUST_DURATION_MS,
|
||||
false /* initiatedByUser */);
|
||||
} else if (id == R.id.revoke_trust) {
|
||||
SampleTrustAgent.sendRevokeTrust(this);
|
||||
} else if (id == R.id.crash) {
|
||||
throw new RuntimeException("crash");
|
||||
} else if (id == R.id.check_device_locked) {
|
||||
updateTrustedState();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (buttonView == mReportUnlockAttempts) {
|
||||
SampleTrustAgent.setReportUnlockAttempts(this, isChecked);
|
||||
} else if (buttonView == mManagingTrust) {
|
||||
SampleTrustAgent.setIsManagingTrust(this, isChecked);
|
||||
} else if (buttonView == mReportDeviceLocked) {
|
||||
SampleTrustAgent.setReportDeviceLocked(this, isChecked);
|
||||
} else if (buttonView == mManagingTrustDirectBoot) {
|
||||
SampleTrustAgent.setIsManagingTrustDirectBoot(this, isChecked);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTrustedState() {
|
||||
mCheckDeviceLockedResult.setText(Boolean.toString(
|
||||
mKeyguardManager.isDeviceLocked()));
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 4.1 KiB |
@@ -1,47 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
**
|
||||
** Copyright 2013, 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
|
||||
<Button android:id="@+id/do_keyguard"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/do_keyguard" />
|
||||
|
||||
<Button android:id="@+id/on_screen_turned_off"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/on_screen_turned_off" />
|
||||
|
||||
<Button android:id="@+id/on_screen_turned_on"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/on_screen_turned_on" />
|
||||
|
||||
<Button android:id="@+id/verify_unlock"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/verify_unlock" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/none_menu_item"
|
||||
android:title="@string/none_menu_item" />
|
||||
<item android:id="@+id/pin_menu_item"
|
||||
android:title="@string/pin_menu_item" />
|
||||
<item android:id="@+id/password_menu_item"
|
||||
android:title="@string/password_menu_item" />
|
||||
<item android:id="@+id/pattern_menu_item"
|
||||
android:title="@string/pattern_menu_item" />
|
||||
<item android:id="@+id/sim_pin_menu_item"
|
||||
android:title="@string/sim_pin_menu_item" />
|
||||
<item android:id="@+id/sim_puk_menu_item"
|
||||
android:title="@string/sim_puk_menu_item" />
|
||||
<item android:id="@+id/add_widget_item"
|
||||
android:title="@string/add_widget_item" />
|
||||
</menu>
|
||||
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/* //device/apps/common/assets/res/any/strings.xml
|
||||
**
|
||||
** Copyright 2013, 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.
|
||||
*/
|
||||
-->
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<string name="app_name">KeyguardTestActivity</string>
|
||||
<string name="secure_app_name">UnifiedCamera</string>
|
||||
<string name="none_menu_item">No security</string>
|
||||
<string name="pin_menu_item">PIN</string>
|
||||
<string name="password_menu_item">Password</string>
|
||||
<string name="pattern_menu_item">Pattern</string>
|
||||
<string name="sim_pin_menu_item">SIM PIN</string>
|
||||
<string name="sim_puk_menu_item">SIM PUK</string>
|
||||
<string name="add_widget_item">Choose widget...</string>
|
||||
<string name="on_screen_turned_off">onScreenTurnedOff</string>
|
||||
<string name="on_screen_turned_on">onScreenTurnedOn</string>
|
||||
<string name="do_keyguard">doKeyguard</string>
|
||||
<string name="verify_unlock">verifyUnlock</string>
|
||||
</resources>
|
||||
@@ -1,373 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.
|
||||
*/
|
||||
|
||||
package com.android.keyguard.test;
|
||||
|
||||
import com.android.internal.policy.IKeyguardShowCallback;
|
||||
import com.android.internal.policy.IKeyguardExitCallback;
|
||||
import com.android.internal.policy.IKeyguardService;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.WindowManagerPolicy;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.internal.widget.LockPatternView.Cell;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class KeyguardTestActivity extends Activity implements OnClickListener {
|
||||
private static final String KEYGUARD_PACKAGE = "com.android.keyguard";
|
||||
private static final String KEYGUARD_CLASS = "com.android.keyguard.KeyguardService";
|
||||
private static final String TAG = "LockScreenTestActivity";
|
||||
private static final int MODE_NONE = 0;
|
||||
private static final int MODE_PIN = 1;
|
||||
private static final int MODE_PASSWORD = 2;
|
||||
private static final int MODE_PATTERN = 3;
|
||||
private static final int MODE_SIM_PIN = 4;
|
||||
private static final int MODE_SIM_PUK = 5;
|
||||
private static final String SECURITY_MODE = "security_mode";
|
||||
Handler mHandler = new Handler();
|
||||
|
||||
IKeyguardService mService = null;
|
||||
|
||||
KeyguardShowCallback mKeyguardShowCallback = new KeyguardShowCallback();
|
||||
KeyguardExitCallback mKeyguardExitCallback = new KeyguardExitCallback();
|
||||
|
||||
RemoteServiceConnection mConnection;
|
||||
private boolean mSentSystemReady;
|
||||
|
||||
class KeyguardShowCallback extends IKeyguardShowCallback.Stub {
|
||||
|
||||
@Override
|
||||
public void onShown(IBinder windowToken) throws RemoteException {
|
||||
Log.v(TAG, "Keyguard is shown, windowToken = " + windowToken);
|
||||
}
|
||||
}
|
||||
|
||||
class KeyguardExitCallback extends IKeyguardExitCallback.Stub {
|
||||
|
||||
@Override
|
||||
public void onKeyguardExitResult(final boolean success) throws RemoteException {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new AlertDialog.Builder(KeyguardTestActivity.this)
|
||||
.setMessage("Result: " + success)
|
||||
.setPositiveButton("OK", null)
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
private class RemoteServiceConnection implements ServiceConnection {
|
||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||
Log.v(TAG, "onServiceConnected()");
|
||||
mService = IKeyguardService.Stub.asInterface(service);
|
||||
try {
|
||||
mService.asBinder().linkToDeath(new IBinder.DeathRecipient() {
|
||||
@Override
|
||||
public void binderDied() {
|
||||
new AlertDialog.Builder(KeyguardTestActivity.this)
|
||||
.setMessage("Oops! Keygued died")
|
||||
.setPositiveButton("OK", null)
|
||||
.show();
|
||||
}
|
||||
}, 0);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Couldn't linkToDeath");
|
||||
e.printStackTrace();
|
||||
}
|
||||
// try {
|
||||
// mService.onSystemReady();
|
||||
// } catch (RemoteException e) {
|
||||
// Log.v(TAG, "Remote service died trying to call onSystemReady");
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
public void onServiceDisconnected(ComponentName className) {
|
||||
Log.v(TAG, "onServiceDisconnected()");
|
||||
mService = null;
|
||||
}
|
||||
};
|
||||
|
||||
private void bindService() {
|
||||
if (mConnection == null) {
|
||||
mConnection = new RemoteServiceConnection();
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName(KEYGUARD_PACKAGE, KEYGUARD_CLASS);
|
||||
Log.v(TAG, "BINDING SERVICE: " + KEYGUARD_CLASS);
|
||||
if (!bindService(intent, mConnection, Context.BIND_AUTO_CREATE)) {
|
||||
Log.v(TAG, "FAILED TO BIND TO KEYGUARD!");
|
||||
}
|
||||
} else {
|
||||
Log.v(TAG, "Service already bound");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.keyguard_test_activity);
|
||||
final int[] buttons = {
|
||||
R.id.on_screen_turned_off, R.id.on_screen_turned_on,
|
||||
R.id.do_keyguard, R.id.verify_unlock
|
||||
};
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
findViewById(buttons[i]).setOnClickListener(this);
|
||||
}
|
||||
Log.v(TAG, "Binding service...");
|
||||
bindService();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putInt(SECURITY_MODE, mSecurityMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
setMode(savedInstanceState.getInt(SECURITY_MODE));
|
||||
}
|
||||
|
||||
// TODO: Find a secure way to inject mock into keyguard...
|
||||
// @Override
|
||||
// public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// MenuInflater inflater = getMenuInflater();
|
||||
// inflater.inflate(R.menu.optionmenu, menu);
|
||||
// return true;
|
||||
// }
|
||||
|
||||
private void setMode(int mode) {
|
||||
mTestSimPin = false;
|
||||
mTestSimPuk = false;
|
||||
mLockPasswordEnabled = false;
|
||||
mLockPatternEnabled = false;
|
||||
switch(mode) {
|
||||
case MODE_NONE:
|
||||
mSecurityModeMock = DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
|
||||
break;
|
||||
case MODE_PIN:
|
||||
mSecurityModeMock = DevicePolicyManager.PASSWORD_QUALITY_NUMERIC;
|
||||
mLockPasswordEnabled = true;
|
||||
break;
|
||||
case MODE_PASSWORD:
|
||||
mSecurityModeMock = DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC;
|
||||
mLockPasswordEnabled = true;
|
||||
break;
|
||||
case MODE_PATTERN:
|
||||
mSecurityModeMock = DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
|
||||
mLockPatternEnabled = true;
|
||||
break;
|
||||
case MODE_SIM_PIN:
|
||||
mTestSimPin = true;
|
||||
break;
|
||||
case MODE_SIM_PUK:
|
||||
mTestSimPuk = true;
|
||||
break;
|
||||
}
|
||||
mSecurityMode = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle item selection
|
||||
switch (item.getItemId()) {
|
||||
case R.id.none_menu_item:
|
||||
setMode(MODE_NONE);
|
||||
break;
|
||||
case R.id.pin_menu_item:
|
||||
setMode(MODE_PIN);
|
||||
break;
|
||||
case R.id.password_menu_item:
|
||||
setMode(MODE_PASSWORD);
|
||||
break;
|
||||
case R.id.pattern_menu_item:
|
||||
setMode(MODE_PATTERN);
|
||||
break;
|
||||
case R.id.sim_pin_menu_item:
|
||||
setMode(MODE_SIM_PIN);
|
||||
break;
|
||||
case R.id.sim_puk_menu_item:
|
||||
setMode(MODE_SIM_PUK);
|
||||
break;
|
||||
case R.id.add_widget_item:
|
||||
startWidgetPicker();
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
try {
|
||||
mService.doKeyguardTimeout(null);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Remote service died");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void startWidgetPicker() {
|
||||
startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
switch (v.getId()) {
|
||||
case R.id.on_screen_turned_on:
|
||||
mService.onScreenTurnedOn(mKeyguardShowCallback);
|
||||
break;
|
||||
case R.id.on_screen_turned_off:
|
||||
mService.onScreenTurnedOff(WindowManagerPolicy.OFF_BECAUSE_OF_USER);
|
||||
break;
|
||||
case R.id.do_keyguard:
|
||||
if (!mSentSystemReady) {
|
||||
mSentSystemReady = true;
|
||||
mService.onSystemReady();
|
||||
}
|
||||
mService.doKeyguardTimeout(null);
|
||||
break;
|
||||
case R.id.verify_unlock:
|
||||
mService.doKeyguardTimeout(null);
|
||||
// Wait for keyguard to lock and then try this...
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
mService.verifyUnlock(mKeyguardExitCallback);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed verifyUnlock()", e);
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
break;
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "onClick(): Failed due to remote exeption", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
try {
|
||||
if (mService != null) {
|
||||
mService.setHidden(true);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Remote service died");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
try {
|
||||
if (mService != null) {
|
||||
mService.setHidden(false);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Remote service died");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public int mSecurityModeMock;
|
||||
private boolean mTestSimPin;
|
||||
private boolean mTestSimPuk;
|
||||
private boolean mLockPasswordEnabled;
|
||||
public boolean mLockPatternEnabled;
|
||||
private int mSecurityMode;
|
||||
|
||||
class LockPatternUtilsMock extends LockPatternUtils {
|
||||
private long mDeadline;
|
||||
public LockPatternUtilsMock(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPattern(List<Cell> pattern) {
|
||||
return pattern.size() > 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPassword(String password) {
|
||||
return password.length() > 4;
|
||||
}
|
||||
@Override
|
||||
public long setLockoutAttemptDeadline() {
|
||||
final long deadline = SystemClock.elapsedRealtime() + FAILED_ATTEMPT_TIMEOUT_MS;
|
||||
mDeadline = deadline;
|
||||
return deadline;
|
||||
}
|
||||
@Override
|
||||
public boolean isLockScreenDisabled() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public long getLockoutAttemptDeadline() {
|
||||
return mDeadline;
|
||||
}
|
||||
@Override
|
||||
public void reportFailedPasswordAttempt() {
|
||||
// Ignored
|
||||
}
|
||||
@Override
|
||||
public void reportSuccessfulPasswordAttempt() {
|
||||
// Ignored
|
||||
}
|
||||
@Override
|
||||
public boolean isLockPatternEnabled() {
|
||||
return mLockPatternEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLockPasswordEnabled() {
|
||||
return mLockPasswordEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getKeyguardStoredPasswordQuality() {
|
||||
return mSecurityModeMock;
|
||||
}
|
||||
|
||||
public boolean isSecure() {
|
||||
return mLockPatternEnabled || mLockPasswordEnabled || mTestSimPin || mTestSimPuk;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,14 @@ LOCAL_PROTO_JAVA_OUTPUT_PARAMS := optional_field_style=accessors
|
||||
|
||||
include $(BUILD_STATIC_JAVA_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := SystemUI-tags
|
||||
|
||||
LOCAL_SRC_FILES := src/com/android/systemui/EventLogTags.logtags
|
||||
|
||||
include $(BUILD_STATIC_JAVA_LIBRARY)
|
||||
|
||||
# ------------------
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
@@ -23,7 +31,6 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-Iaidl-files-unde
|
||||
|
||||
LOCAL_STATIC_ANDROID_LIBRARIES := \
|
||||
SystemUIPluginLib \
|
||||
Keyguard \
|
||||
android-support-v7-recyclerview \
|
||||
android-support-v7-preference \
|
||||
android-support-v7-appcompat \
|
||||
@@ -32,6 +39,7 @@ LOCAL_STATIC_ANDROID_LIBRARIES := \
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
framework-protos \
|
||||
SystemUI-tags \
|
||||
SystemUI-proto
|
||||
|
||||
LOCAL_JAVA_LIBRARIES := telephony-common
|
||||
@@ -42,6 +50,7 @@ LOCAL_CERTIFICATE := platform
|
||||
LOCAL_PRIVILEGED_MODULE := true
|
||||
|
||||
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
|
||||
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res-keyguard $(LOCAL_PATH)/res
|
||||
|
||||
ifneq ($(INCREMENTAL_BUILDS),)
|
||||
LOCAL_PROGUARD_ENABLED := disabled
|
||||
@@ -52,6 +61,8 @@ endif
|
||||
|
||||
include frameworks/base/packages/SettingsLib/common.mk
|
||||
|
||||
LOCAL_AAPT_FLAGS := --extra-packages com.android.keyguard
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
||||
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |