summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Adrian Roos <roosa@google.com> 2016-12-16 12:23:51 -0800
committer Adrian Roos <roosa@google.com> 2016-12-16 12:56:07 -0800
commitcd139a6df1c098e7fc65abe6516d70519ebc568a (patch)
tree08242a3f370fb7142aeb6d6d3ad8797232f98fda
parenta91407f65bce8857953f4adfa34df33aefcf3ca8 (diff)
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
-rw-r--r--packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java3
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java10
2 files changed, 12 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java b/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java
index 13e047cceb30..6a868d53d409 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java
@@ -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;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java
index 8b99d725fd73..c3948258f11c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java
@@ -214,6 +214,16 @@ public class DozeMachineTest {
@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() {
mMachine.requestState(INITIALIZED);