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
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 0d79ee2..dc12cc7 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -218,7 +218,7 @@
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 @@
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 @@
}
}
- 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 @@
} 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 0acb9d0..33cab8f 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
@@ -197,5 +197,5 @@
/**
* 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 de42fe1..61246b0 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 @@
private FlashlightController mFlashlightController;
private PreviewInflater mPreviewInflater;
private KeyguardIndicationController mIndicationController;
- private boolean mFaceUnlockRunning;
private final TrustDrawable mTrustDrawable;
@@ -299,7 +298,7 @@
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);
@@ -377,12 +376,6 @@
}
@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 58196f7..e5eef9d 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 @@
private final ArrayList<OnUnlockMethodChangedListener> mListeners = new ArrayList<>();
private boolean mMethodInsecure;
private boolean mTrustManaged;
+ private boolean mFaceUnlockRunning;
private UnlockMethodCache(Context ctx) {
mLockPatternUtils = new LockPatternUtils(ctx);
@@ -73,10 +74,14 @@
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 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);
}