Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e1fe719 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update mState if try again is successful" into 24D1-dev

parents b4e1aba3 08a02435
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;
@@ -616,7 +618,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);
        }
+63 −0
Original line number Diff line number Diff line
@@ -563,6 +563,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 {