From 6b5a9fd911e88b5fb5538aef19cfe964402e1f1d Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Thu, 5 May 2022 17:22:30 -0500 Subject: [PATCH] Fix one-icon shelf flicker after lockscreen swipe-down-and-let-go How the flicker happens: - As we return to lockscreen after swipe down, fractionToShade decreases, so sectionGap decreases. - In NSSL#setFractionToShade, we don't immediately update stackHeight with the smaller sectionGap, so the requested children update works with the bigger stackHeight from before. - However, StackScrollAlgorithm#updateChild uses the updated (smaller) sectionGap, resulting in more room such that the last notification shows partially above the shelf. - The shelf no longer has a full view so it hides. This change adds the missing call to updateContentHeight after fractionToShade changes. Bug: 222123657 Test: NotificationStackScrollLayoutTest Test: on lockscreen, have one icon in shelf, swipe down and let go => shelf and last notification do not flicker Change-Id: I59a6564b73c1acf15a046db403a185bdaaa5fafe --- .../notification/stack/NotificationStackScrollLayout.java | 1 + .../stack/NotificationStackScrollLayoutTest.java | 8 ++++++++ 2 files changed, 9 insertions(+) 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 36cd173d2d1cd..7dd11687ee34d 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 @@ -5513,6 +5513,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable */ public void setFractionToShade(float fraction) { mAmbientState.setFractionToShade(fraction); + updateContentHeight(); // Recompute stack height with different section gap. requestChildrenUpdate(); } 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 e8608fa76c062..63e0f53e093d4 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 @@ -31,6 +31,8 @@ import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertFalse; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyFloat; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.clearInvocations; @@ -612,6 +614,12 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { assertTrue(mStackScroller.isInsideQsHeader(event2)); } + @Test + public void setFractionToShade_recomputesStackHeight() { + mStackScroller.setFractionToShade(1f); + verify(mNotificationStackSizeCalculator).computeHeight(any(), anyInt(), anyFloat()); + } + private void setBarStateForTest(int state) { // Can't inject this through the listener or we end up on the actual implementation // rather than the mock because the spy just coppied the anonymous inner /shruggie.