diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/doze/DozeDockHandler.java | 6 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/doze/DozeDockHandlerTest.java | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeDockHandler.java b/packages/SystemUI/src/com/android/systemui/doze/DozeDockHandler.java index c331164f001b..537cacd13a96 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeDockHandler.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeDockHandler.java @@ -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; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeDockHandlerTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeDockHandlerTest.java index af027e871542..6d2df19b997d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeDockHandlerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeDockHandlerTest.java @@ -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)); + } } |