From 18fefecab2d90127f316db2b72c6fa381564ae33 Mon Sep 17 00:00:00 2001 From: Josh Tsuji Date: Fri, 6 Aug 2021 17:06:21 -0400 Subject: [PATCH] Don't call updateIsKeyguard from the UnlockedScreenOffAnimationController if we can't control the screen off animation. This call is intended to ensure the keyguard is in the correct state if the screen off animation is interrupted. It should be very safe to not call this if the screen off animation was not able to play at all. See b/192323808 for detailed investigation. Fixes: 192323808 Test: Disable AOD (thus disabling screen off), press the power off button to begin turning off the screen, then double tap to launch camera as the screen is turning off (I can repro ~10% of the time) Change-Id: I57597308fdc3b5cb86b2c755f33f82d1476c2c09 --- .../UnlockedScreenOffAnimationController.kt | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt index a5b868b6f8a30..6b52dca42edab 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt @@ -149,14 +149,18 @@ class UnlockedScreenOffAnimationController @Inject constructor( lightRevealAnimationPlaying = false aodUiAnimationPlaying = false - // Make sure the status bar is in the correct keyguard state, forcing it if necessary. This - // is required if the screen off animation is cancelled, since it might be incorrectly left - // in the KEYGUARD or SHADE states depending on when it was cancelled and whether 'lock - // instantly' is enabled. We need to force it so that the state is set even if we're going - // from SHADE to SHADE or KEYGUARD to KEYGUARD, since we might have changed parts of the UI - // (such as showing AOD in the shade) without actually changing the StatusBarState. This - // ensures that the UI definitely reflects the desired state. - statusBar.updateIsKeyguard(true /* force */) + // If we can't control the screen off animation, we shouldn't mess with the StatusBar's + // keyguard state unnecessarily. + if (dozeParameters.get().canControlUnlockedScreenOff()) { + // Make sure the status bar is in the correct keyguard state, forcing it if necessary. + // This is required if the screen off animation is cancelled, since it might be + // incorrectly left in the KEYGUARD or SHADE states depending on when it was cancelled + // and whether 'lock instantly' is enabled. We need to force it so that the state is set + // even if we're going from SHADE to SHADE or KEYGUARD to KEYGUARD, since we might have + // changed parts of the UI (such as showing AOD in the shade) without actually changing + // the StatusBarState. This ensures that the UI definitely reflects the desired state. + statusBar.updateIsKeyguard(true /* force */) + } } override fun onStartedGoingToSleep() {