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

Commit b34e3b0c authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Allow forcing status bar state changes and do so during a cancelled screen off.

During screen off, we show the AOD UI without fully switching to the KEYGUARD state. When screen off is cancelled, we ask all components to reset to the SHADE state, which should also reset the UI components we changed to show AOD. However, since the StatusBarState was already SHADE, this is ignored.

This adds a force flag, which we use when cancelling screen off to make sure that all UI components are reset to the SHADE state regardless.

Test: cancel screen off, pull down the shade
Fixes: 190986023
Change-Id: I79baeb71ac5d1ed45602ac55cdca996b3bed0ac3
parent 39e9e83e
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -145,11 +145,11 @@ public class StatusBarStateControllerImpl implements SysuiStatusBarStateControll
    }
    }


    @Override
    @Override
    public boolean setState(int state) {
    public boolean setState(int state, boolean force) {
        if (state > MAX_STATE || state < MIN_STATE) {
        if (state > MAX_STATE || state < MIN_STATE) {
            throw new IllegalArgumentException("Invalid state " + state);
            throw new IllegalArgumentException("Invalid state " + state);
        }
        }
        if (state == mState) {
        if (!force && state == mState) {
            return false;
            return false;
        }
        }


+13 −1
Original line number Original line Diff line number Diff line
@@ -59,7 +59,19 @@ public interface SysuiStatusBarStateController extends StatusBarStateController
     * @param state see {@link StatusBarState} for valid options
     * @param state see {@link StatusBarState} for valid options
     * @return {@code true} if the state changed, else {@code false}
     * @return {@code true} if the state changed, else {@code false}
     */
     */
    boolean setState(int state);
    default boolean setState(int state) {
        return setState(state, false /* force */);
    }

    /**
     * Update the status bar state
     * @param state see {@link StatusBarState} for valid options
     * @param force whether to set the state even if it's the same as the current state. This will
     *              dispatch the state to all StatusBarStateListeners, ensuring that all listening
     *              components are reset to this state.
     * @return {@code true} if the state was changed or set forcefully
     */
    boolean setState(int state, boolean force);


    /**
    /**
     * Update the dozing state from {@link StatusBar}'s perspective
     * Update the dozing state from {@link StatusBar}'s perspective
+7 −3
Original line number Original line Diff line number Diff line
@@ -3408,6 +3408,10 @@ public class StatusBar extends SystemUI implements DemoMode,
    }
    }


    boolean updateIsKeyguard() {
    boolean updateIsKeyguard() {
        return updateIsKeyguard(false /* force */);
    }

    boolean updateIsKeyguard(boolean force) {
        boolean wakeAndUnlocking = mBiometricUnlockController.getMode()
        boolean wakeAndUnlocking = mBiometricUnlockController.getMode()
                == BiometricUnlockController.MODE_WAKE_AND_UNLOCK;
                == BiometricUnlockController.MODE_WAKE_AND_UNLOCK;


@@ -3431,7 +3435,7 @@ public class StatusBar extends SystemUI implements DemoMode,
                showKeyguardImpl();
                showKeyguardImpl();
            }
            }
        } else {
        } else {
            return hideKeyguardImpl();
            return hideKeyguardImpl(force);
        }
        }
        return false;
        return false;
    }
    }
@@ -3560,11 +3564,11 @@ public class StatusBar extends SystemUI implements DemoMode,
    /**
    /**
     * @return true if we would like to stay in the shade, false if it should go away entirely
     * @return true if we would like to stay in the shade, false if it should go away entirely
     */
     */
    public boolean hideKeyguardImpl() {
    public boolean hideKeyguardImpl(boolean force) {
        mIsKeyguard = false;
        mIsKeyguard = false;
        Trace.beginSection("StatusBar#hideKeyguard");
        Trace.beginSection("StatusBar#hideKeyguard");
        boolean staying = mStatusBarStateController.leaveOpenOnKeyguardHide();
        boolean staying = mStatusBarStateController.leaveOpenOnKeyguardHide();
        if (!(mStatusBarStateController.setState(StatusBarState.SHADE))) {
        if (!(mStatusBarStateController.setState(StatusBarState.SHADE, force))) {
            //TODO: StatusBarStateController should probably know about hiding the keyguard and
            //TODO: StatusBarStateController should probably know about hiding the keyguard and
            // notify listeners.
            // notify listeners.


+8 −3
Original line number Original line Diff line number Diff line
@@ -131,9 +131,14 @@ class UnlockedScreenOffAnimationController @Inject constructor(
        lightRevealAnimationPlaying = false
        lightRevealAnimationPlaying = false
        aodUiAnimationPlaying = false
        aodUiAnimationPlaying = false


        // Make sure the status bar is in the correct keyguard state, since we might have left it in
        // Make sure the status bar is in the correct keyguard state, forcing it if necessary. This
        // the KEYGUARD state if this wakeup cancelled the screen off animation.
        // is required if the screen off animation is cancelled, since it might be incorrectly left
        statusBar.updateIsKeyguard()
        // in the KEYGUARD or SHADE states depending on when it was cancelled and whether 'lock
        // instantly' is enabled. We need to force it so that the state is set even if we're going
        // from SHADE to SHADE or KEYGUARD to KEYGUARD, since we might have changed parts of the UI
        // (such as showing AOD in the shade) without actually changing the StatusBarState. This
        // ensures that the UI definitely reflects the desired state.
        statusBar.updateIsKeyguard(true /* force */)
    }
    }


    override fun onStartedGoingToSleep() {
    override fun onStartedGoingToSleep() {
+4 −2
Original line number Original line Diff line number Diff line
@@ -843,12 +843,14 @@ public class StatusBarTest extends SysuiTestCase {


        // By default, showKeyguardImpl sets state to KEYGUARD.
        // By default, showKeyguardImpl sets state to KEYGUARD.
        mStatusBar.showKeyguardImpl();
        mStatusBar.showKeyguardImpl();
        verify(mStatusBarStateController).setState(eq(StatusBarState.KEYGUARD));
        verify(mStatusBarStateController).setState(
                eq(StatusBarState.KEYGUARD), eq(false) /* force */);


        // If useFullscreenUserSwitcher is true, state is set to FULLSCREEN_USER_SWITCHER.
        // If useFullscreenUserSwitcher is true, state is set to FULLSCREEN_USER_SWITCHER.
        when(mUserSwitcherController.useFullscreenUserSwitcher()).thenReturn(true);
        when(mUserSwitcherController.useFullscreenUserSwitcher()).thenReturn(true);
        mStatusBar.showKeyguardImpl();
        mStatusBar.showKeyguardImpl();
        verify(mStatusBarStateController).setState(eq(StatusBarState.FULLSCREEN_USER_SWITCHER));
        verify(mStatusBarStateController).setState(
                eq(StatusBarState.FULLSCREEN_USER_SWITCHER), eq(false) /* force */);
    }
    }


    @Test
    @Test