From 16ef7aa227e975e4afb39e98ec5f899888b2064a Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Thu, 22 Sep 2022 15:44:14 -0700 Subject: [PATCH] [Bouncer] Fix swipe to unlock being too fast. This is fixing swipe to unlock being too fast. Notif layout should move with the finger as we track to show the bouner. The exception here is when quick settings is displayed. Unfortunately, we need to hide quick settings in order to show the bouncer. Bug: 247833995 Test: Manual on device Change-Id: Id8e71ec9948dee54dfd3214f48446fc1e30bac49 --- .../stack/NotificationStackScrollLayout.java | 4 ++- .../NotificationStackScrollLayoutTest.java | 35 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) 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 5fbaa515d5d74..ef1ca1ff5cb1a 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 @@ -1318,7 +1318,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable + mAmbientState.getOverExpansion() - getCurrentOverScrollAmount(false /* top */); float fraction = mAmbientState.getExpansionFraction(); - if (mAmbientState.isBouncerInTransit()) { + // If we are on quick settings, we need to quickly hide it to show the bouncer to avoid an + // overlap. Otherwise, we maintain the normal fraction for smoothness. + if (mAmbientState.isBouncerInTransit() && mQsExpansionFraction > 0f) { fraction = BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(fraction); } final float stackY = MathUtils.lerp(0, endTopPosition, fraction); 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 6ae021b48f66c..43530365360b4 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 @@ -55,6 +55,7 @@ import android.view.ViewGroup; import androidx.test.annotation.UiThreadTest; import androidx.test.filters.SmallTest; +import com.android.keyguard.BouncerPanelExpansionCalculator; import com.android.systemui.ExpandHelper; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; @@ -178,6 +179,40 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { doNothing().when(mNotificationShelf).setAnimationsEnabled(anyBoolean()); } + @Test + public void testUpdateStackHeight_qsExpansionGreaterThanZero() { + final float expansionFraction = 0.2f; + final float overExpansion = 50f; + + mStackScroller.setQsExpansionFraction(1f); + mAmbientState.setExpansionFraction(expansionFraction); + mAmbientState.setOverExpansion(overExpansion); + when(mAmbientState.isBouncerInTransit()).thenReturn(true); + + + mStackScroller.setExpandedHeight(100f); + + float expected = MathUtils.lerp(0, overExpansion, + BouncerPanelExpansionCalculator.aboutToShowBouncerProgress(expansionFraction)); + assertThat(mAmbientState.getStackY()).isEqualTo(expected); + } + + @Test + public void testUpdateStackHeight_qsExpansionZero() { + final float expansionFraction = 0.2f; + final float overExpansion = 50f; + + mStackScroller.setQsExpansionFraction(0f); + mAmbientState.setExpansionFraction(expansionFraction); + mAmbientState.setOverExpansion(overExpansion); + when(mAmbientState.isBouncerInTransit()).thenReturn(true); + + mStackScroller.setExpandedHeight(100f); + + float expected = MathUtils.lerp(0, overExpansion, expansionFraction); + assertThat(mAmbientState.getStackY()).isEqualTo(expected); + } + @Test public void testUpdateStackHeight_withDozeAmount_whenDozeChanging() { final float dozeAmount = 0.5f;