From d70c6c8f117b659d5dc958ebd51ac5edea80bc74 Mon Sep 17 00:00:00 2001 From: Ned Burns Date: Fri, 2 Jul 2021 04:56:00 -0400 Subject: [PATCH] Hide silent notifications when AOD animation starts When the user presses the power button on an unlocked device, we play a transition animation into AOD. This animation has two parts: a black scrim that collapses around the power button, followed by the appearance of the AOD UI. For performance reasons, we don't mark the state of the status bar as KEYGUARD until both sections of the animation finish. This causes a bug with silent notifications: if the user's only notification is one or more silent notifs and they press the power button, the AOD animation will play, but in the moment that the AOD UI needs to appear, the status bar is not yet in the KEYGUARD state. This means that the silent notifications will not yet be hidden, and so the lockscreen will use the "small" clock treatment rather than the "large" clock treatment. A few ms later, we will enter KEYGUARD state for real, the notifs will be hidden, and the small clock will revert to the large clock, causing a flicker. This change creates a new concept in StatusBarStateController: an "upcoming state". When we start the animation, we mark our upcoming state as KEYGUARD (without changing the actual state). At the same time, we modify NotificationViewHierarchyManager (the thing in charge of hiding silent notifications) to check the upcoming state rather than the actual state. To avoid the upcoming state desyncing from the actual state, setting the actual state causes the upcoming state to be cleared. Bug: 190344677 Test: manual Change-Id: I7b3613d242516440ba2e86aa1a936aef62a53d6a --- .../NotificationViewHierarchyManager.java | 3 ++- .../statusbar/StatusBarStateControllerImpl.java | 12 ++++++++++++ .../statusbar/SysuiStatusBarStateController.java | 14 ++++++++++++++ .../phone/NotificationPanelViewController.java | 2 ++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java index 467f27f640f9e..396d86bab825e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java @@ -435,7 +435,8 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle final int N = mListContainer.getContainerChildCount(); int visibleNotifications = 0; - boolean onKeyguard = mStatusBarStateController.getState() == StatusBarState.KEYGUARD; + boolean onKeyguard = + mStatusBarStateController.getCurrentOrUpcomingState() == StatusBarState.KEYGUARD; Stack stack = new Stack<>(); for (int i = N - 1; i >= 0; i--) { View child = mListContainer.getContainerChildAt(i); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java index f8a1ff879e721..0725bf961e137 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java @@ -82,6 +82,7 @@ public class StatusBarStateControllerImpl implements SysuiStatusBarStateControll private final UiEventLogger mUiEventLogger; private int mState; private int mLastState; + private int mUpcomingState; private boolean mLeaveOpenOnKeyguardHide; private boolean mKeyguardRequested; @@ -169,6 +170,7 @@ public class StatusBarStateControllerImpl implements SysuiStatusBarStateControll } mLastState = mState; mState = state; + mUpcomingState = state; mUiEventLogger.log(StatusBarStateEvent.fromState(mState)); for (RankedListener rl : new ArrayList<>(mListeners)) { rl.mListener.onStateChanged(mState); @@ -183,6 +185,16 @@ public class StatusBarStateControllerImpl implements SysuiStatusBarStateControll return true; } + @Override + public void setUpcomingState(int nextState) { + mUpcomingState = nextState; + } + + @Override + public int getCurrentOrUpcomingState() { + return mUpcomingState; + } + @Override public boolean isDozing() { return mIsDozing; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SysuiStatusBarStateController.java b/packages/SystemUI/src/com/android/systemui/statusbar/SysuiStatusBarStateController.java index 73f3d90bd4f86..25200501a9165 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SysuiStatusBarStateController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SysuiStatusBarStateController.java @@ -73,6 +73,20 @@ public interface SysuiStatusBarStateController extends StatusBarStateController */ boolean setState(int state, boolean force); + /** + * Provides a hint that the status bar has started to transition to another + * {@link StatusBarState}. This suggests that a matching call to setState() with the same value + * will happen in the near future, although that may not happen if the animation is canceled, + * etc. + */ + void setUpcomingState(int state); + + /** + * If the status bar is in the process of transitioning to a new state, returns that state. + * Otherwise, returns the current state. + */ + int getCurrentOrUpcomingState(); + /** * Update the dozing state from {@link StatusBar}'s perspective * @param isDozing well, are we dozing? diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 7fdc2e36eb24e..2692f3bc20437 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -4392,6 +4392,8 @@ public class NotificationPanelViewController extends PanelViewController { */ public void showAodUi() { setDozing(true /* dozing */, false /* animate */, null); + mStatusBarStateController.setUpcomingState(KEYGUARD); + mEntryManager.updateNotifications("showAodUi"); mStatusBarStateListener.onStateChanged(KEYGUARD); mStatusBarStateListener.onDozeAmountChanged(1f, 1f); setExpandedFraction(1f);