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

Commit e805f2b1 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Only show UDFPS bouncer if it can be used to auth

If UDFPS cannot be used to enter the device (ie: primary
auth is required to enter the device), we should directly
show the pin/pattern/password bouncer.

Test: manual, atest StatusBarKeyguardViewManagerTest
Fixes: 210142999
Change-Id: I2b09d6d675a494a4c97796f76f27bf0b8b48a07c
parent 90db2335
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -416,7 +416,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
     * dragging it and translation should be deferred {@see KeyguardBouncer#show(boolean, boolean)}
     */
    public void showGenericBouncer(boolean scrimmed) {
        if (mAlternateAuthInterceptor != null) {
        if (shouldShowAltAuth()) {
            updateAlternateAuthShowing(mAlternateAuthInterceptor.showAlternateAuthBouncer());
            return;
        }
@@ -424,6 +424,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        showBouncer(scrimmed);
    }

    private boolean shouldShowAltAuth() {
        return mAlternateAuthInterceptor != null
                && mKeyguardUpdateManager.isUnlockingWithBiometricAllowed(true);
    }

    /**
     * Hides the input bouncer (pin/password/pattern).
     */
@@ -479,7 +484,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb

            // If there is an an alternate auth interceptor (like the UDFPS), show that one instead
            // of the bouncer.
            if (mAlternateAuthInterceptor != null) {
            if (shouldShowAltAuth()) {
                if (!afterKeyguardGone) {
                    mBouncer.setDismissAction(mAfterKeyguardGoneAction, mKeyguardGoneCancelAction);
                    mAfterKeyguardGoneAction = null;
+33 −0
Original line number Diff line number Diff line
@@ -388,6 +388,39 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
        verify(mAlternateAuthInterceptor).hideAlternateAuthBouncer();
    }

    @Test
    public void testShowAltAuth_unlockingWithBiometricNotAllowed() {
        // GIVEN alt auth exists, unlocking with biometric isn't allowed
        mStatusBarKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor);
        when(mBouncer.isShowing()).thenReturn(false);
        when(mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean()))
                .thenReturn(false);

        // WHEN showGenericBouncer is called
        final boolean scrimmed = true;
        mStatusBarKeyguardViewManager.showGenericBouncer(scrimmed);

        // THEN regular bouncer is shown
        verify(mBouncer).show(anyBoolean(), eq(scrimmed));
        verify(mAlternateAuthInterceptor, never()).showAlternateAuthBouncer();
    }

    @Test
    public void testShowAltAuth_unlockingWithBiometricAllowed() {
        // GIVEN alt auth exists, unlocking with biometric is allowed
        mStatusBarKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor);
        when(mBouncer.isShowing()).thenReturn(false);
        when(mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean()))
                .thenReturn(true);

        // WHEN showGenericBouncer is called
        mStatusBarKeyguardViewManager.showGenericBouncer(true);

        // THEN alt auth bouncer is shown
        verify(mAlternateAuthInterceptor).showAlternateAuthBouncer();
        verify(mBouncer, never()).show(anyBoolean(), anyBoolean());
    }

    @Test
    public void testUpdateResources_delegatesToBouncer() {
        mStatusBarKeyguardViewManager.updateResources();