diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 07ae33c42c213..9a9e3bc587745 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -619,6 +619,8 @@ public class StatusBar extends CoreStartable implements protected boolean mDozing; private boolean mIsFullscreen; + boolean mCloseQsBeforeScreenOff; + private final NotificationMediaManager mMediaManager; private final NotificationLockscreenUserManager mLockscreenUserManager; private final NotificationRemoteInputManager mRemoteInputManager; @@ -1124,6 +1126,15 @@ public class StatusBar extends CoreStartable implements } if (leaveOpen) { mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); + if (mIsKeyguard) { + // When device state changes on keyguard we don't want to keep the state of + // the shade and instead we open clean state of keyguard with shade closed. + // Normally some parts of QS state (like expanded/collapsed) are persisted and + // that causes incorrect UI rendering, especially when changing state with QS + // expanded. To prevent that we can close QS which resets QS and some parts of + // the shade to its default state. Read more in b/201537421 + mCloseQsBeforeScreenOff = true; + } } } @@ -2923,10 +2934,10 @@ public class StatusBar extends CoreStartable implements } boolean updateIsKeyguard() { - return updateIsKeyguard(false /* force */); + return updateIsKeyguard(false /* forceStateChange */); } - boolean updateIsKeyguard(boolean force) { + boolean updateIsKeyguard(boolean forceStateChange) { boolean wakeAndUnlocking = mBiometricUnlockController.getMode() == BiometricUnlockController.MODE_WAKE_AND_UNLOCK; @@ -2959,7 +2970,7 @@ public class StatusBar extends CoreStartable implements // as the animation could prepare 'fake AOD' interface (without actually // transitioning to keyguard state) and this might reset the view states if (!mScreenOffAnimationController.isKeyguardHideDelayed()) { - return hideKeyguardImpl(force); + return hideKeyguardImpl(forceStateChange); } } return false; @@ -3087,12 +3098,12 @@ public class StatusBar extends CoreStartable implements /** * @return true if we would like to stay in the shade, false if it should go away entirely */ - public boolean hideKeyguardImpl(boolean force) { + public boolean hideKeyguardImpl(boolean forceStateChange) { mIsKeyguard = false; Trace.beginSection("StatusBar#hideKeyguard"); boolean staying = mStatusBarStateController.leaveOpenOnKeyguardHide(); int previousState = mStatusBarStateController.getState(); - if (!(mStatusBarStateController.setState(StatusBarState.SHADE, force))) { + if (!(mStatusBarStateController.setState(StatusBarState.SHADE, forceStateChange))) { //TODO: StatusBarStateController should probably know about hiding the keyguard and // notify listeners. @@ -3654,6 +3665,10 @@ public class StatusBar extends CoreStartable implements public void onScreenTurnedOff() { mFalsingCollector.onScreenOff(); mScrimController.onScreenTurnedOff(); + if (mCloseQsBeforeScreenOff) { + mNotificationPanelViewController.closeQs(); + mCloseQsBeforeScreenOff = false; + } updateIsKeyguard(); } }; 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 6746b3e8883a9..dab37e0da57fc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt @@ -219,7 +219,7 @@ class UnlockedScreenOffAnimationController @Inject constructor( // 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 */) + statusBar.updateIsKeyguard(true /* forceStateChange */) } }