Merge "Fix keyguard authentication after PIN" into sc-v2-dev am: 8fc7281abb
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16081544 Change-Id: I1de326b6a313cdd5f73ae77cac94c980671ccf05
This commit is contained in:
@@ -144,7 +144,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private static final boolean DEBUG_FACE = Build.IS_DEBUGGABLE;
|
private static final boolean DEBUG_FACE = Build.IS_DEBUGGABLE;
|
||||||
private static final boolean DEBUG_FINGERPRINT = Build.IS_DEBUGGABLE;
|
private static final boolean DEBUG_FINGERPRINT = Build.IS_DEBUGGABLE;
|
||||||
private static final boolean DEBUG_SPEW = false;
|
private static final boolean DEBUG_SPEW = false;
|
||||||
private static final int FINGERPRINT_LOCKOUT_RESET_DELAY_MS = 600;
|
private static final int BIOMETRIC_LOCKOUT_RESET_DELAY_MS = 600;
|
||||||
|
|
||||||
private static final String ACTION_FACE_UNLOCK_STARTED
|
private static final String ACTION_FACE_UNLOCK_STARTED
|
||||||
= "com.android.facelock.FACE_UNLOCK_STARTED";
|
= "com.android.facelock.FACE_UNLOCK_STARTED";
|
||||||
@@ -200,6 +200,19 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
*/
|
*/
|
||||||
private static final int BIOMETRIC_STATE_CANCELLING = 2;
|
private static final int BIOMETRIC_STATE_CANCELLING = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action indicating keyguard *can* start biometric authentiation.
|
||||||
|
*/
|
||||||
|
private static final int BIOMETRIC_ACTION_START = 0;
|
||||||
|
/**
|
||||||
|
* Action indicating keyguard *can* stop biometric authentiation.
|
||||||
|
*/
|
||||||
|
private static final int BIOMETRIC_ACTION_STOP = 1;
|
||||||
|
/**
|
||||||
|
* Action indicating keyguard *can* start or stop biometric authentiation.
|
||||||
|
*/
|
||||||
|
private static final int BIOMETRIC_ACTION_UPDATE = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Biometric state: During cancelling we got another request to start listening, so when we
|
* Biometric state: During cancelling we got another request to start listening, so when we
|
||||||
* receive the cancellation done signal, we should start listening again.
|
* receive the cancellation done signal, we should start listening again.
|
||||||
@@ -339,13 +352,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private final Runnable mFpCancelNotReceived = () -> {
|
private final Runnable mFpCancelNotReceived = () -> {
|
||||||
Log.e(TAG, "Fp cancellation not received, transitioning to STOPPED");
|
Log.e(TAG, "Fp cancellation not received, transitioning to STOPPED");
|
||||||
mFingerprintRunningState = BIOMETRIC_STATE_STOPPED;
|
mFingerprintRunningState = BIOMETRIC_STATE_STOPPED;
|
||||||
updateFingerprintListeningState();
|
updateFingerprintListeningState(BIOMETRIC_ACTION_STOP);
|
||||||
};
|
};
|
||||||
|
|
||||||
private final Runnable mFaceCancelNotReceived = () -> {
|
private final Runnable mFaceCancelNotReceived = () -> {
|
||||||
Log.e(TAG, "Face cancellation not received, transitioning to STOPPED");
|
Log.e(TAG, "Face cancellation not received, transitioning to STOPPED");
|
||||||
mFaceRunningState = BIOMETRIC_STATE_STOPPED;
|
mFaceRunningState = BIOMETRIC_STATE_STOPPED;
|
||||||
updateFaceListeningState();
|
updateFaceListeningState(BIOMETRIC_ACTION_STOP);
|
||||||
};
|
};
|
||||||
|
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
@@ -365,7 +378,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
public void onChanged(boolean enabled, int userId) throws RemoteException {
|
public void onChanged(boolean enabled, int userId) throws RemoteException {
|
||||||
mHandler.post(() -> {
|
mHandler.post(() -> {
|
||||||
mBiometricEnabledForUser.put(userId, enabled);
|
mBiometricEnabledForUser.put(userId, enabled);
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -415,7 +428,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private final KeyguardListenQueue mListenModels = new KeyguardListenQueue();
|
private final KeyguardListenQueue mListenModels = new KeyguardListenQueue();
|
||||||
|
|
||||||
private static int sCurrentUser;
|
private static int sCurrentUser;
|
||||||
private Runnable mUpdateBiometricListeningState = this::updateBiometricListeningState;
|
|
||||||
|
|
||||||
public synchronized static void setCurrentUser(int currentUser) {
|
public synchronized static void setCurrentUser(int currentUser) {
|
||||||
sCurrentUser = currentUser;
|
sCurrentUser = currentUser;
|
||||||
@@ -428,8 +440,17 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
@Override
|
@Override
|
||||||
public void onTrustChanged(boolean enabled, int userId, int flags) {
|
public void onTrustChanged(boolean enabled, int userId, int flags) {
|
||||||
Assert.isMainThread();
|
Assert.isMainThread();
|
||||||
|
boolean wasTrusted = mUserHasTrust.get(userId, false);
|
||||||
mUserHasTrust.put(userId, enabled);
|
mUserHasTrust.put(userId, enabled);
|
||||||
updateBiometricListeningState();
|
// If there was no change in trusted state, make sure we are not authenticating.
|
||||||
|
// TrustManager sends an onTrustChanged whenever a user unlocks keyguard, for
|
||||||
|
// this reason we need to make sure to not authenticate.
|
||||||
|
if (wasTrusted == enabled) {
|
||||||
|
updateBiometricListeningState(BIOMETRIC_ACTION_STOP);
|
||||||
|
} else if (!enabled) {
|
||||||
|
updateBiometricListeningState(BIOMETRIC_ACTION_START);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
||||||
if (cb != null) {
|
if (cb != null) {
|
||||||
@@ -594,7 +615,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
*/
|
*/
|
||||||
public void setCredentialAttempted() {
|
public void setCredentialAttempted() {
|
||||||
mCredentialAttempted = true;
|
mCredentialAttempted = true;
|
||||||
updateBiometricListeningState();
|
// Do not update face listening state in case of false authentication attempts.
|
||||||
|
updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -602,7 +624,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
*/
|
*/
|
||||||
public void setKeyguardGoingAway(boolean goingAway) {
|
public void setKeyguardGoingAway(boolean goingAway) {
|
||||||
mKeyguardGoingAway = goingAway;
|
mKeyguardGoingAway = goingAway;
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -610,7 +632,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
*/
|
*/
|
||||||
public void setKeyguardOccluded(boolean occluded) {
|
public void setKeyguardOccluded(boolean occluded) {
|
||||||
mKeyguardOccluded = occluded;
|
mKeyguardOccluded = occluded;
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -622,7 +644,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
*/
|
*/
|
||||||
public void requestFaceAuthOnOccludingApp(boolean request) {
|
public void requestFaceAuthOnOccludingApp(boolean request) {
|
||||||
mOccludingAppRequestingFace = request;
|
mOccludingAppRequestingFace = request;
|
||||||
updateFaceListeningState();
|
updateFaceListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -633,7 +655,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
*/
|
*/
|
||||||
public void requestFingerprintAuthOnOccludingApp(boolean request) {
|
public void requestFingerprintAuthOnOccludingApp(boolean request) {
|
||||||
mOccludingAppRequestingFp = request;
|
mOccludingAppRequestingFp = request;
|
||||||
updateFingerprintListeningState();
|
updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -641,7 +663,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
*/
|
*/
|
||||||
public void onCameraLaunched() {
|
public void onCameraLaunched() {
|
||||||
mSecureCameraLaunched = true;
|
mSecureCameraLaunched = true;
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -676,7 +698,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
}
|
}
|
||||||
// Don't send cancel if authentication succeeds
|
// Don't send cancel if authentication succeeds
|
||||||
mFingerprintCancelSignal = null;
|
mFingerprintCancelSignal = null;
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
||||||
if (cb != null) {
|
if (cb != null) {
|
||||||
@@ -772,7 +794,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
Log.w(TAG, "Retrying fingerprint after HW unavailable, attempt " +
|
Log.w(TAG, "Retrying fingerprint after HW unavailable, attempt " +
|
||||||
mHardwareFingerprintUnavailableRetryCount);
|
mHardwareFingerprintUnavailableRetryCount);
|
||||||
if (mFpm.isHardwareDetected()) {
|
if (mFpm.isHardwareDetected()) {
|
||||||
updateFingerprintListeningState();
|
updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
} else if (mHardwareFingerprintUnavailableRetryCount < HAL_ERROR_RETRY_MAX) {
|
} else if (mHardwareFingerprintUnavailableRetryCount < HAL_ERROR_RETRY_MAX) {
|
||||||
mHardwareFingerprintUnavailableRetryCount++;
|
mHardwareFingerprintUnavailableRetryCount++;
|
||||||
mHandler.postDelayed(mRetryFingerprintAuthentication, HAL_ERROR_RETRY_TIMEOUT);
|
mHandler.postDelayed(mRetryFingerprintAuthentication, HAL_ERROR_RETRY_TIMEOUT);
|
||||||
@@ -792,7 +814,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
if (msgId == FingerprintManager.FINGERPRINT_ERROR_CANCELED
|
if (msgId == FingerprintManager.FINGERPRINT_ERROR_CANCELED
|
||||||
&& mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING) {
|
&& mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING) {
|
||||||
setFingerprintRunningState(BIOMETRIC_STATE_STOPPED);
|
setFingerprintRunningState(BIOMETRIC_STATE_STOPPED);
|
||||||
updateFingerprintListeningState();
|
updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
} else {
|
} else {
|
||||||
setFingerprintRunningState(BIOMETRIC_STATE_STOPPED);
|
setFingerprintRunningState(BIOMETRIC_STATE_STOPPED);
|
||||||
}
|
}
|
||||||
@@ -813,7 +835,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
lockedOutStateChanged |= !mFingerprintLockedOut;
|
lockedOutStateChanged |= !mFingerprintLockedOut;
|
||||||
mFingerprintLockedOut = true;
|
mFingerprintLockedOut = true;
|
||||||
if (isUdfpsEnrolled()) {
|
if (isUdfpsEnrolled()) {
|
||||||
updateFingerprintListeningState();
|
updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -840,10 +862,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
// that the events will arrive in a particular order. Add a delay here in case
|
// that the events will arrive in a particular order. Add a delay here in case
|
||||||
// an unlock is in progress. In this is a normal unlock the extra delay won't
|
// an unlock is in progress. In this is a normal unlock the extra delay won't
|
||||||
// be noticeable.
|
// be noticeable.
|
||||||
mHandler.postDelayed(this::updateFingerprintListeningState,
|
mHandler.postDelayed(() -> {
|
||||||
FINGERPRINT_LOCKOUT_RESET_DELAY_MS);
|
updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
|
}, BIOMETRIC_LOCKOUT_RESET_DELAY_MS);
|
||||||
} else {
|
} else {
|
||||||
updateFingerprintListeningState();
|
updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
@@ -887,7 +910,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
}
|
}
|
||||||
// Don't send cancel if authentication succeeds
|
// Don't send cancel if authentication succeeds
|
||||||
mFaceCancelSignal = null;
|
mFaceCancelSignal = null;
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
||||||
if (cb != null) {
|
if (cb != null) {
|
||||||
@@ -980,7 +1003,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
public void run() {
|
public void run() {
|
||||||
Log.w(TAG, "Retrying face after HW unavailable, attempt " +
|
Log.w(TAG, "Retrying face after HW unavailable, attempt " +
|
||||||
mHardwareFaceUnavailableRetryCount);
|
mHardwareFaceUnavailableRetryCount);
|
||||||
updateFaceListeningState();
|
updateFaceListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -997,7 +1020,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
if (msgId == FaceManager.FACE_ERROR_CANCELED
|
if (msgId == FaceManager.FACE_ERROR_CANCELED
|
||||||
&& mFaceRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING) {
|
&& mFaceRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING) {
|
||||||
setFaceRunningState(BIOMETRIC_STATE_STOPPED);
|
setFaceRunningState(BIOMETRIC_STATE_STOPPED);
|
||||||
updateFaceListeningState();
|
updateFaceListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
} else {
|
} else {
|
||||||
setFaceRunningState(BIOMETRIC_STATE_STOPPED);
|
setFaceRunningState(BIOMETRIC_STATE_STOPPED);
|
||||||
}
|
}
|
||||||
@@ -1035,7 +1058,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
boolean changed = mFaceLockedOutPermanent;
|
boolean changed = mFaceLockedOutPermanent;
|
||||||
mFaceLockedOutPermanent = false;
|
mFaceLockedOutPermanent = false;
|
||||||
|
|
||||||
updateFaceListeningState();
|
mHandler.postDelayed(() -> {
|
||||||
|
updateFaceListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
|
}, BIOMETRIC_LOCKOUT_RESET_DELAY_MS);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
notifyLockedOutStateChanged(BiometricSourceType.FACE);
|
notifyLockedOutStateChanged(BiometricSourceType.FACE);
|
||||||
@@ -1288,7 +1313,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void setAssistantVisible(boolean assistantVisible) {
|
void setAssistantVisible(boolean assistantVisible) {
|
||||||
mAssistantVisible = assistantVisible;
|
mAssistantVisible = assistantVisible;
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class DisplayClientState {
|
static class DisplayClientState {
|
||||||
@@ -1627,7 +1652,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
protected void handleStartedWakingUp() {
|
protected void handleStartedWakingUp() {
|
||||||
Trace.beginSection("KeyguardUpdateMonitor#handleStartedWakingUp");
|
Trace.beginSection("KeyguardUpdateMonitor#handleStartedWakingUp");
|
||||||
Assert.isMainThread();
|
Assert.isMainThread();
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
||||||
if (cb != null) {
|
if (cb != null) {
|
||||||
@@ -1648,7 +1673,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mGoingToSleep = true;
|
mGoingToSleep = true;
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleFinishedGoingToSleep(int arg1) {
|
protected void handleFinishedGoingToSleep(int arg1) {
|
||||||
@@ -1660,7 +1685,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
cb.onFinishedGoingToSleep(arg1);
|
cb.onFinishedGoingToSleep(arg1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleScreenTurnedOn() {
|
private void handleScreenTurnedOn() {
|
||||||
@@ -1697,7 +1722,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
cb.onDreamingStateChanged(mIsDreaming);
|
cb.onDreamingStateChanged(mIsDreaming);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleUserInfoChanged(int userId) {
|
private void handleUserInfoChanged(int userId) {
|
||||||
@@ -1888,7 +1913,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
setAssistantVisible((boolean) msg.obj);
|
setAssistantVisible((boolean) msg.obj);
|
||||||
break;
|
break;
|
||||||
case MSG_BIOMETRIC_AUTHENTICATION_CONTINUE:
|
case MSG_BIOMETRIC_AUTHENTICATION_CONTINUE:
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
break;
|
break;
|
||||||
case MSG_DEVICE_POLICY_MANAGER_STATE_CHANGED:
|
case MSG_DEVICE_POLICY_MANAGER_STATE_CHANGED:
|
||||||
updateLogoutEnabled();
|
updateLogoutEnabled();
|
||||||
@@ -2006,10 +2031,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnrollmentsChanged() {
|
public void onEnrollmentsChanged() {
|
||||||
mainExecutor.execute(() -> updateBiometricListeningState());
|
mainExecutor.execute(() -> updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
if (mFpm != null) {
|
if (mFpm != null) {
|
||||||
mFpm.addLockoutResetCallback(mFingerprintLockoutResetCallback);
|
mFpm.addLockoutResetCallback(mFingerprintLockoutResetCallback);
|
||||||
}
|
}
|
||||||
@@ -2123,12 +2148,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
mHandler.sendEmptyMessage(MSG_AIRPLANE_MODE_CHANGED);
|
mHandler.sendEmptyMessage(MSG_AIRPLANE_MODE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBiometricListeningState() {
|
private void updateBiometricListeningState(int action) {
|
||||||
updateFingerprintListeningState();
|
updateFingerprintListeningState(action);
|
||||||
updateFaceListeningState();
|
updateFaceListeningState(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFingerprintListeningState() {
|
private void updateFingerprintListeningState(int action) {
|
||||||
// If this message exists, we should not authenticate again until this message is
|
// If this message exists, we should not authenticate again until this message is
|
||||||
// consumed by the handler
|
// consumed by the handler
|
||||||
if (mHandler.hasMessages(MSG_BIOMETRIC_AUTHENTICATION_CONTINUE)) {
|
if (mHandler.hasMessages(MSG_BIOMETRIC_AUTHENTICATION_CONTINUE)) {
|
||||||
@@ -2140,8 +2165,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
final boolean runningOrRestarting = mFingerprintRunningState == BIOMETRIC_STATE_RUNNING
|
final boolean runningOrRestarting = mFingerprintRunningState == BIOMETRIC_STATE_RUNNING
|
||||||
|| mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING;
|
|| mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING;
|
||||||
if (runningOrRestarting && !shouldListenForFingerprint) {
|
if (runningOrRestarting && !shouldListenForFingerprint) {
|
||||||
|
if (action == BIOMETRIC_ACTION_START) {
|
||||||
|
Log.v(TAG, "Ignoring stopListeningForFingerprint()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
stopListeningForFingerprint();
|
stopListeningForFingerprint();
|
||||||
} else if (!runningOrRestarting && shouldListenForFingerprint) {
|
} else if (!runningOrRestarting && shouldListenForFingerprint) {
|
||||||
|
if (action == BIOMETRIC_ACTION_STOP) {
|
||||||
|
Log.v(TAG, "Ignoring startListeningForFingerprint()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
startListeningForFingerprint();
|
startListeningForFingerprint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2170,7 +2203,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mAuthInterruptActive = active;
|
mAuthInterruptActive = active;
|
||||||
updateFaceListeningState();
|
updateFaceListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2181,7 +2214,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
public void requestFaceAuth(boolean userInitiatedRequest) {
|
public void requestFaceAuth(boolean userInitiatedRequest) {
|
||||||
if (DEBUG) Log.d(TAG, "requestFaceAuth() userInitiated=" + userInitiatedRequest);
|
if (DEBUG) Log.d(TAG, "requestFaceAuth() userInitiated=" + userInitiatedRequest);
|
||||||
mIsFaceAuthUserRequested |= userInitiatedRequest;
|
mIsFaceAuthUserRequested |= userInitiatedRequest;
|
||||||
updateFaceListeningState();
|
updateFaceListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFaceAuthUserRequested() {
|
public boolean isFaceAuthUserRequested() {
|
||||||
@@ -2195,7 +2228,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
stopListeningForFace();
|
stopListeningForFace();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFaceListeningState() {
|
private void updateFaceListeningState(int action) {
|
||||||
// If this message exists, we should not authenticate again until this message is
|
// If this message exists, we should not authenticate again until this message is
|
||||||
// consumed by the handler
|
// consumed by the handler
|
||||||
if (mHandler.hasMessages(MSG_BIOMETRIC_AUTHENTICATION_CONTINUE)) {
|
if (mHandler.hasMessages(MSG_BIOMETRIC_AUTHENTICATION_CONTINUE)) {
|
||||||
@@ -2204,9 +2237,17 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
mHandler.removeCallbacks(mRetryFaceAuthentication);
|
mHandler.removeCallbacks(mRetryFaceAuthentication);
|
||||||
boolean shouldListenForFace = shouldListenForFace();
|
boolean shouldListenForFace = shouldListenForFace();
|
||||||
if (mFaceRunningState == BIOMETRIC_STATE_RUNNING && !shouldListenForFace) {
|
if (mFaceRunningState == BIOMETRIC_STATE_RUNNING && !shouldListenForFace) {
|
||||||
|
if (action == BIOMETRIC_ACTION_START) {
|
||||||
|
Log.v(TAG, "Ignoring stopListeningForFace()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
mIsFaceAuthUserRequested = false;
|
mIsFaceAuthUserRequested = false;
|
||||||
stopListeningForFace();
|
stopListeningForFace();
|
||||||
} else if (mFaceRunningState != BIOMETRIC_STATE_RUNNING && shouldListenForFace) {
|
} else if (mFaceRunningState != BIOMETRIC_STATE_RUNNING && shouldListenForFace) {
|
||||||
|
if (action == BIOMETRIC_ACTION_STOP) {
|
||||||
|
Log.v(TAG, "Ignoring startListeningForFace()");
|
||||||
|
return;
|
||||||
|
}
|
||||||
startListeningForFace();
|
startListeningForFace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2414,7 +2455,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
mLockIconPressed = true;
|
mLockIconPressed = true;
|
||||||
final int userId = getCurrentUser();
|
final int userId = getCurrentUser();
|
||||||
mUserFaceAuthenticated.put(userId, null);
|
mUserFaceAuthenticated.put(userId, null);
|
||||||
updateFaceListeningState();
|
updateFaceListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
mStrongAuthTracker.onStrongAuthRequiredChanged(userId);
|
mStrongAuthTracker.onStrongAuthRequiredChanged(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2590,7 +2631,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
*/
|
*/
|
||||||
private void handleDevicePolicyManagerStateChanged(int userId) {
|
private void handleDevicePolicyManagerStateChanged(int userId) {
|
||||||
Assert.isMainThread();
|
Assert.isMainThread();
|
||||||
updateFingerprintListeningState();
|
updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
updateSecondaryLockscreenRequirement(userId);
|
updateSecondaryLockscreenRequirement(userId);
|
||||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
||||||
@@ -2880,7 +2921,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
cb.onKeyguardVisibilityChangedRaw(showing);
|
cb.onKeyguardVisibilityChangedRaw(showing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Notifies that the occluded state changed. */
|
/** Notifies that the occluded state changed. */
|
||||||
@@ -2902,7 +2943,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
*/
|
*/
|
||||||
private void handleKeyguardReset() {
|
private void handleKeyguardReset() {
|
||||||
if (DEBUG) Log.d(TAG, "handleKeyguardReset");
|
if (DEBUG) Log.d(TAG, "handleKeyguardReset");
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
mNeedsSlowUnlockTransition = resolveNeedsSlowUnlockTransition();
|
mNeedsSlowUnlockTransition = resolveNeedsSlowUnlockTransition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2948,7 +2989,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
cb.onKeyguardBouncerChanged(mBouncer);
|
cb.onKeyguardBouncerChanged(mBouncer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateBiometricListeningState();
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3068,7 +3109,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
public void setSwitchingUser(boolean switching) {
|
public void setSwitchingUser(boolean switching) {
|
||||||
mSwitchingUser = switching;
|
mSwitchingUser = switching;
|
||||||
// Since this comes in on a binder thread, we need to post if first
|
// Since this comes in on a binder thread, we need to post if first
|
||||||
mHandler.post(mUpdateBiometricListeningState);
|
mHandler.post(() -> {
|
||||||
|
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendUpdates(KeyguardUpdateMonitorCallback callback) {
|
private void sendUpdates(KeyguardUpdateMonitorCallback callback) {
|
||||||
|
|||||||
@@ -1056,6 +1056,16 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
|
|||||||
verify(callback, atLeastOnce()).onRequireUnlockForNfc();
|
verify(callback, atLeastOnce()).onRequireUnlockForNfc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFaceDoesNotAuth_afterPinAttempt() {
|
||||||
|
mTestableLooper.processAllMessages();
|
||||||
|
mKeyguardUpdateMonitor.setCredentialAttempted();
|
||||||
|
verify(mFingerprintManager, never()).authenticate(any(), any(), any(),
|
||||||
|
any(), anyInt());
|
||||||
|
verify(mFaceManager, never()).authenticate(any(), any(), any(), any(), anyInt(),
|
||||||
|
anyBoolean());
|
||||||
|
}
|
||||||
|
|
||||||
private void setKeyguardBouncerVisibility(boolean isVisible) {
|
private void setKeyguardBouncerVisibility(boolean isVisible) {
|
||||||
mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(isVisible);
|
mKeyguardUpdateMonitor.sendKeyguardBouncerChanged(isVisible);
|
||||||
mTestableLooper.processAllMessages();
|
mTestableLooper.processAllMessages();
|
||||||
|
|||||||
Reference in New Issue
Block a user