Loading packages/SystemUI/src/com/android/systemui/doze/DozeDockHandler.java +13 −3 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ public class DozeDockHandler implements DozeMachine.Part { private int mDockState = DockManager.STATE_NONE; public DozeDockHandler(AmbientDisplayConfiguration config, DozeMachine machine, DozeDockHandler(AmbientDisplayConfiguration config, DozeMachine machine, DockManager dockManager) { mMachine = machine; mConfig = config; Loading Loading @@ -74,8 +74,13 @@ public class DozeDockHandler implements DozeMachine.Part { @Override public void onEvent(int dockState) { if (DEBUG) Log.d(TAG, "dock event = " + dockState); final DozeMachine.State nextState; mDockState = dockState; if (isPulsing()) { return; } DozeMachine.State nextState; switch (mDockState) { case DockManager.STATE_DOCKED: nextState = State.DOZE_AOD_DOCKED; Loading @@ -90,10 +95,15 @@ public class DozeDockHandler implements DozeMachine.Part { default: return; } mMachine.requestState(nextState); } private boolean isPulsing() { DozeMachine.State state = mMachine.getState(); return state == State.DOZE_REQUEST_PULSE || state == State.DOZE_PULSING || state == State.DOZE_PULSING_BRIGHT; } void register() { if (mRegistered) { return; Loading packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java +2 −2 Original line number Diff line number Diff line Loading @@ -339,8 +339,8 @@ public class DozeMachine { return State.DOZE; } if ((mState == State.DOZE_AOD_PAUSED || mState == State.DOZE_AOD_PAUSING || mState == State.DOZE_AOD || mState == State.DOZE) && requestedState == State.DOZE_PULSE_DONE) { || mState == State.DOZE_AOD || mState == State.DOZE || mState == State.DOZE_AOD_DOCKED) && requestedState == State.DOZE_PULSE_DONE) { Log.i(TAG, "Dropping pulse done because current state is already done: " + mState); return mState; } Loading packages/SystemUI/tests/src/com/android/systemui/doze/DozeDockHandlerTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -20,8 +20,10 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.hardware.display.AmbientDisplayConfiguration; import android.testing.AndroidTestingRunner; Loading Loading @@ -56,6 +58,7 @@ public class DozeDockHandlerTest extends SysuiTestCase { mDockManagerFake = spy(new DockManagerFake()); mDockHandler = new DozeDockHandler(mConfig, mMachine, mDockManagerFake); when(mMachine.getState()).thenReturn(State.DOZE_AOD); doReturn(true).when(mConfig).alwaysOnEnabled(anyInt()); mDockHandler.transitionTo(DozeMachine.State.UNINITIALIZED, DozeMachine.State.INITIALIZED); } Loading Loading @@ -101,4 +104,31 @@ public class DozeDockHandlerTest extends SysuiTestCase { verify(mMachine).requestState(eq(State.DOZE)); } @Test public void onEvent_dockedWhilePulsing_wontRequestStateChange() { when(mMachine.getState()).thenReturn(State.DOZE_PULSING); mDockManagerFake.setDockEvent(DockManager.STATE_DOCKED); verify(mMachine, never()).requestState(any(State.class)); } @Test public void onEvent_noneWhilePulsing_wontRequestStateChange() { when(mMachine.getState()).thenReturn(State.DOZE_PULSING); mDockManagerFake.setDockEvent(DockManager.STATE_NONE); verify(mMachine, never()).requestState(any(State.class)); } @Test public void onEvent_hideWhilePulsing_wontRequestStateChange() { when(mMachine.getState()).thenReturn(State.DOZE_PULSING); mDockManagerFake.setDockEvent(DockManager.STATE_DOCKED_HIDE); verify(mMachine, never()).requestState(any(State.class)); } } packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -253,6 +253,17 @@ public class DozeMachineTest extends SysuiTestCase { assertEquals(DOZE_AOD_DOCKED, mMachine.getState()); } @Test public void testPulseDone_whileDockedAoD_staysDockedAod() { when(mDockManager.isDocked()).thenReturn(true); mMachine.requestState(INITIALIZED); mMachine.requestState(DOZE_AOD_DOCKED); mMachine.requestState(DOZE_PULSE_DONE); verify(mPartMock, never()).transitionTo(DOZE_AOD_DOCKED, DOZE_PULSE_DONE); } @Test public void testPulseDone_dozeSuppressed_afterDocked_goesToDoze() { when(mHost.isDozeSuppressed()).thenReturn(true); Loading Loading
packages/SystemUI/src/com/android/systemui/doze/DozeDockHandler.java +13 −3 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ public class DozeDockHandler implements DozeMachine.Part { private int mDockState = DockManager.STATE_NONE; public DozeDockHandler(AmbientDisplayConfiguration config, DozeMachine machine, DozeDockHandler(AmbientDisplayConfiguration config, DozeMachine machine, DockManager dockManager) { mMachine = machine; mConfig = config; Loading Loading @@ -74,8 +74,13 @@ public class DozeDockHandler implements DozeMachine.Part { @Override public void onEvent(int dockState) { if (DEBUG) Log.d(TAG, "dock event = " + dockState); final DozeMachine.State nextState; mDockState = dockState; if (isPulsing()) { return; } DozeMachine.State nextState; switch (mDockState) { case DockManager.STATE_DOCKED: nextState = State.DOZE_AOD_DOCKED; Loading @@ -90,10 +95,15 @@ public class DozeDockHandler implements DozeMachine.Part { default: return; } mMachine.requestState(nextState); } private boolean isPulsing() { DozeMachine.State state = mMachine.getState(); return state == State.DOZE_REQUEST_PULSE || state == State.DOZE_PULSING || state == State.DOZE_PULSING_BRIGHT; } void register() { if (mRegistered) { return; Loading
packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java +2 −2 Original line number Diff line number Diff line Loading @@ -339,8 +339,8 @@ public class DozeMachine { return State.DOZE; } if ((mState == State.DOZE_AOD_PAUSED || mState == State.DOZE_AOD_PAUSING || mState == State.DOZE_AOD || mState == State.DOZE) && requestedState == State.DOZE_PULSE_DONE) { || mState == State.DOZE_AOD || mState == State.DOZE || mState == State.DOZE_AOD_DOCKED) && requestedState == State.DOZE_PULSE_DONE) { Log.i(TAG, "Dropping pulse done because current state is already done: " + mState); return mState; } Loading
packages/SystemUI/tests/src/com/android/systemui/doze/DozeDockHandlerTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -20,8 +20,10 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.hardware.display.AmbientDisplayConfiguration; import android.testing.AndroidTestingRunner; Loading Loading @@ -56,6 +58,7 @@ public class DozeDockHandlerTest extends SysuiTestCase { mDockManagerFake = spy(new DockManagerFake()); mDockHandler = new DozeDockHandler(mConfig, mMachine, mDockManagerFake); when(mMachine.getState()).thenReturn(State.DOZE_AOD); doReturn(true).when(mConfig).alwaysOnEnabled(anyInt()); mDockHandler.transitionTo(DozeMachine.State.UNINITIALIZED, DozeMachine.State.INITIALIZED); } Loading Loading @@ -101,4 +104,31 @@ public class DozeDockHandlerTest extends SysuiTestCase { verify(mMachine).requestState(eq(State.DOZE)); } @Test public void onEvent_dockedWhilePulsing_wontRequestStateChange() { when(mMachine.getState()).thenReturn(State.DOZE_PULSING); mDockManagerFake.setDockEvent(DockManager.STATE_DOCKED); verify(mMachine, never()).requestState(any(State.class)); } @Test public void onEvent_noneWhilePulsing_wontRequestStateChange() { when(mMachine.getState()).thenReturn(State.DOZE_PULSING); mDockManagerFake.setDockEvent(DockManager.STATE_NONE); verify(mMachine, never()).requestState(any(State.class)); } @Test public void onEvent_hideWhilePulsing_wontRequestStateChange() { when(mMachine.getState()).thenReturn(State.DOZE_PULSING); mDockManagerFake.setDockEvent(DockManager.STATE_DOCKED_HIDE); verify(mMachine, never()).requestState(any(State.class)); } }
packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -253,6 +253,17 @@ public class DozeMachineTest extends SysuiTestCase { assertEquals(DOZE_AOD_DOCKED, mMachine.getState()); } @Test public void testPulseDone_whileDockedAoD_staysDockedAod() { when(mDockManager.isDocked()).thenReturn(true); mMachine.requestState(INITIALIZED); mMachine.requestState(DOZE_AOD_DOCKED); mMachine.requestState(DOZE_PULSE_DONE); verify(mPartMock, never()).transitionTo(DOZE_AOD_DOCKED, DOZE_PULSE_DONE); } @Test public void testPulseDone_dozeSuppressed_afterDocked_goesToDoze() { when(mHost.isDozeSuppressed()).thenReturn(true); Loading