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

Commit 3f4b04b8 authored by Beverly's avatar Beverly
Browse files

Check KeyguardTransitionInteractor for the current keyguard state

Don't check KeyguardBypassController or the AlternateBouncerInteractor
for whether the alternate bouncer is visible. It's possible that we
just started transitioning away from the alternate bouncer, but those
states are already reporting isAltBouncerShowing=false. Instead, it's
more robust to check whether we're currently in the KeyguardTransition
state for the alternate bouncer which will include when we're
transitioning away from the AlternateBouncer but haven't finished into
the next state (for example, GONE).

Test: atest BiometricsUnlockControllerTest
Fixes: 332885570
Flag: None
Change-Id: Iea1496f6ba4be62eef57ba2040b7b43c7e730126
parent 6c27c89c
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -67,6 +67,8 @@ import com.android.systemui.util.time.SystemClock;

import dagger.Lazy;

import kotlinx.coroutines.ExperimentalCoroutinesApi;

import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -77,8 +79,6 @@ import java.util.Set;

import javax.inject.Inject;

import kotlinx.coroutines.ExperimentalCoroutinesApi;

/**
 * Controller which coordinates all the biometric unlocking actions with the UI.
 */
@@ -183,6 +183,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
    private final SystemClock mSystemClock;
    private final boolean mOrderUnlockAndWake;
    private final Lazy<SelectedUserInteractor> mSelectedUserInteractor;
    private final KeyguardTransitionInteractor mKeyguardTransitionInteractor;
    private long mLastFpFailureUptimeMillis;
    private int mNumConsecutiveFpFailures;

@@ -323,6 +324,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
        mOrderUnlockAndWake = resources.getBoolean(
                com.android.internal.R.bool.config_orderUnlockAndWake);
        mSelectedUserInteractor = selectedUserInteractor;
        mKeyguardTransitionInteractor = keyguardTransitionInteractor;
        javaAdapter.alwaysCollectFlow(
                keyguardTransitionInteractor.getStartedKeyguardTransitionStep(),
                this::consumeTransitionStepOnStartedKeyguardState);
@@ -665,7 +667,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp
        }
        if (isKeyguardShowing) {
            if ((mKeyguardViewController.primaryBouncerIsOrWillBeShowing()
                    || mKeyguardBypassController.getAltBouncerShowing()) && unlockingAllowed) {
                    || mKeyguardTransitionInteractor.getCurrentState()
                    == KeyguardState.ALTERNATE_BOUNCER) && unlockingAllowed) {
                return MODE_DISMISS_BOUNCER;
            } else if (unlockingAllowed && bypass) {
                return MODE_UNLOCK_COLLAPSING;
+21 −1
Original line number Diff line number Diff line
@@ -131,6 +131,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
    private SelectedUserInteractor mSelectedUserInteractor;
    @Mock
    private BiometricUnlockInteractor mBiometricUnlockInteractor;
    @Mock
    private KeyguardTransitionInteractor mKeyguardTransitionInteractor;
    private final FakeSystemClock mSystemClock = new FakeSystemClock();
    private BiometricUnlockController mBiometricUnlockController;

@@ -167,7 +169,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
                () -> mSelectedUserInteractor,
                mBiometricUnlockInteractor,
                mock(JavaAdapter.class),
                mock(KeyguardTransitionInteractor.class)
                mKeyguardTransitionInteractor
        );
        biometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager);
        biometricUnlockController.addListener(mBiometricUnlockEventsListener);
@@ -373,6 +375,24 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase {
                .isEqualTo(BiometricSourceType.FACE);
    }

    @Test
    public void onBiometricAuthenticated_whenFaceOnAlternateBouncer_dismissBouncer() {
        when(mUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true);
        when(mStatusBarKeyguardViewManager.primaryBouncerIsOrWillBeShowing()).thenReturn(false);
        when(mKeyguardTransitionInteractor.getCurrentState())
                .thenReturn(KeyguardState.ALTERNATE_BOUNCER);
        // the value of isStrongBiometric doesn't matter here since we only care about the returned
        // value of isUnlockingWithBiometricAllowed()
        mBiometricUnlockController.onBiometricAuthenticated(UserHandle.USER_CURRENT,
                BiometricSourceType.FACE, true /* isStrongBiometric */);

        verify(mStatusBarKeyguardViewManager).notifyKeyguardAuthenticated(eq(false));
        assertThat(mBiometricUnlockController.getMode())
                .isEqualTo(BiometricUnlockController.MODE_DISMISS_BOUNCER);
        assertThat(mBiometricUnlockController.getBiometricType())
                .isEqualTo(BiometricSourceType.FACE);
    }

    @Test
    public void onBiometricAuthenticated_whenBypassOnBouncer_dismissBouncer() {
        reset(mKeyguardBypassController);