From ec0dad2072f540340ff55d0be296763cc9f712ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Go=CC=88llner?= Date: Wed, 15 Mar 2023 14:45:23 +0100 Subject: [PATCH] Fix QS and QS Footer sometimes having low alpha after expansion This could happen in two cases: - Fast fling to expand shade - Setting global animator duration scale to 0 There were two issues in the code: - For the footer: During very fast flings, QSFragment was receiving calls to setExpansion, and when certain parameters where the same as before, there was an early return, and the footer alpha was not being set. The code to check if the parameters were the same as before, forgot to check for the value of "panelExpansionFraction". This was different than before, and used for the footer alpha, but ignored in the check. - For the entire panel: reproducible when setting animator duration scale to 0. The issue was that QuickSettingsController didn't have the most up to date value for the shade expansion fraction. When animator duration scale was 1, this issue was almost no visible because it keep getting new values until reaching 0.999 of expansion. When setting the animator duration scale to 0, there will only be one call with the updated expansion, instead of multiple, so the out of date value will be noticeable. Fixes: 271605496 Fixes: 219589379 Test: Manually, as described above. Change-Id: I4ab954b1d5ccca609af63179e72e053f7e1f4a64 --- .../com/android/systemui/qs/QSFragment.java | 3 ++- .../NotificationPanelViewController.java | 4 ++-- .../shade/QuickSettingsController.java | 11 +++------- .../shade/QuickSettingsControllerTest.java | 21 +++++++------------ 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java index 938a9c35c2053..a8022bc4e1165 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java @@ -636,7 +636,8 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca && mLastKeyguardAndExpanded == onKeyguardAndExpanded && mLastViewHeight == currentHeight && mLastHeaderTranslation == headerTranslation - && mSquishinessFraction == squishinessFraction) { + && mSquishinessFraction == squishinessFraction + && mLastPanelFraction == panelExpansionFraction) { return; } mLastHeaderTranslation = headerTranslation; diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index ff523ad7fa0f3..6cdbec9912d83 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -3700,10 +3700,10 @@ public final class NotificationPanelViewController implements Dumpable { mHeightAnimator.end(); } } - mQsController.setShadeExpandedHeight(mExpandedHeight); - mExpansionDragDownAmountPx = h; mExpandedFraction = Math.min(1f, maxPanelHeight == 0 ? 0 : mExpandedHeight / maxPanelHeight); + mQsController.setShadeExpansion(mExpandedHeight, mExpandedFraction); + mExpansionDragDownAmountPx = h; mAmbientState.setExpansionFraction(mExpandedFraction); onHeightUpdated(mExpandedHeight); updatePanelExpansionAndVisibility(); diff --git a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsController.java b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsController.java index 50e6c719e6464..6e185fe4aabff 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsController.java @@ -339,7 +339,6 @@ public class QuickSettingsController { mFeatureFlags = featureFlags; mInteractionJankMonitor = interactionJankMonitor; - mShadeExpansionStateManager.addExpansionListener(this::onPanelExpansionChanged); mLockscreenShadeTransitionController.addCallback(new LockscreenShadeTransitionCallback()); } @@ -845,8 +844,9 @@ public class QuickSettingsController { mCollapsedOnDown = collapsedOnDown; } - void setShadeExpandedHeight(float shadeExpandedHeight) { - mShadeExpandedHeight = shadeExpandedHeight; + void setShadeExpansion(float expandedHeight, float expandedFraction) { + mShadeExpandedHeight = expandedHeight; + mShadeExpandedFraction = expandedFraction; } @VisibleForTesting @@ -1698,11 +1698,6 @@ public class QuickSettingsController { return false; } - @VisibleForTesting - void onPanelExpansionChanged(ShadeExpansionChangeEvent event) { - mShadeExpandedFraction = event.getFraction(); - } - /** * Animate QS closing by flinging it. * If QS is expanded, it will collapse into QQS and stop. diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerTest.java index 15b84238dd19e..d8ffe39e427de 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerTest.java @@ -275,9 +275,7 @@ public class QuickSettingsControllerTest extends SysuiTestCase { @Test public void testPanelStaysOpenWhenClosingQs() { - mShadeExpansionStateManager.onPanelExpansionChanged(/* fraction= */ 1, - /* expanded= */ true, /* tracking= */ false, /* dragDownPxAmount= */ 0); - mQsController.setShadeExpandedHeight(1); + mQsController.setShadeExpansion(/* shadeExpandedHeight= */ 1, /* expandedFraction=*/ 1); float shadeExpandedHeight = mQsController.getShadeExpandedHeight(); mQsController.animateCloseQs(false); @@ -289,7 +287,7 @@ public class QuickSettingsControllerTest extends SysuiTestCase { public void interceptTouchEvent_withinQs_shadeExpanded_startsQsTracking() { mQsController.setQs(mQs); - mQsController.setShadeExpandedHeight(1f); + mQsController.setShadeExpansion(/* shadeExpandedHeight= */ 1, /* expandedFraction=*/ 1); mQsController.onIntercept( createMotionEvent(0, 0, ACTION_DOWN)); mQsController.onIntercept( @@ -303,7 +301,7 @@ public class QuickSettingsControllerTest extends SysuiTestCase { enableSplitShade(true); mQsController.setQs(mQs); - mQsController.setShadeExpandedHeight(1f); + mQsController.setShadeExpansion(/* shadeExpandedHeight= */ 1, /* expandedFraction=*/ 1); mQsController.onIntercept( createMotionEvent(0, 0, ACTION_DOWN)); mQsController.onIntercept( @@ -342,13 +340,8 @@ public class QuickSettingsControllerTest extends SysuiTestCase { public void handleTouch_downActionInQsArea() { mQsController.setQs(mQs); mQsController.setBarState(SHADE); - mQsController.onPanelExpansionChanged( - new ShadeExpansionChangeEvent( - 0.5f, - true, - true, - 0 - )); + mQsController.setShadeExpansion(/* shadeExpandedHeight= */ 1, /* expandedFraction=*/ 0.5f); + MotionEvent event = createMotionEvent(QS_FRAME_WIDTH / 2, QS_FRAME_BOTTOM / 2, ACTION_DOWN); mQsController.handleTouch(event, false, false); @@ -385,7 +378,7 @@ public class QuickSettingsControllerTest extends SysuiTestCase { @Test public void handleTouch_isConflictingExpansionGestureSet() { assertThat(mQsController.isConflictingExpansionGesture()).isFalse(); - mShadeExpansionStateManager.onPanelExpansionChanged(1f, true, false, 0f); + mQsController.setShadeExpansion(/* shadeExpandedHeight= */ 1, /* expandedFraction=*/ 1); mQsController.handleTouch(MotionEvent.obtain(0L /* downTime */, 0L /* eventTime */, ACTION_DOWN, 0f /* x */, 0f /* y */, 0 /* metaState */), false, false); @@ -394,7 +387,7 @@ public class QuickSettingsControllerTest extends SysuiTestCase { @Test public void handleTouch_isConflictingExpansionGestureSet_cancel() { - mShadeExpansionStateManager.onPanelExpansionChanged(1f, true, false, 0f); + mQsController.setShadeExpansion(/* shadeExpandedHeight= */ 1, /* expandedFraction=*/ 1); mQsController.handleTouch(createMotionEvent(0, 0, ACTION_DOWN), false, false); assertThat(mQsController.isConflictingExpansionGesture()).isTrue(); mQsController.handleTouch(createMotionEvent(0, 0, ACTION_UP), true, true);