Doze: Fix crash when suppressing pulse

Fixes a crash due to an overzealous state validation.

Change-Id: I363c13206c890a2be56615663f89d80ac256a991
Test: runtest -x packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java
Fixes: 33463320
This commit is contained in:
Adrian Roos
2016-12-16 12:23:51 -08:00
parent a91407f65b
commit cd139a6df1
2 changed files with 12 additions and 1 deletions

View File

@@ -218,7 +218,8 @@ public class DozeMachine {
Preconditions.checkState(mState == State.DOZE_REQUEST_PULSE);
break;
case DOZE_PULSE_DONE:
Preconditions.checkState(mState == State.DOZE_PULSING);
Preconditions.checkState(
mState == State.DOZE_REQUEST_PULSE || mState == State.DOZE_PULSING);
break;
default:
break;

View File

@@ -212,6 +212,16 @@ public class DozeMachineTest {
mMachine.requestState(DOZE_PULSE_DONE);
}
@Test
@UiThreadTest
public void testSuppressingPulse_doesntCrash() {
mMachine.requestState(INITIALIZED);
mMachine.requestState(DOZE);
mMachine.requestState(DOZE_REQUEST_PULSE);
mMachine.requestState(DOZE_PULSE_DONE);
}
@Test
@UiThreadTest
public void testScreen_offInDoze() {