summaryrefslogtreecommitdiffstats
path: root/packages/Keyguard
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2014-03-31 19:26:01 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-03-31 19:26:01 +0000
commite5bfd6d7ce8a856f753f6fef81c85ef9ffef0635 (patch)
treeaf08888fa994dcc460d61a495de6a4bd746222b4 /packages/Keyguard
parent3830700257028d26506f4a9bd5a3dd25798d675f (diff)
parent46842d946d1777c22f05e6bb96933c1b5cbd00d4 (diff)
downloadframeworks_base-e5bfd6d7ce8a856f753f6fef81c85ef9ffef0635.zip
frameworks_base-e5bfd6d7ce8a856f753f6fef81c85ef9ffef0635.tar.gz
frameworks_base-e5bfd6d7ce8a856f753f6fef81c85ef9ffef0635.tar.bz2
am 46842d94: Make Keyguard trust aware
* commit '46842d946d1777c22f05e6bb96933c1b5cbd00d4': Make Keyguard trust aware
Diffstat (limited to 'packages/Keyguard')
-rw-r--r--packages/Keyguard/AndroidManifest.xml1
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java20
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java3
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java19
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java1
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java4
6 files changed, 40 insertions, 8 deletions
diff --git a/packages/Keyguard/AndroidManifest.xml b/packages/Keyguard/AndroidManifest.xml
index 35226e5..75b7dbd 100644
--- a/packages/Keyguard/AndroidManifest.xml
+++ b/packages/Keyguard/AndroidManifest.xml
@@ -39,6 +39,7 @@
<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />
<uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
<uses-permission android:name="android.permission.ACCESS_KEYGUARD_SECURE_STORAGE" />
+ <uses-permission android:name="android.permission.TRUST_LISTENER" />
<application android:label="@string/app_name"
android:process="com.android.systemui"
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java b/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java
index 368a97a..0d5e477 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java
@@ -104,9 +104,10 @@ public abstract class KeyguardActivityLauncher {
// Workaround to avoid camera release/acquisition race when resuming face unlock
// after showing lockscreen camera (bug 11063890).
- KeyguardUpdateMonitor.getInstance(getContext()).setAlternateUnlockEnabled(false);
+ KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(getContext());
+ updateMonitor.setAlternateUnlockEnabled(false);
- if (lockPatternUtils.isSecure()) {
+ if (mustLaunchSecurely()) {
// Launch the secure version of the camera
if (wouldLaunchResolverActivity(SECURE_CAMERA_INTENT)) {
// TODO: Show disambiguation dialog instead.
@@ -123,6 +124,13 @@ public abstract class KeyguardActivityLauncher {
}
}
+ private boolean mustLaunchSecurely() {
+ LockPatternUtils lockPatternUtils = getLockPatternUtils();
+ KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(getContext());
+ int currentUser = lockPatternUtils.getCurrentUser();
+ return lockPatternUtils.isSecure() && !updateMonitor.getUserHasTrust(currentUser);
+ }
+
public void launchWidgetPicker(int appWidgetId) {
Intent pickIntent = new Intent(AppWidgetManager.ACTION_KEYGUARD_APPWIDGET_PICK);
@@ -177,9 +185,9 @@ public abstract class KeyguardActivityLauncher {
Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_SINGLE_TOP
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
- boolean isSecure = lockPatternUtils.isSecure();
- if (!isSecure || showsWhileLocked) {
- if (!isSecure) {
+ boolean mustLaunchSecurely = mustLaunchSecurely();
+ if (!mustLaunchSecurely || showsWhileLocked) {
+ if (!mustLaunchSecurely) {
dismissKeyguardOnNextActivity();
}
try {
@@ -253,7 +261,7 @@ public abstract class KeyguardActivityLauncher {
}
private Intent getCameraIntent() {
- return getLockPatternUtils().isSecure() ? SECURE_CAMERA_INTENT : INSECURE_CAMERA_INTENT;
+ return mustLaunchSecurely() ? SECURE_CAMERA_INTENT : INSECURE_CAMERA_INTENT;
}
private boolean wouldLaunchResolverActivity(Intent intent) {
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
index 9f5768a..da6482a 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
@@ -23,6 +23,7 @@ import com.android.internal.telephony.IccCardConstants;
import com.android.internal.widget.LockPatternUtils;
public class KeyguardSecurityModel {
+
/**
* The different types of security available for {@link Mode#UnlockScreen}.
* @see com.android.internal.policy.impl.LockPatternKeyguardView#getUnlockMode()
@@ -82,6 +83,8 @@ public class KeyguardSecurityModel {
} else if (simState == IccCardConstants.State.PUK_REQUIRED
&& mLockPatternUtils.isPukUnlockScreenEnable()) {
mode = SecurityMode.SimPuk;
+ } else if (updateMonitor.getUserHasTrust(mLockPatternUtils.getCurrentUser())) {
+ mode = SecurityMode.None;
} else {
final int security = mLockPatternUtils.getKeyguardStoredPasswordQuality();
switch (security) {
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 3b712e9..88c78ab 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -20,6 +20,7 @@ import android.app.ActivityManagerNative;
import android.app.IUserSwitchObserver;
import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager;
+import android.app.trust.TrustManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -51,6 +52,8 @@ import com.android.internal.telephony.TelephonyIntents;
import android.telephony.TelephonyManager;
import android.util.Log;
+import android.util.SparseBooleanArray;
+
import com.google.android.collect.Lists;
import java.lang.ref.WeakReference;
@@ -66,7 +69,7 @@ import java.util.ArrayList;
* the device, and {@link #getFailedUnlockAttempts()}, {@link #reportFailedAttempt()}
* and {@link #clearFailedUnlockAttempts()}. Maybe we should rename this 'KeyguardContext'...
*/
-public class KeyguardUpdateMonitor {
+public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
private static final String TAG = "KeyguardUpdateMonitor";
private static final boolean DEBUG = false;
@@ -205,6 +208,17 @@ public class KeyguardUpdateMonitor {
private AudioManager mAudioManager;
+ private SparseBooleanArray mUserHasTrust = new SparseBooleanArray();
+
+ @Override
+ public void onTrustChanged(boolean enabled, int userId) {
+ mUserHasTrust.put(userId, enabled);
+ }
+
+ public boolean getUserHasTrust(int userId) {
+ return mUserHasTrust.get(userId);
+ }
+
static class DisplayClientState {
public int clientGeneration;
public boolean clearing;
@@ -581,6 +595,9 @@ public class KeyguardUpdateMonitor {
// TODO Auto-generated catch block
e.printStackTrace();
}
+
+ TrustManager trustManager = (TrustManager) context.getSystemService(Context.TRUST_SERVICE);
+ trustManager.registerTrustListener(this);
}
private boolean isDeviceProvisionedInSettingsDb() {
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
index 481d132..556711b 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
@@ -178,4 +178,5 @@ class KeyguardUpdateMonitorCallback {
* Called when the NFC Service has found a tag that is registered for NFC unlock.
*/
public void onNfcUnlock() { }
+
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java
index 31e806c..c3aa47f 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java
@@ -550,7 +550,9 @@ public class KeyguardViewMediator {
@Override
public int getSessionType() {
- return mLockPatternUtils.isSecure() ? Session.TYPE_KEYGUARD_SECURE
+ return mLockPatternUtils.isSecure() && !mUpdateMonitor.getUserHasTrust(
+ mLockPatternUtils.getCurrentUser())
+ ? Session.TYPE_KEYGUARD_SECURE
: Session.TYPE_KEYGUARD_INSECURE;
}
}, new File(mContext.getCacheDir(), "keyguard_analytics.bin"));