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
This commit is contained in:
Adrian Roos
2014-08-20 17:41:44 +02:00
parent 46a8f45253
commit 4a4101714d
4 changed files with 30 additions and 15 deletions

View File

@@ -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()));
}
}
};

View File

@@ -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) { }
}

View File

@@ -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();

View File

@@ -38,6 +38,7 @@ public class UnlockMethodCache {
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 @@ 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);
}