Fix the state cannot transition to DOZE while room is dark.

When AOD is on and the device goes from SCREEN_ON to SCREEN_OFF
in a dark room, the doze state is DOZE_AOD. Due to DozeDockHandler
receives STATE_DOCKED_HIDE but the state is not PLUSING, the screen
does not hide.

Bug: 127737347
Test: atest SystemUITests:DozeDockHandlerTest
Test: Manual
Change-Id: Icaebbdf843de61ef0026e8d3d5dca47bfc2f89eb
This commit is contained in:
Joanne Chung
2019-03-07 20:02:57 +08:00
parent 28541ec70a
commit 57be7e1b38
2 changed files with 21 additions and 3 deletions

View File

@@ -121,11 +121,17 @@ public class DozeDockHandler implements DozeMachine.Part {
if (dozeState == State.DOZE
&& mConfig.alwaysOnEnabled(UserHandle.USER_CURRENT)) {
mMachine.requestState(State.DOZE_AOD);
break;
}
// continue below
else {
requestPulseOutNow(dozeState);
}
break;
case DockManager.STATE_DOCKED_HIDE:
requestPulseOutNow(dozeState);
if (dozeState == State.DOZE_AOD) {
mMachine.requestState(State.DOZE);
} else {
requestPulseOutNow(dozeState);
}
break;
default:
// no-op

View File

@@ -202,4 +202,16 @@ public class DozeDockHandlerTest extends SysuiTestCase {
verify(mMachine).requestState(eq(State.DOZE));
}
@Test
public void testTransitionToPulsing_whenDockedHide_requestPulseOut() {
mDockHandler.transitionTo(DozeMachine.State.UNINITIALIZED, DozeMachine.State.INITIALIZED);
when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE_PULSING);
when(mMachine.getPulseReason()).thenReturn(DozeLog.PULSE_REASON_DOCKING);
mDockManagerFake.setDockEvent(DockManager.STATE_DOCKED_HIDE);
mDockHandler.transitionTo(DozeMachine.State.INITIALIZED, State.DOZE_PULSING);
verify(mHost).stopPulsing();
}
}