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

Commit a0cb8a54 authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "The fp lifecycle ends on FingerprintDetection success" into main

parents 850beea1 1380e281
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -217,7 +217,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private static final int MSG_BIOMETRIC_ENROLLMENT_STATE_CHANGED = 348;

    /** Biometric authentication state: Not listening. */
    private static final int BIOMETRIC_STATE_STOPPED = 0;
    @VisibleForTesting
    protected static final int BIOMETRIC_STATE_STOPPED = 0;

    /** Biometric authentication state: Listening. */
    private static final int BIOMETRIC_STATE_RUNNING = 1;
@@ -1803,6 +1804,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                public void onFingerprintDetected(int sensorId, int userId,
                        boolean isStrongBiometric) {
                    handleBiometricDetected(userId, FINGERPRINT, isStrongBiometric);
                    setFingerprintRunningState(BIOMETRIC_STATE_STOPPED);
                }
            };

+19 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import static android.telephony.SubscriptionManager.NAME_SOURCE_CARRIER_ID;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN;
import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_STATE_CANCELLING_RESTARTING;
import static com.android.keyguard.KeyguardUpdateMonitor.BIOMETRIC_STATE_STOPPED;
import static com.android.keyguard.KeyguardUpdateMonitor.DEFAULT_CANCEL_SIGNAL_TIMEOUT;
import static com.android.keyguard.KeyguardUpdateMonitor.HAL_POWER_PRESS_TIMEOUT;
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_OPENED;
@@ -1972,6 +1973,24 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
                .isEqualTo(BIOMETRIC_STATE_CANCELLING_RESTARTING);
    }

    @Test
    public void detectFingerprint_onSuccess_biometricStateStopped() {
        // GIVEN FP detection is running
        givenDetectFingerprintWithClearingFingerprintManagerInvocations();

        // WHEN detection is successful
        ArgumentCaptor<FingerprintManager.FingerprintDetectionCallback> fpDetectCallbackCaptor =
                ArgumentCaptor.forClass(FingerprintManager.FingerprintDetectionCallback.class);
        verify(mFingerprintManager).detectFingerprint(
                any(), fpDetectCallbackCaptor.capture(), any());
        fpDetectCallbackCaptor.getValue().onFingerprintDetected(0, 0, true);
        mTestableLooper.processAllMessages();

        // THEN fingerprint detect state should immediately update to STOPPED
        assertThat(mKeyguardUpdateMonitor.mFingerprintRunningState)
                .isEqualTo(BIOMETRIC_STATE_STOPPED);
    }

    @Test
    public void testFingerprintSensorProperties() throws RemoteException {
        mFingerprintAuthenticatorsRegisteredCallback.onAllAuthenticatorsRegistered(