From 4a4101714dbd17bdabc67812e7e2449613b3f5bb Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Wed, 20 Aug 2014 17:41:44 +0200 Subject: [PATCH] Only show face unlock indication if it applies When trust is not managed or the indication is set for a different than the current user, don't show it on the lock screen. Bug: 17034124 Change-Id: Ia470520d6bd05db8417b3b0bb1f55894f791554e --- .../keyguard/KeyguardUpdateMonitor.java | 18 +++++++++++++----- .../KeyguardUpdateMonitorCallback.java | 2 +- .../phone/KeyguardBottomAreaView.java | 9 +-------- .../statusbar/phone/UnlockMethodCache.java | 16 +++++++++++++++- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java index 0d79ee2014c08..dc12cc799fba5 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -218,7 +218,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { handleFingerprintProcessed(msg.arg1); break; case MSG_FACE_UNLOCK_STATE_CHANGED: - handleFaceUnlockStateChanged(msg.arg1 != 0); + handleFaceUnlockStateChanged(msg.arg1 != 0, msg.arg2); break; } } @@ -227,6 +227,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private SparseBooleanArray mUserHasTrust = new SparseBooleanArray(); private SparseBooleanArray mUserTrustIsManaged = new SparseBooleanArray(); private SparseBooleanArray mUserFingerprintRecognized = new SparseBooleanArray(); + private SparseBooleanArray mUserFaceUnlockRunning = new SparseBooleanArray(); @Override public void onTrustChanged(boolean enabled, int userId, boolean initiatedByUser) { @@ -297,15 +298,20 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } } - private void handleFaceUnlockStateChanged(boolean running) { + private void handleFaceUnlockStateChanged(boolean running, int userId) { + mUserFaceUnlockRunning.put(userId, running); for (int i = 0; i < mCallbacks.size(); i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { - cb.onFaceUnlockStateChanged(running); + cb.onFaceUnlockStateChanged(running, userId); } } } + public boolean isFaceUnlockRunning(int userId) { + return mUserFaceUnlockRunning.get(userId); + } + private boolean isTrustDisabled(int userId) { final DevicePolicyManager dpm = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE); @@ -398,9 +404,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) { dispatchBootCompleted(); } else if (ACTION_FACE_UNLOCK_STARTED.equals(action)) { - mHandler.sendMessage(mHandler.obtainMessage(MSG_FACE_UNLOCK_STATE_CHANGED, 1, 0)); + mHandler.sendMessage(mHandler.obtainMessage(MSG_FACE_UNLOCK_STATE_CHANGED, 1, + getSendingUserId())); } else if (ACTION_FACE_UNLOCK_STOPPED.equals(action)) { - mHandler.sendMessage(mHandler.obtainMessage(MSG_FACE_UNLOCK_STATE_CHANGED, 0, 0)); + mHandler.sendMessage(mHandler.obtainMessage(MSG_FACE_UNLOCK_STATE_CHANGED, 0, + getSendingUserId())); } } }; diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java index 0acb9d0dff930..33cab8f2ce7a6 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java @@ -197,5 +197,5 @@ public class KeyguardUpdateMonitorCallback { /** * Called when the state of face unlock changed. */ - public void onFaceUnlockStateChanged(boolean running) { } + public void onFaceUnlockStateChanged(boolean running, int userId) { } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index de42fe1a0aa0f..61246b01c6d25 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -80,7 +80,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL private FlashlightController mFlashlightController; private PreviewInflater mPreviewInflater; private KeyguardIndicationController mIndicationController; - private boolean mFaceUnlockRunning; private final TrustDrawable mTrustDrawable; @@ -299,7 +298,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL return; } // TODO: Real icon for facelock. - int iconRes = mFaceUnlockRunning ? R.drawable.ic_account_circle + int iconRes = mUnlockMethodCache.isFaceUnlockRunning() ? R.drawable.ic_account_circle : mUnlockMethodCache.isMethodInsecure() ? R.drawable.ic_lock_open_24dp : R.drawable.ic_lock_24dp; mLockIcon.setImageResource(iconRes); @@ -376,12 +375,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL updateCameraVisibility(); } - @Override - public void onFaceUnlockStateChanged(boolean running) { - mFaceUnlockRunning = running; - updateLockIcon(); - } - @Override public void onScreenTurnedOn() { updateLockIcon(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java index 58196f73e66e3..e5eef9db7a899 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockMethodCache.java @@ -38,6 +38,7 @@ public class UnlockMethodCache { private final ArrayList mListeners = new ArrayList<>(); private boolean mMethodInsecure; private boolean mTrustManaged; + private boolean mFaceUnlockRunning; private UnlockMethodCache(Context ctx) { mLockPatternUtils = new LockPatternUtils(ctx); @@ -73,10 +74,14 @@ public class UnlockMethodCache { boolean methodInsecure = !mLockPatternUtils.isSecure() || mKeyguardUpdateMonitor.getUserHasTrust(user); boolean trustManaged = mKeyguardUpdateMonitor.getUserTrustIsManaged(user); - boolean changed = methodInsecure != mMethodInsecure || trustManaged != mTrustManaged; + boolean faceUnlockRunning = mKeyguardUpdateMonitor.isFaceUnlockRunning(user) + && trustManaged; + boolean changed = methodInsecure != mMethodInsecure || trustManaged != mTrustManaged + || faceUnlockRunning != mFaceUnlockRunning; if (changed || updateAlways) { mMethodInsecure = methodInsecure; mTrustManaged = trustManaged; + mFaceUnlockRunning = faceUnlockRunning; notifyListeners(mMethodInsecure); } } @@ -112,12 +117,21 @@ public class UnlockMethodCache { public void onFingerprintRecognized(int userId) { updateMethodSecure(false /* updateAlways */); } + + @Override + public void onFaceUnlockStateChanged(boolean running, int userId) { + updateMethodSecure(false /* updateAlways */); + } }; public boolean isTrustManaged() { return mTrustManaged; } + public boolean isFaceUnlockRunning() { + return mFaceUnlockRunning; + } + public static interface OnUnlockMethodChangedListener { void onMethodSecureChanged(boolean methodSecure); }