From 536d557a40eda31beb6c67bc4fe160dcf1f96de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Go=CC=88llner?= Date: Thu, 9 Mar 2023 09:13:45 +0100 Subject: [PATCH] Reset shade over scroll state when split shade enabled changes It seems that in some corner cases, there might be left over overscroll state from when split shade is enabled. Bug: 268531152 Test: NotificationPanelViewControllerTest.java Change-Id: Id6058be76f5d50ba15bce5d8dbe768963c911a41 --- .../NotificationPanelViewController.java | 6 ++++ .../NotificationPanelViewControllerTest.java | 33 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index c44f4f3918317..1053505a82adc 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -1203,6 +1203,12 @@ public final class NotificationPanelViewController implements Dumpable { private void onSplitShadeEnabledChanged() { mShadeLog.logSplitShadeChanged(mSplitShadeEnabled); + // Reset any left over overscroll state. It is a rare corner case but can happen. + mQsController.setOverScrollAmount(0); + mScrimController.setNotificationsOverScrollAmount(0); + mNotificationStackScrollLayoutController.setOverExpansion(0); + mNotificationStackScrollLayoutController.setOverScrollAmount(0); + // when we switch between split shade and regular shade we want to enforce setting qs to // the default state: expanded for split shade and collapsed otherwise if (!isOnKeyguard() && mPanelExpanded) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java index abcde3dca4e93..4517596e8b024 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -37,6 +37,7 @@ import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.inOrder; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; +import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -921,6 +922,38 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo } + @Test + public void onSplitShadeChanged_duringShadeExpansion_resetsOverScrollState() { + // There was a bug where there was left-over overscroll state after going from split shade + // to single shade. + // Since on single shade we don't set overscroll values on QS nor Scrim, those values that + // were there from split shade were never reset. + // To prevent this, we will reset all overscroll state. + enableSplitShade(true); + reset(mQsController, mScrimController, mNotificationStackScrollLayoutController); + + mNotificationPanelViewController.setOverExpansion(123); + verify(mQsController).setOverScrollAmount(123); + verify(mScrimController).setNotificationsOverScrollAmount(123); + verify(mNotificationStackScrollLayoutController).setOverExpansion(123); + + enableSplitShade(false); + verify(mQsController).setOverScrollAmount(0); + verify(mScrimController).setNotificationsOverScrollAmount(0); + verify(mNotificationStackScrollLayoutController).setOverExpansion(0); + } + + @Test + public void onSplitShadeChanged_alwaysResetsOverScrollState() { + enableSplitShade(true); + enableSplitShade(false); + + verify(mQsController, times(2)).setOverScrollAmount(0); + verify(mScrimController, times(2)).setNotificationsOverScrollAmount(0); + verify(mNotificationStackScrollLayoutController, times(2)).setOverExpansion(0); + verify(mNotificationStackScrollLayoutController, times(2)).setOverScrollAmount(0); + } + /** * When shade is flinging to close and this fling is not intercepted, * {@link AmbientState#setIsClosing(boolean)} should be called before