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

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

Merge "Check doze transition before attempting to getState()" into main

parents 550e9ddf 6e1c0db9
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -93,7 +93,11 @@ public class DozeDockHandler implements DozeMachine.Part {
            }

            mDockState = dockState;
            if (isPulsing()) {
            if (mMachine.isExecutingTransition() || isPulsing()) {
                // If the device is in the middle of executing a transition or is pulsing,
                // exit early instead of requesting a new state. DozeMachine
                // will check the docked state and resolveIntermediateState in the next
                // transition after pulse done.
                return;
            }

+10 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ public class DozeDockHandlerTest extends SysuiTestCase {
        mDockHandler = new DozeDockHandler(mConfig, mDockManagerFake, mUserTracker);
        mDockHandler.setDozeMachine(mMachine);

        when(mMachine.isExecutingTransition()).thenReturn(false);
        when(mUserTracker.getUserId()).thenReturn(ActivityManager.getCurrentUser());
        when(mMachine.getState()).thenReturn(State.DOZE_AOD);
        doReturn(true).when(mConfig).alwaysOnEnabled(anyInt());
@@ -148,4 +149,13 @@ public class DozeDockHandlerTest extends SysuiTestCase {

        verify(mMachine, never()).requestState(any(State.class));
    }

    @Test
    public void onEvent_dockedWhileTransitioning_wontRequestStateChange() {
        when(mMachine.isExecutingTransition()).thenReturn(true);

        mDockManagerFake.setDockEvent(DockManager.STATE_DOCKED_HIDE);

        verify(mMachine, never()).requestState(any(State.class));
    }
}