From dc732a85e1b781fafa45ca630723d6173246b280 Mon Sep 17 00:00:00 2001 From: Beverly Date: Mon, 20 Mar 2023 15:08:33 +0000 Subject: [PATCH] Don't crash on transition DOZE_SUSPEND_TRIGGERS => DOZE_PULSE_DONE This transition can happen with the following sequence of events: - Heads up notification arrives during doze_aod or doze, pulse begins (DOZE_REQUEST_PULSE, DOZE_PULSING) - While pulsing, car mode begins (DOZE_SUSPEND_TRIGGERS) - Heads up notification stops showing (DOZE_PULSE_DONE) If the device is in DOZE_SUSPEND_TRIGGERS, don't send DOZE_PULSE_DONE to DozeMachine.Parts. DOZE_SUSPEND_TRIGGERS means the device has already ended the pulsing UI. Test: atest DozeMachineTest Test: manually force car mode to start after DOZE_PULSING and see that the device won't crash on pulse-done Fixes: 262346136 Change-Id: Icc16b8a16af1fd266a2afcfdbe6e1121ef788d65 --- .../src/com/android/systemui/doze/DozeMachine.java | 3 ++- .../com/android/systemui/doze/DozeMachineTest.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java b/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java index fc3263fd3d11b..f0aefb5bc0dff 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeMachine.java @@ -398,7 +398,8 @@ public class DozeMachine { } if ((mState == State.DOZE_AOD_PAUSED || mState == State.DOZE_AOD_PAUSING || mState == State.DOZE_AOD || mState == State.DOZE - || mState == State.DOZE_AOD_DOCKED) && requestedState == State.DOZE_PULSE_DONE) { + || mState == State.DOZE_AOD_DOCKED || mState == State.DOZE_SUSPEND_TRIGGERS) + && requestedState == State.DOZE_PULSE_DONE) { Log.i(TAG, "Dropping pulse done because current state is already done: " + mState); return mState; } 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 a636b7f436486..b87647ef98392 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java @@ -407,6 +407,17 @@ public class DozeMachineTest extends SysuiTestCase { mMachine.requestState(DOZE_PULSE_DONE); } + @Test + public void testPulsing_dozeSuspendTriggers_pulseDone_doesntCrash() { + mMachine.requestState(INITIALIZED); + + mMachine.requestState(DOZE); + mMachine.requestPulse(DozeLog.PULSE_REASON_NOTIFICATION); + mMachine.requestState(DOZE_PULSING); + mMachine.requestState(DOZE_SUSPEND_TRIGGERS); + mMachine.requestState(DOZE_PULSE_DONE); + } + @Test public void testSuppressingPulse_doesntCrash() { mMachine.requestState(INITIALIZED);