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

Commit 1380e281 authored by Beverly's avatar Beverly
Browse files

The fp lifecycle ends on FingerprintDetection success

Similar to how the lifecycle ends immediately on
fingerprintAuthentication. We do this to remain
in sync with the framework fp lifecycle.

Test: atest KeyguardUpdateMonitorTest
Fixes: 318541620
Flag: NONE
Change-Id: I6965a88019d5024fa1e08fad75530512507b4b85
parent af3dba48
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(