Merge "Fix KeyguardUpdateMonitor auth lifecycle issues" into sc-dev am: 755ee24f4c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15474434 Change-Id: I76e9fa2971f214bff6ade49c99bc3d89c3745e09
This commit is contained in:
@@ -347,13 +347,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private static final int HAL_ERROR_RETRY_TIMEOUT = 500; // ms
|
private static final int HAL_ERROR_RETRY_TIMEOUT = 500; // ms
|
||||||
private static final int HAL_ERROR_RETRY_MAX = 20;
|
private static final int HAL_ERROR_RETRY_MAX = 20;
|
||||||
|
|
||||||
private final Runnable mCancelNotReceived = new Runnable() {
|
private final Runnable mFpCancelNotReceived = () -> {
|
||||||
@Override
|
Log.e(TAG, "Fp cancellation not received, transitioning to STOPPED");
|
||||||
public void run() {
|
mFingerprintRunningState = BIOMETRIC_STATE_STOPPED;
|
||||||
Log.w(TAG, "Cancel not received, transitioning to STOPPED");
|
updateFingerprintListeningState();
|
||||||
mFingerprintRunningState = mFaceRunningState = BIOMETRIC_STATE_STOPPED;
|
};
|
||||||
updateBiometricListeningState();
|
|
||||||
}
|
private final Runnable mFaceCancelNotReceived = () -> {
|
||||||
|
Log.e(TAG, "Face cancellation not received, transitioning to STOPPED");
|
||||||
|
mFaceRunningState = BIOMETRIC_STATE_STOPPED;
|
||||||
|
updateFaceListeningState();
|
||||||
};
|
};
|
||||||
|
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
@@ -791,19 +794,19 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
|
|
||||||
private void handleFingerprintError(int msgId, String errString) {
|
private void handleFingerprintError(int msgId, String errString) {
|
||||||
Assert.isMainThread();
|
Assert.isMainThread();
|
||||||
if (msgId == FingerprintManager.FINGERPRINT_ERROR_CANCELED && mHandler.hasCallbacks(
|
if (mHandler.hasCallbacks(mFpCancelNotReceived)) {
|
||||||
mCancelNotReceived)) {
|
mHandler.removeCallbacks(mFpCancelNotReceived);
|
||||||
mHandler.removeCallbacks(mCancelNotReceived);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error is always the end of authentication lifecycle.
|
||||||
|
mFingerprintCancelSignal = null;
|
||||||
|
|
||||||
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();
|
||||||
} else {
|
} else {
|
||||||
setFingerprintRunningState(BIOMETRIC_STATE_STOPPED);
|
setFingerprintRunningState(BIOMETRIC_STATE_STOPPED);
|
||||||
mFingerprintCancelSignal = null;
|
|
||||||
mFaceCancelSignal = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgId == FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE) {
|
if (msgId == FingerprintManager.FINGERPRINT_ERROR_HW_UNAVAILABLE) {
|
||||||
@@ -905,6 +908,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
|
|
||||||
private void handleFaceAuthFailed() {
|
private void handleFaceAuthFailed() {
|
||||||
Assert.isMainThread();
|
Assert.isMainThread();
|
||||||
|
mFaceCancelSignal = null;
|
||||||
setFaceRunningState(BIOMETRIC_STATE_STOPPED);
|
setFaceRunningState(BIOMETRIC_STATE_STOPPED);
|
||||||
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();
|
||||||
@@ -983,10 +987,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private void handleFaceError(int msgId, String errString) {
|
private void handleFaceError(int msgId, String errString) {
|
||||||
Assert.isMainThread();
|
Assert.isMainThread();
|
||||||
if (DEBUG_FACE) Log.d(TAG, "Face error received: " + errString);
|
if (DEBUG_FACE) Log.d(TAG, "Face error received: " + errString);
|
||||||
if (msgId == FaceManager.FACE_ERROR_CANCELED && mHandler.hasCallbacks(mCancelNotReceived)) {
|
if (mHandler.hasCallbacks(mFaceCancelNotReceived)) {
|
||||||
mHandler.removeCallbacks(mCancelNotReceived);
|
mHandler.removeCallbacks(mFaceCancelNotReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error is always the end of authentication lifecycle
|
||||||
|
mFaceCancelSignal = null;
|
||||||
|
|
||||||
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);
|
||||||
@@ -2368,6 +2375,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startListeningForFingerprint() {
|
private void startListeningForFingerprint() {
|
||||||
|
final int userId = getCurrentUser();
|
||||||
|
final boolean unlockPossible = isUnlockWithFingerprintPossible(userId);
|
||||||
|
if (mFingerprintCancelSignal != null) {
|
||||||
|
Log.e(TAG, "Cancellation signal is not null, high chance of bug in fp auth lifecycle"
|
||||||
|
+ " management. FP state: " + mFingerprintRunningState
|
||||||
|
+ ", unlockPossible: " + unlockPossible);
|
||||||
|
}
|
||||||
|
|
||||||
if (mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING) {
|
if (mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING) {
|
||||||
setFingerprintRunningState(BIOMETRIC_STATE_CANCELLING_RESTARTING);
|
setFingerprintRunningState(BIOMETRIC_STATE_CANCELLING_RESTARTING);
|
||||||
return;
|
return;
|
||||||
@@ -2377,11 +2392,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.v(TAG, "startListeningForFingerprint()");
|
if (DEBUG) Log.v(TAG, "startListeningForFingerprint()");
|
||||||
int userId = getCurrentUser();
|
|
||||||
if (isUnlockWithFingerprintPossible(userId)) {
|
if (unlockPossible) {
|
||||||
if (mFingerprintCancelSignal != null) {
|
|
||||||
mFingerprintCancelSignal.cancel();
|
|
||||||
}
|
|
||||||
mFingerprintCancelSignal = new CancellationSignal();
|
mFingerprintCancelSignal = new CancellationSignal();
|
||||||
|
|
||||||
if (isEncryptedOrLockdown(userId)) {
|
if (isEncryptedOrLockdown(userId)) {
|
||||||
@@ -2397,6 +2409,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startListeningForFace() {
|
private void startListeningForFace() {
|
||||||
|
final int userId = getCurrentUser();
|
||||||
|
final boolean unlockPossible = isUnlockWithFacePossible(userId);
|
||||||
|
if (mFaceCancelSignal != null) {
|
||||||
|
Log.e(TAG, "Cancellation signal is not null, high chance of bug in face auth lifecycle"
|
||||||
|
+ " management. Face state: " + mFaceRunningState
|
||||||
|
+ ", unlockPossible: " + unlockPossible);
|
||||||
|
}
|
||||||
|
|
||||||
if (mFaceRunningState == BIOMETRIC_STATE_CANCELLING) {
|
if (mFaceRunningState == BIOMETRIC_STATE_CANCELLING) {
|
||||||
setFaceRunningState(BIOMETRIC_STATE_CANCELLING_RESTARTING);
|
setFaceRunningState(BIOMETRIC_STATE_CANCELLING_RESTARTING);
|
||||||
return;
|
return;
|
||||||
@@ -2405,11 +2425,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.v(TAG, "startListeningForFace(): " + mFaceRunningState);
|
if (DEBUG) Log.v(TAG, "startListeningForFace(): " + mFaceRunningState);
|
||||||
int userId = getCurrentUser();
|
|
||||||
if (isUnlockWithFacePossible(userId)) {
|
if (unlockPossible) {
|
||||||
if (mFaceCancelSignal != null) {
|
|
||||||
mFaceCancelSignal.cancel();
|
|
||||||
}
|
|
||||||
mFaceCancelSignal = new CancellationSignal();
|
mFaceCancelSignal = new CancellationSignal();
|
||||||
|
|
||||||
// This would need to be updated for multi-sensor devices
|
// This would need to be updated for multi-sensor devices
|
||||||
@@ -2461,9 +2478,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
if (mFingerprintCancelSignal != null) {
|
if (mFingerprintCancelSignal != null) {
|
||||||
mFingerprintCancelSignal.cancel();
|
mFingerprintCancelSignal.cancel();
|
||||||
mFingerprintCancelSignal = null;
|
mFingerprintCancelSignal = null;
|
||||||
if (!mHandler.hasCallbacks(mCancelNotReceived)) {
|
mHandler.removeCallbacks(mFpCancelNotReceived);
|
||||||
mHandler.postDelayed(mCancelNotReceived, DEFAULT_CANCEL_SIGNAL_TIMEOUT);
|
mHandler.postDelayed(mFpCancelNotReceived, DEFAULT_CANCEL_SIGNAL_TIMEOUT);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setFingerprintRunningState(BIOMETRIC_STATE_CANCELLING);
|
setFingerprintRunningState(BIOMETRIC_STATE_CANCELLING);
|
||||||
}
|
}
|
||||||
@@ -2478,9 +2494,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
if (mFaceCancelSignal != null) {
|
if (mFaceCancelSignal != null) {
|
||||||
mFaceCancelSignal.cancel();
|
mFaceCancelSignal.cancel();
|
||||||
mFaceCancelSignal = null;
|
mFaceCancelSignal = null;
|
||||||
if (!mHandler.hasCallbacks(mCancelNotReceived)) {
|
mHandler.removeCallbacks(mFaceCancelNotReceived);
|
||||||
mHandler.postDelayed(mCancelNotReceived, DEFAULT_CANCEL_SIGNAL_TIMEOUT);
|
mHandler.postDelayed(mFaceCancelNotReceived, DEFAULT_CANCEL_SIGNAL_TIMEOUT);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setFaceRunningState(BIOMETRIC_STATE_CANCELLING);
|
setFaceRunningState(BIOMETRIC_STATE_CANCELLING);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user