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

Commit 7910e6a2 authored by Matt Pietal's avatar Matt Pietal
Browse files

Check device sleeping state for bouncer visibility

On reset when the device is going to sleep, the bouncer
may be asked to be visible for SIM unlocks. Do not attempt
to show the bouncer if the device is going to sleep. The dozing
signal can sometimes come too late.

Fixes: 351426938
Test: atest StatusBarKeyguardViewManagerTest
Test: manual - race condition on reboot, hit power button when on
SIM unlock
Flag: com.android.systemui.sim_pin_race_condition_on_restart

Change-Id: Id3ecac03bdaf31b8d54b63a44ef99a582a89a85b
parent 781e3ec8
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
    private boolean mBouncerShowingOverDream;
    private int mAttemptsToShowBouncer = 0;
    private DelayableExecutor mExecutor;
    private boolean mIsSleeping = false;

    private final PrimaryBouncerExpansionCallback mExpansionCallback =
            new PrimaryBouncerExpansionCallback() {
@@ -713,7 +714,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
     * {@link #needsFullscreenBouncer()}.
     */
    protected void showBouncerOrKeyguard(boolean hideBouncerWhenShowing, boolean isFalsingReset) {
        if (needsFullscreenBouncer() && !mDozing) {
        boolean showBouncer = needsFullscreenBouncer() && !mDozing;
        if (Flags.simPinRaceConditionOnRestart()) {
            showBouncer = showBouncer && !mIsSleeping;
        }
        if (showBouncer) {
            // The keyguard might be showing (already). So we need to hide it.
            if (!primaryBouncerIsShowing()) {
                if (SceneContainerFlag.isEnabled()) {
@@ -1041,6 +1046,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb

    @Override
    public void onStartedWakingUp() {
        mIsSleeping = false;
        setRootViewAnimationDisabled(false);
        NavigationBarView navBarView = mCentralSurfaces.getNavigationBarView();
        if (navBarView != null) {
@@ -1054,6 +1060,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb

    @Override
    public void onStartedGoingToSleep() {
        mIsSleeping = true;
        setRootViewAnimationDisabled(true);
        NavigationBarView navBarView = mCentralSurfaces.getNavigationBarView();
        if (navBarView != null) {
+19 −0
Original line number Diff line number Diff line
@@ -1112,9 +1112,11 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
    public void testShowBouncerOrKeyguard_showsKeyguardIfShowBouncerReturnsFalse() {
        when(mKeyguardSecurityModel.getSecurityMode(anyInt())).thenReturn(
                KeyguardSecurityModel.SecurityMode.SimPin);
        // Returning false means unable to show the bouncer
        when(mPrimaryBouncerInteractor.show(true)).thenReturn(false);
        when(mKeyguardTransitionInteractor.getTransitionState().getValue().getTo())
                .thenReturn(KeyguardState.LOCKSCREEN);
        mStatusBarKeyguardViewManager.onStartedWakingUp();

        reset(mCentralSurfaces);
        // Advance past reattempts
@@ -1125,6 +1127,23 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
        verify(mCentralSurfaces).showKeyguard();
    }

    @Test
    @DisableSceneContainer
    @EnableFlags(Flags.FLAG_SIM_PIN_RACE_CONDITION_ON_RESTART)
    public void testShowBouncerOrKeyguard_showsKeyguardIfSleeping() {
        when(mKeyguardTransitionInteractor.getTransitionState().getValue().getTo())
                .thenReturn(KeyguardState.LOCKSCREEN);
        mStatusBarKeyguardViewManager.onStartedGoingToSleep();

        reset(mCentralSurfaces);
        reset(mPrimaryBouncerInteractor);
        mStatusBarKeyguardViewManager.showBouncerOrKeyguard(
                /* hideBouncerWhenShowing= */true, false);
        verify(mCentralSurfaces).showKeyguard();
        verify(mPrimaryBouncerInteractor).hide();
    }


    @Test
    @DisableSceneContainer
    public void testShowBouncerOrKeyguard_needsFullScreen_bouncerAlreadyShowing() {