diff options
| author | 2024-05-21 15:27:16 +0000 | |
|---|---|---|
| committer | 2024-05-21 15:50:06 +0000 | |
| commit | 39b6c397d5c331657e2d2684974cad2681c190e2 (patch) | |
| tree | d9869ac208993d8b55a339830dbaa93c93b1be0e | |
| parent | 270dc7d758d0974756165d6fa2af315b99eecad6 (diff) | |
Update mState if try again is successful
Test: atest AuthSessionTest
Fixes: 341443262
Change-Id: I37ae8b5de7af25ee716a2972d389e2f061465c3f
| -rw-r--r-- | services/core/java/com/android/server/biometrics/AuthSession.java | 3 | ||||
| -rw-r--r-- | services/tests/servicestests/src/com/android/server/biometrics/AuthSessionTest.java | 63 |
2 files changed, 65 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/biometrics/AuthSession.java b/services/core/java/com/android/server/biometrics/AuthSession.java index 0be893c4b932..469e8b7f26ad 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 @@ public final class AuthSession implements IBinder.DeathRecipient { && 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 @@ public final class AuthSession implements IBinder.DeathRecipient { 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 48f1286e29e3..1eaa170e169b 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 @@ public class AuthSessionTest { 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 { |