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

Commit 32bc4d8a authored by Beverly's avatar Beverly
Browse files

Update fingerprint listening state after faceAuth cb is sent

Test: atest KeyguardUpdateMonitorTest
Flag: NONE
Fixes: 332885570
Change-Id: Ia467fa06c9e9dd0d06957f3e97304671dc164673
parent 5a0f5ab3
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -225,7 +225,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    protected static final int BIOMETRIC_STATE_STOPPED = 0;

    /** Biometric authentication state: Listening. */
    private static final int BIOMETRIC_STATE_RUNNING = 1;
    protected static final int BIOMETRIC_STATE_RUNNING = 1;

    /**
     * Biometric authentication: Cancelling and waiting for the relevant biometric service to
@@ -1145,7 +1145,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        if (getUserCanSkipBouncer(userId)) {
            mTrustManager.unlockedByBiometricForUser(userId, FACE);
        }
        updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
        mLogger.d("onFaceAuthenticated");
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
@@ -1156,6 +1155,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            }
        }

        // Intentionally update the fingerprint running state after sending the
        // onBiometricAuthenticated callback to listeners. Updating the fingerprint listening state
        // can update the state of the device which listeners to the callback may rely on.
        // For example, the alternate bouncer visibility state or udfps finger down state.
        updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);

        // Only authenticate face once when assistant is visible
        mAssistantVisible = false;

+27 −2
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -157,7 +158,6 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.MockitoSession;
import org.mockito.internal.util.reflection.FieldSetter;
@@ -808,6 +808,31 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        verifyFingerprintDetectCall();
    }

    @Test
    public void whenFaceAuthenticated_biometricAuthenticatedCallback_beforeUpdatingFpState() {
        // GIVEN listening for UDFPS fingerprint
        when(mAuthController.isUdfpsSupported()).thenReturn(true);
        mKeyguardUpdateMonitor.dispatchStartedWakingUp(PowerManager.WAKE_REASON_POWER_BUTTON);
        mTestableLooper.processAllMessages();
        keyguardIsVisible();
        final CancellationSignal fpCancel = spy(mKeyguardUpdateMonitor.mFingerprintCancelSignal);
        mKeyguardUpdateMonitor.mFingerprintCancelSignal = fpCancel;

        // WHEN face is authenticated
        when(mFaceAuthInteractor.isAuthenticated()).thenReturn(true);
        when(mFaceAuthInteractor.isFaceAuthStrong()).thenReturn(true);
        when(mFaceAuthInteractor.isLockedOut()).thenReturn(false);
        mKeyguardUpdateMonitor.onFaceAuthenticated(0, true);
        mTestableLooper.processAllMessages();

        // THEN verify keyguardUpdateMonitorCallback receives an onAuthenticated callback
        // before cancelling the fingerprint request
        InOrder inOrder = inOrder(mTestCallback, fpCancel);
        inOrder.verify(mTestCallback).onBiometricAuthenticated(
                eq(0), eq(BiometricSourceType.FACE), eq(true));
        inOrder.verify(fpCancel).cancel();
    }

    @Test
    public void whenDetectFingerprint_biometricDetectCallback() {
        ArgumentCaptor<FingerprintManager.FingerprintDetectionCallback> fpDetectCallbackCaptor =
@@ -2133,7 +2158,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
                null /* trustGrantedMessages */);

        // THEN onTrustChanged is called FIRST
        final InOrder inOrder = Mockito.inOrder(callback);
        final InOrder inOrder = inOrder(callback);
        inOrder.verify(callback).onTrustChanged(eq(mSelectedUserInteractor.getSelectedUserId()));

        // AND THEN onTrustGrantedForCurrentUser callback called