Merge "Update mState if try again is successful" into main
diff --git a/services/core/java/com/android/server/biometrics/AuthSession.java b/services/core/java/com/android/server/biometrics/AuthSession.java
index 0be893c..469e8b7 100644
--- a/services/core/java/com/android/server/biometrics/AuthSession.java
+++ b/services/core/java/com/android/server/biometrics/AuthSession.java
@@ -265,6 +265,8 @@
&& state != BiometricSensor.STATE_CANCELING) {
Slog.d(TAG, "Skip retry because sensor: " + sensor.id + " is: " + state);
continue;
+ } else if (isTryAgain) {
+ mState = STATE_AUTH_PAUSED_RESUMING;
}
final int cookie = mRandom.nextInt(Integer.MAX_VALUE - 1) + 1;
@@ -617,7 +619,6 @@
try {
setSensorsToStateWaitingForCookie(true /* isTryAgain */);
- mState = STATE_AUTH_PAUSED_RESUMING;
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException: " + e);
}
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/AuthSessionTest.java b/services/tests/servicestests/src/com/android/server/biometrics/AuthSessionTest.java
index 48f1286..1eaa170 100644
--- a/services/tests/servicestests/src/com/android/server/biometrics/AuthSessionTest.java
+++ b/services/tests/servicestests/src/com/android/server/biometrics/AuthSessionTest.java
@@ -602,6 +602,69 @@
eq(0) /* userId */);
}
+ @Test
+ public void onErrorReceivedAfterOnTryAgainPressedWhenSensorsAuthenticating() throws Exception {
+ setupFingerprint(0 /* id */, FingerprintSensorProperties.TYPE_UDFPS_OPTICAL);
+ setupFace(1 /* id */, false, mock(IBiometricAuthenticator.class));
+ final long operationId = 123;
+ final int userId = 10;
+ final AuthSession session = createAuthSession(mSensors,
+ false /* checkDevicePolicyManager */,
+ Authenticators.BIOMETRIC_STRONG,
+ TEST_REQUEST_ID,
+ operationId,
+ userId);
+ session.goToInitialState();
+ for (BiometricSensor sensor : session.mPreAuthInfo.eligibleSensors) {
+ session.onCookieReceived(
+ session.mPreAuthInfo.eligibleSensors.get(sensor.id).getCookie());
+ }
+ session.onDialogAnimatedIn(true /* startFingerprintNow */);
+
+ for (BiometricSensor sensor : session.mPreAuthInfo.eligibleSensors) {
+ assertEquals(BiometricSensor.STATE_AUTHENTICATING, sensor.getSensorState());
+ }
+ session.onTryAgainPressed();
+ session.onErrorReceived(0 /* sensorId */,
+ session.mPreAuthInfo.eligibleSensors.get(0 /* sensorId */).getCookie(),
+ BiometricConstants.BIOMETRIC_ERROR_LOCKOUT_PERMANENT, 0);
+
+ verify(mStatusBarService).onBiometricError(anyInt(), anyInt(), anyInt());
+ }
+
+ @Test
+ public void onErrorReceivedAfterOnTryAgainPressedWhenSensorStopped() throws Exception {
+ setupFingerprint(0 /* id */, FingerprintSensorProperties.TYPE_UDFPS_OPTICAL);
+ setupFace(1 /* id */, false, mock(IBiometricAuthenticator.class));
+ final long operationId = 123;
+ final int userId = 10;
+ final AuthSession session = createAuthSession(mSensors,
+ false /* checkDevicePolicyManager */,
+ Authenticators.BIOMETRIC_STRONG,
+ TEST_REQUEST_ID,
+ operationId,
+ userId);
+ session.goToInitialState();
+ for (BiometricSensor sensor : session.mPreAuthInfo.eligibleSensors) {
+ session.onCookieReceived(
+ session.mPreAuthInfo.eligibleSensors.get(sensor.id).getCookie());
+ }
+ session.onDialogAnimatedIn(true /* startFingerprintNow */);
+
+ for (BiometricSensor sensor : session.mPreAuthInfo.eligibleSensors) {
+ sensor.goToStoppedStateIfCookieMatches(sensor.getCookie(),
+ BiometricConstants.BIOMETRIC_ERROR_TIMEOUT);
+ assertEquals(BiometricSensor.STATE_STOPPED, sensor.getSensorState());
+ }
+
+ session.onTryAgainPressed();
+ session.onErrorReceived(0 /* sensorId */,
+ session.mPreAuthInfo.eligibleSensors.get(0 /* sensorId */).getCookie(),
+ BiometricConstants.BIOMETRIC_ERROR_LOCKOUT_PERMANENT, 0);
+
+ verify(mStatusBarService, never()).onBiometricError(anyInt(), anyInt(), anyInt());
+ }
+
// TODO (b/208484275) : Enable these tests
// @Test
// public void testPreAuth_canAuthAndPrivacyDisabled() throws Exception {