diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt index 84728f699e91c..760bee21b0d1d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationWakeUpCoordinator.kt @@ -98,8 +98,6 @@ class NotificationWakeUpCoordinator @Inject constructor( } } - private var animatingScreenOff = false - private var collapsedEnoughToHide: Boolean = false var pulsing: Boolean = false @@ -236,11 +234,11 @@ class NotificationWakeUpCoordinator @Inject constructor( } override fun onDozeAmountChanged(linear: Float, eased: Float) { - if (overrideDozeAmountIfBypass()) { + if (overrideDozeAmountIfAnimatingScreenOff(linear)) { return } - if (overrideDozeAmountIfAnimatingScreenOff(linear)) { + if (overrideDozeAmountIfBypass()) { return } @@ -267,7 +265,7 @@ class NotificationWakeUpCoordinator @Inject constructor( override fun onStateChanged(newState: Int) { if (unlockedScreenOffAnimationController.shouldPlayScreenOffAnimation()) { - if (animatingScreenOff && + if (unlockedScreenOffAnimationController.isScreenOffAnimationPlaying() && state == StatusBarState.KEYGUARD && newState == StatusBarState.SHADE) { // If we're animating the screen off and going from KEYGUARD back to SHADE, the @@ -275,12 +273,16 @@ class NotificationWakeUpCoordinator @Inject constructor( // dozing) so that the notifications are no longer hidden. setDozeAmount(0f, 0f) } - - animatingScreenOff = - state == StatusBarState.SHADE && newState == StatusBarState.KEYGUARD } - overrideDozeAmountIfBypass() + if (overrideDozeAmountIfAnimatingScreenOff(mLinearDozeAmount)) { + return + } + + if (overrideDozeAmountIfBypass()) { + return + } + if (bypassController.bypassEnabled && newState == StatusBarState.KEYGUARD && state == StatusBarState.SHADE_LOCKED && (!statusBarStateController.isDozing || shouldAnimateVisibility())) { @@ -330,12 +332,7 @@ class NotificationWakeUpCoordinator @Inject constructor( * animation. If true, the original doze amount should be ignored. */ private fun overrideDozeAmountIfAnimatingScreenOff(linearDozeAmount: Float): Boolean { - if (animatingScreenOff) { - if (linearDozeAmount == 1f) { - animatingScreenOff = false - return false - } - + if (unlockedScreenOffAnimationController.isScreenOffAnimationPlaying()) { setDozeAmount(1f, 1f) return true } @@ -395,11 +392,6 @@ class NotificationWakeUpCoordinator @Inject constructor( override fun onDozingChanged(isDozing: Boolean) { if (isDozing) { setNotificationsVisible(visible = false, animate = false, increaseSpeed = false) - } else { - // We only unset the flag once we fully went asleep. If the user interrupts the - // animation in the middle, we have to abort the animation as well to make sure - // the notifications are visible again. - animatingScreenOff = false } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index 64f228f41df9d..611518c43f098 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -106,6 +106,7 @@ import com.android.systemui.statusbar.phone.HeadsUpAppearanceController; import com.android.systemui.statusbar.phone.HeadsUpTouchHelper; import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController; import com.android.systemui.statusbar.policy.HeadsUpUtil; import com.android.systemui.statusbar.policy.ScrollAdapter; import com.android.systemui.util.Assert; @@ -455,6 +456,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable private long mNumHeadsUp; private NotificationStackScrollLayoutController.TouchHandler mTouchHandler; private final FeatureFlags mFeatureFlags; + private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController; private boolean mShouldUseSplitNotificationShade; private final ExpandableView.OnHeightChangedListener mOnChildHeightChangedListener = @@ -495,11 +497,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable GroupMembershipManager groupMembershipManager, GroupExpansionManager groupExpansionManager, AmbientState ambientState, - FeatureFlags featureFlags) { + FeatureFlags featureFlags, + UnlockedScreenOffAnimationController unlockedScreenOffAnimationController) { super(context, attrs, 0, 0); Resources res = getResources(); mSectionsManager = notificationSectionsManager; mFeatureFlags = featureFlags; + mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController; mShouldUseSplitNotificationShade = shouldUseSplitNotificationShade(mFeatureFlags, res); mSectionsManager.initialize(this, LayoutInflater.from(context)); mSections = mSectionsManager.createSectionsForBuckets(); @@ -600,6 +604,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable RemoteInputController remoteInputController = mRemoteInputManager.getController(); boolean showFooterView = (showDismissView || mController.hasActiveNotifications()) && mStatusBarState != StatusBarState.KEYGUARD + && !mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying() && (remoteInputController == null || !remoteInputController.isRemoteInputActive()); boolean showHistory = Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.NOTIFICATION_HISTORY_ENABLED, 0, UserHandle.USER_CURRENT) == 1; @@ -4606,7 +4611,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable @ShadeViewRefactor(RefactorComponent.SHADE_VIEW) @VisibleForTesting - protected void setStatusBarState(int statusBarState) { + public void setStatusBarState(int statusBarState) { mStatusBarState = statusBarState; mAmbientState.setStatusBarState(statusBarState); updateSpeedBumpIndex(); 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 dc71c10ed87cf..e793fcb6d537d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -4314,7 +4314,8 @@ public class NotificationPanelViewController extends PanelViewController { /** * Reconfigures the shade to show the AOD UI (clock, smartspace, etc). This is called by the * screen off animation controller in order to animate in AOD without "actually" fully switching - * to the KEYGUARD state. + * to the KEYGUARD state, which is a heavy transition that causes jank as 10+ files react to the + * change. */ public void showAodUi() { setDozing(true /* dozing */, false /* animate */, null); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index 8758e1609fa8e..43f7284e477eb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -65,6 +65,7 @@ import com.android.systemui.statusbar.notification.row.FooterView; import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.KeyguardBypassEnabledProvider; import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController; import org.junit.Assert; import org.junit.Before; @@ -105,6 +106,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { @Mock private NotificationSwipeHelper mNotificationSwipeHelper; @Mock private NotificationStackScrollLayoutController mStackScrollLayoutController; @Mock private FeatureFlags mFeatureFlags; + @Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController; @Before @UiThreadTest @@ -143,7 +145,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { mGroupMembershipManger, mGroupExpansionManager, mAmbientState, - mFeatureFlags); + mFeatureFlags, + mUnlockedScreenOffAnimationController); mStackScrollerInternal.initView(getContext(), mKeyguardBypassEnabledProvider, mNotificationSwipeHelper); mStackScroller = spy(mStackScrollerInternal);