diff options
author | Adrian Roos <roosa@google.com> | 2014-03-31 19:26:14 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-03-31 19:26:14 +0000 |
commit | 78d9aece821cf8f40eb95aa962cb3ea707669413 (patch) | |
tree | 8febf46597b07c703dbcdb7579049b304beab9bf /packages/Keyguard/src/com/android | |
parent | e6978cda7110823f70cc74319c37bd512866c6f1 (diff) | |
parent | 46842d946d1777c22f05e6bb96933c1b5cbd00d4 (diff) | |
download | frameworks_base-78d9aece821cf8f40eb95aa962cb3ea707669413.zip frameworks_base-78d9aece821cf8f40eb95aa962cb3ea707669413.tar.gz frameworks_base-78d9aece821cf8f40eb95aa962cb3ea707669413.tar.bz2 |
am 46842d94: Make Keyguard trust aware
* commit '46842d946d1777c22f05e6bb96933c1b5cbd00d4':
Make Keyguard trust aware
Diffstat (limited to 'packages/Keyguard/src/com/android')
4 files changed, 36 insertions, 7 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java b/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java index 2e112ac..25f3383 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 98ecc9c..73c2840 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 = KeyguardConstants.DEBUG; @@ -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 a9bcb5d..862931e 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java @@ -178,4 +178,5 @@ public class KeyguardUpdateMonitorCallback { * Called when the NFC Service has found a tag that is registered for NFC unlock. */ public void onNfcUnlock() { } + } |