From f382a4ce223464bdd3cd7265c5c010b8b3e9ff13 Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Wed, 26 Oct 2022 16:31:30 +0100 Subject: [PATCH] Fixing QS not showing up in split shade This is fixing two issues: - QS invisible when expanding on keyguard from clicking notification - QS invisible when unfolding device, because then we're effectively keeping shade open when one screen is turning off and transitioning to keyguard The issue was caused by ag/20007064 because now we rely on qsExpanded state being explicitly set in split shade. Turns out we were only doing that in updateQsExpansionForLockscreenToShadeTransition only until current state was not SHADE_LOCKED but now this state is set before we do the animation, so it was never called. This fix is removing that condition and making it only work when we're in the transition (pxAmount > 0), otherwise state would reset as the transition is reset at the end. Fixes: 253192346 Fixes: 253978080 Test: on split keyguard, click to expand notification, see QS visible on the left Change-Id: I6e2d118eeb889d188dcd0a5dc2f21f5bedebf811 --- .../NotificationPanelViewController.java | 46 +++++++------------ .../NotificationPanelViewControllerTest.java | 4 +- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index ddb57f74cacf8..9ac3288689600 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -41,7 +41,6 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_N import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED; import static com.android.systemui.statusbar.StatusBarState.KEYGUARD; import static com.android.systemui.statusbar.StatusBarState.SHADE; -import static com.android.systemui.statusbar.StatusBarState.SHADE_LOCKED; import static com.android.systemui.statusbar.VibratorHelper.TOUCH_VIBRATION_ATTRIBUTES; import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL; import static com.android.systemui.statusbar.notification.stack.StackStateAnimator.ANIMATION_DURATION_FOLD_TO_AOD; @@ -1959,7 +1958,7 @@ public final class NotificationPanelViewController { public void closeQs() { cancelQsAnimation(); - setQsExpansion(mQsMinExpansionHeight); + setQsExpansionHeight(mQsMinExpansionHeight); } @VisibleForTesting @@ -1997,7 +1996,7 @@ public final class NotificationPanelViewController { } float height = mQsExpansionHeight; mQsExpansionAnimator.cancel(); - setQsExpansion(height); + setQsExpansionHeight(height); } flingSettings(0 /* vel */, animateAway ? FLING_HIDE : FLING_COLLAPSE); } @@ -2210,7 +2209,7 @@ public final class NotificationPanelViewController { // Already tracking because onOverscrolled was called. We need to update here // so we don't stop for a frame until the next touch event gets handled in // onTouchEvent. - setQsExpansion(h + mInitialHeightOnTouch); + setQsExpansionHeight(h + mInitialHeightOnTouch); trackMovement(event); return true; } else { @@ -2621,7 +2620,7 @@ public final class NotificationPanelViewController { case MotionEvent.ACTION_MOVE: if (DEBUG_LOGCAT) Log.d(TAG, "onQSTouch move"); mShadeLog.logMotionEvent(event, "onQsTouch: move action, setting QS expansion"); - setQsExpansion(h + mInitialHeightOnTouch); + setQsExpansionHeight(h + mInitialHeightOnTouch); if (h >= getFalsingThreshold()) { mQsTouchAboveFalsingThreshold = true; } @@ -2668,7 +2667,7 @@ public final class NotificationPanelViewController { // Reset scroll position and apply that position to the expanded height. float height = mQsExpansionHeight; - setQsExpansion(height); + setQsExpansionHeight(height); updateExpandedHeightToMaxHeight(); mNotificationStackScrollLayoutController.checkSnoozeLeavebehind(); @@ -2740,7 +2739,7 @@ public final class NotificationPanelViewController { mQs.setExpanded(mQsExpanded); } - void setQsExpansion(float height) { + void setQsExpansionHeight(float height) { height = Math.min(Math.max(height, mQsMinExpansionHeight), mQsMaxExpansionHeight); mQsFullyExpanded = height == mQsMaxExpansionHeight && mQsMaxExpansionHeight != 0; boolean qsAnimatingAway = !mQsAnimatorExpand && mAnimatingQS; @@ -3162,12 +3161,13 @@ public final class NotificationPanelViewController { delay); mIsQsTranslationResetAnimator = mQsTranslationForFullShadeTransition > 0.0f; } - - if (mSplitShadeEnabled) { - updateQsExpansionForLockscreenToShadeTransition(pxAmount); - } float endPosition = 0; if (pxAmount > 0.0f) { + if (mSplitShadeEnabled) { + float qsHeight = MathUtils.lerp(mQsMinExpansionHeight, mQsMaxExpansionHeight, + mLockscreenShadeTransitionController.getQSDragProgress()); + setQsExpansionHeight(qsHeight); + } if (mNotificationStackScrollLayoutController.getVisibleNotificationCount() == 0 && !mMediaDataManager.hasActiveMediaOrRecommendation()) { // No notifications are visible, let's animate to the height of qs instead @@ -3205,18 +3205,6 @@ public final class NotificationPanelViewController { updateQsExpansion(); } - private void updateQsExpansionForLockscreenToShadeTransition(float pxAmount) { - float qsExpansion = 0; - if (pxAmount > 0.0f) { - qsExpansion = MathUtils.lerp(mQsMinExpansionHeight, mQsMaxExpansionHeight, - mLockscreenShadeTransitionController.getQSDragProgress()); - } - // SHADE_LOCKED means transition is over and we don't want further updates - if (mBarState != SHADE_LOCKED) { - setQsExpansion(qsExpansion); - } - } - /** * Notify the panel that the pulse expansion has finished and that we're going to the full * shade @@ -3334,7 +3322,7 @@ public final class NotificationPanelViewController { animator.setDuration(350); } animator.addUpdateListener( - animation -> setQsExpansion((Float) animation.getAnimatedValue())); + animation -> setQsExpansionHeight((Float) animation.getAnimatedValue())); animator.addListener(new AnimatorListenerAdapter() { private boolean mIsCanceled; @@ -3475,7 +3463,7 @@ public final class NotificationPanelViewController { } float targetHeight = mQsMinExpansionHeight + qsExpansionFraction * (mQsMaxExpansionHeight - mQsMinExpansionHeight); - setQsExpansion(targetHeight); + setQsExpansionHeight(targetHeight); } updateExpandedHeight(expandedHeight); updateHeader(); @@ -5346,7 +5334,7 @@ public final class NotificationPanelViewController { mQsExpansionFromOverscroll = rounded != 0f; mLastOverscroll = rounded; updateQsState(); - setQsExpansion(mQsMinExpansionHeight + rounded); + setQsExpansionHeight(mQsMinExpansionHeight + rounded); } @Override @@ -5363,7 +5351,7 @@ public final class NotificationPanelViewController { // make sure we can expand setOverScrolling(false); } - setQsExpansion(mQsExpansionHeight); + setQsExpansionHeight(mQsExpansionHeight); boolean canExpand = isQsExpansionEnabled(); flingSettings(!canExpand && open ? 0f : velocity, open && canExpand ? FLING_EXPAND : FLING_COLLAPSE, () -> { @@ -5556,7 +5544,7 @@ public final class NotificationPanelViewController { } } else { // this else branch means we are doing one of: - // - from KEYGUARD and SHADE (but not expanded shade) + // - from KEYGUARD to SHADE (but not fully expanded as when swiping from the top) // - from SHADE to KEYGUARD // - from SHADE_LOCKED to SHADE // - getting notified again about the current SHADE or KEYGUARD state @@ -5725,7 +5713,7 @@ public final class NotificationPanelViewController { startQsSizeChangeAnimation(oldMaxHeight, mQsMaxExpansionHeight); } } else if (!mQsExpanded && mQsExpansionAnimator == null) { - setQsExpansion(mQsMinExpansionHeight + mLastOverscroll); + setQsExpansionHeight(mQsMinExpansionHeight + mLastOverscroll); } else { mShadeLog.v("onLayoutChange: qs expansion not set"); } 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 02f28a235b951..9713b71db5755 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -1555,7 +1555,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { /* delay= */ 0 ); - mNotificationPanelViewController.setQsExpansion(/* height= */ 123); + mNotificationPanelViewController.setQsExpansionHeight(/* height= */ 123); // First for setTransitionToFullShadeAmount and then setQsExpansion verify(mQs, times(2)).setQsExpansion( @@ -1576,7 +1576,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { when(mNotificationStackScrollLayoutController.getNotificationSquishinessFraction()) .thenReturn(nsslSquishinessFraction); - mNotificationPanelViewController.setQsExpansion(/* height= */ 123); + mNotificationPanelViewController.setQsExpansionHeight(/* height= */ 123); verify(mQs).setQsExpansion( /* expansion= */ anyFloat(),