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

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

Merge "Don't listen for FP device entry if biometric prompt is showing" into main

parents 930a7c70 c15a3c6d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ data class KeyguardFingerprintListenModel(
    var allowOnCurrentOccludingActivity: Boolean = false,
    var alternateBouncerShowing: Boolean = false,
    var biometricEnabledForUser: Boolean = false,
    var biometricPromptShowing: Boolean = false,
    var bouncerIsOrWillShow: Boolean = false,
    var canSkipBouncer: Boolean = false,
    var credentialAttempted: Boolean = false,
@@ -61,6 +62,7 @@ data class KeyguardFingerprintListenModel(
            allowOnCurrentOccludingActivity.toString(),
            alternateBouncerShowing.toString(),
            biometricEnabledForUser.toString(),
            biometricPromptShowing.toString(),
            bouncerIsOrWillShow.toString(),
            canSkipBouncer.toString(),
            credentialAttempted.toString(),
@@ -101,6 +103,7 @@ data class KeyguardFingerprintListenModel(
                allowOnCurrentOccludingActivity = model.allowOnCurrentOccludingActivity
                alternateBouncerShowing = model.alternateBouncerShowing
                biometricEnabledForUser = model.biometricEnabledForUser
                biometricPromptShowing = model.biometricPromptShowing
                bouncerIsOrWillShow = model.bouncerIsOrWillShow
                canSkipBouncer = model.canSkipBouncer
                credentialAttempted = model.credentialAttempted
@@ -147,6 +150,7 @@ data class KeyguardFingerprintListenModel(
                "allowOnCurrentOccludingActivity",
                "alternateBouncerShowing",
                "biometricAllowedForUser",
                "biometricPromptShowing",
                "bouncerIsOrWillShow",
                "canSkipBouncer",
                "credentialAttempted",
+27 −4
Original line number Diff line number Diff line
@@ -380,6 +380,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private boolean mOccludingAppRequestingFace;
    private boolean mSecureCameraLaunched;
    private boolean mAllowedDisplayStateWhileAwakeForFaceAuth = true;
    private boolean mBiometricPromptShowing;
    @VisibleForTesting
    protected boolean mTelephonyCapable;
    private boolean mAllowFingerprintOnCurrentOccludingActivity;
@@ -2010,9 +2011,17 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            };

    private final FingerprintManager.FingerprintDetectionCallback mFingerprintDetectionCallback =
            (sensorId, userId, isStrongBiometric) -> {
                // Trigger the fingerprint detected path so the bouncer can be shown
            new FingerprintManager.FingerprintDetectionCallback() {
                @Override
                public void onDetectionError(int errorMsgId) {
                    handleFingerprintError(errorMsgId, "");
                }

                @Override
                public void onFingerprintDetected(int sensorId, int userId,
                        boolean isStrongBiometric) {
                    handleBiometricDetected(userId, FINGERPRINT, isStrongBiometric);
                }
            };

    private final FaceManager.FaceDetectionCallback mFaceDetectionCallback
@@ -2641,6 +2650,19 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                mainExecutor.execute(() -> updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE,
                        FACE_AUTH_TRIGGERED_ENROLLMENTS_CHANGED));
            }

            @Override
            public void onBiometricPromptShown() {
                // SysUI should give priority to the biometric prompt requesting FP instead of
                // taking over the fingerprint listening state.
                mBiometricPromptShowing = true;
            }

            @Override
            public void onBiometricPromptDismissed() {
                mBiometricPromptShowing = false;
                updateFingerprintListeningState(BIOMETRIC_ACTION_START);
            }
        });
        if (mConfigFaceAuthSupportedPosture != DEVICE_POSTURE_UNKNOWN) {
            mPostureController.addCallback(mPostureCallback);
@@ -3139,7 +3161,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab


        boolean shouldListen = shouldListenKeyguardState && shouldListenUserState
                && shouldListenBouncerState && shouldListenUdfpsState;
                && shouldListenBouncerState && shouldListenUdfpsState && !mBiometricPromptShowing;
        logListenerModelData(
                new KeyguardFingerprintListenModel(
                    System.currentTimeMillis(),
@@ -3148,6 +3170,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                    mAllowFingerprintOnCurrentOccludingActivity,
                    mAlternateBouncerShowing,
                    biometricEnabledForUser,
                    mBiometricPromptShowing,
                    mPrimaryBouncerIsOrWillBeShowing,
                    userCanSkipBouncer,
                    mCredentialAttempted,
+45 −0
Original line number Diff line number Diff line
@@ -869,6 +869,23 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
                anyInt(), any(), anyBoolean());
    }

    @Test
    public void whenDetectFingerprint_detectError() {
        ArgumentCaptor<FingerprintManager.FingerprintDetectionCallback> fpDetectCallbackCaptor =
                ArgumentCaptor.forClass(FingerprintManager.FingerprintDetectionCallback.class);

        givenDetectFingerprintWithClearingFingerprintManagerInvocations();
        verify(mFingerprintManager).detectFingerprint(
                any(), fpDetectCallbackCaptor.capture(), any());
        fpDetectCallbackCaptor.getValue().onDetectionError(/* msgId */ 10);

        // THEN verify keyguardUpdateMonitorCallback receives a biometric error
        verify(mTestCallback).onBiometricError(
                eq(10), eq(""), eq(BiometricSourceType.FINGERPRINT));
        verify(mTestCallback, never()).onBiometricAuthenticated(
                anyInt(), any(), anyBoolean());
    }

    @Test
    public void whenDetectFace_biometricDetectCallback() throws RemoteException {
        ArgumentCaptor<FaceManager.FaceDetectionCallback> faceDetectCallbackCaptor =
@@ -1211,6 +1228,34 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        verifyFingerprintAuthenticateCall();
    }

    @Test
    public void fpStopsListeningWhenBiometricPromptShows_resumesOnBpHidden() {
        // verify AuthController.Callback is added:
        ArgumentCaptor<AuthController.Callback> captor = ArgumentCaptor.forClass(
                AuthController.Callback.class);
        verify(mAuthController).addCallback(captor.capture());
        AuthController.Callback callback = captor.getValue();

        // GIVEN keyguard showing
        mKeyguardUpdateMonitor.dispatchStartedWakingUp(PowerManager.WAKE_REASON_POWER_BUTTON);
        mKeyguardUpdateMonitor.setKeyguardShowing(true, false);

        // THEN fingerprint should listen
        assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(false)).isTrue();

        // WHEN biometric prompt is shown
        callback.onBiometricPromptShown();

        // THEN shouldn't listen for fingerprint
        assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(false)).isFalse();

        // WHEN biometric prompt is dismissed
        callback.onBiometricPromptDismissed();

        // THEN we should listen for fingerprint
        assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(false)).isTrue();
    }

    @Test
    public void testTriesToAuthenticate_whenTrustOnAgentKeyguard_ifBypass() {
        mKeyguardUpdateMonitor.dispatchStartedWakingUp(PowerManager.WAKE_REASON_POWER_BUTTON);