From cd142a488e8142ae79adc445b64deb972250abcb Mon Sep 17 00:00:00 2001 From: Nicolo' Mazzucato Date: Mon, 11 Apr 2022 11:10:23 +0200 Subject: [PATCH] Fix notifications count change during animation on keyguard max keyguard displayed notifications was being updated while an animation was in progress, getting a wrong top padding (as all the views were translated upwards during the hint animation). The update is skipped in this case. Fixes: 220800339 Fixes: 228170071 Test: add notifications, trigger hint and aod animation => notification count is not updated in the middle Change-Id: I2cc851437104cac4b228dd6d1b4bb7c3b97e59ef --- .../phone/NotificationPanelViewController.java | 11 +++++++++-- .../phone/NotificationPanelViewControllerTest.java | 5 ++++- 2 files changed, 13 insertions(+), 3 deletions(-) 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 8deaa3444bb06..2d0b0aa94131f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -338,6 +338,7 @@ public class NotificationPanelViewController extends PanelViewController { private boolean mAnimateNextPositionUpdate; private float mQuickQsHeaderHeight; private ScreenOffAnimationController mScreenOffAnimationController; + private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController; private int mTrackingPointer; private VelocityTracker mQsVelocityTracker; @@ -745,7 +746,8 @@ public class NotificationPanelViewController extends PanelViewController { KeyguardUnlockAnimationController keyguardUnlockAnimationController, NotificationListContainer notificationListContainer, PanelEventsEmitter panelEventsEmitter, - NotificationStackSizeCalculator notificationStackSizeCalculator) { + NotificationStackSizeCalculator notificationStackSizeCalculator, + UnlockedScreenOffAnimationController unlockedScreenOffAnimationController) { super(view, falsingManager, dozeLog, @@ -846,6 +848,7 @@ public class NotificationPanelViewController extends PanelViewController { mAuthController = authController; mLockIconViewController = lockIconViewController; mScreenOffAnimationController = screenOffAnimationController; + mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController; mRemoteInputManager = remoteInputManager; int currentMode = navigationModeController.addListener( @@ -1251,6 +1254,10 @@ public class NotificationPanelViewController extends PanelViewController { } } + private boolean shouldAvoidChangingNotificationsCount() { + return mHintAnimationRunning || mUnlockedScreenOffAnimationController.isAnimationPlaying(); + } + public void setKeyguardIndicationController(KeyguardIndicationController indicationController) { mKeyguardIndicationController = indicationController; mKeyguardIndicationController.setIndicationArea(mKeyguardBottomArea); @@ -4733,7 +4740,7 @@ public class NotificationPanelViewController extends PanelViewController { int oldTop, int oldRight, int oldBottom) { DejankUtils.startDetectingBlockingIpcs("NVP#onLayout"); super.onLayoutChange(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom); - updateMaxDisplayedNotifications(true); + updateMaxDisplayedNotifications(!shouldAvoidChangingNotificationsCount()); setIsFullWidth(mNotificationStackScrollLayoutController.getWidth() == mView.getWidth()); // Update Clock Pivot diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java index 8f3df09d913dc..09773d31de411 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewControllerTest.java @@ -331,6 +331,8 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { private NotificationListContainer mNotificationListContainer; @Mock private NotificationStackSizeCalculator mNotificationStackSizeCalculator; + @Mock + private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController; private NotificationPanelViewController.PanelEventsEmitter mPanelEventsEmitter; private Optional mSysUIUnfoldComponent = Optional.empty(); private SysuiStatusBarStateController mStatusBarStateController; @@ -511,7 +513,8 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { mKeyguardUnlockAnimationController, mNotificationListContainer, mPanelEventsEmitter, - mNotificationStackSizeCalculator); + mNotificationStackSizeCalculator, + mUnlockedScreenOffAnimationController); mNotificationPanelViewController.initDependencies( mCentralSurfaces, () -> {},