From 397a969ce3f7d17919d98a3538cbddc8e43a71c0 Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Thu, 19 May 2022 01:35:45 +0200 Subject: [PATCH] Properly fixing expansion state in lockscreen to shade transition This is follow up to ag/18436783 which was just a quick fix, even though it also introduced important scrim-related fix. This change updates QS expansion along lockscreen to shade transition in split shade. That uncovered some inconsistent behaviour in split shade like calculating top notifications padding or max panel height which are also fixed here. Bug: 228198572 Test: expand shade from split lockscreen and see most bottom tiles functioning properly (requires 9 tiles visible in split shade) Change-Id: Ia68d9ec80eeeff56d2db7538449d0162ce6e690f --- .../phone/KeyguardClockPositionAlgorithm.java | 9 ++++--- .../NotificationPanelViewController.java | 27 +++++++++++++------ .../KeyguardClockPositionAlgorithmTest.java | 20 +++++++++++--- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java index 629aa0317d24f..dde6b168b350f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java @@ -309,9 +309,12 @@ public class KeyguardClockPositionAlgorithm { */ private float getClockAlpha(int y) { float alphaKeyguard = Math.max(0, y / Math.max(1f, getClockY(1f, mDarkAmount))); - float qsAlphaFactor = MathUtils.saturate(mQsExpansion / 0.3f); - qsAlphaFactor = 1f - qsAlphaFactor; - alphaKeyguard *= qsAlphaFactor; + if (!mIsSplitShade) { + // in split shade QS are always expanded so this factor shouldn't apply + float qsAlphaFactor = MathUtils.saturate(mQsExpansion / 0.3f); + qsAlphaFactor = 1f - qsAlphaFactor; + alphaKeyguard *= qsAlphaFactor; + } alphaKeyguard = Interpolators.ACCELERATE.getInterpolation(alphaKeyguard); return MathUtils.lerp(alphaKeyguard, 1f, mDarkAmount); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 9afdfd6511307..4d8a7fe9f6879 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -32,6 +32,7 @@ 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.notification.stack.NotificationStackScrollLayout.ROWS_ALL; import static com.android.systemui.statusbar.notification.stack.StackStateAnimator.ANIMATION_DURATION_FOLD_TO_AOD; import static com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManagerKt.STATE_CLOSED; @@ -2672,8 +2673,8 @@ public class NotificationPanelViewController extends PanelViewController { } private float calculateNotificationsTopPadding() { - if (mSplitShadeEnabled && !mKeyguardShowing) { - return 0; + if (mSplitShadeEnabled) { + return mKeyguardShowing ? getKeyguardNotificationStaticPadding() : 0; } if (mKeyguardShowing && (mQsExpandImmediate || mIsExpanding && mQsExpandedWhenExpandingStarted)) { @@ -2747,6 +2748,9 @@ public class NotificationPanelViewController extends PanelViewController { mIsQsTranslationResetAnimator = mQsTranslationForFullShadeTransition > 0.0f; } + if (mSplitShadeEnabled) { + updateQsExpansionForLockscreenToShadeTransition(pxAmount); + } float endPosition = 0; if (pxAmount > 0.0f) { if (mNotificationStackScrollLayoutController.getVisibleNotificationCount() == 0 @@ -2786,6 +2790,18 @@ public class NotificationPanelViewController extends PanelViewController { 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 @@ -2989,7 +3005,7 @@ public class NotificationPanelViewController extends PanelViewController { } int maxHeight; if (mQsExpandImmediate || mQsExpanded || mIsExpanding && mQsExpandedWhenExpandingStarted - || mPulsing) { + || mPulsing || mSplitShadeEnabled) { maxHeight = calculatePanelHeightQsExpanded(); } else { maxHeight = calculatePanelHeightShade(); @@ -4737,11 +4753,6 @@ public class NotificationPanelViewController extends PanelViewController { duration = StackStateAnimator.ANIMATION_DURATION_STANDARD; } mKeyguardStatusBarViewController.animateKeyguardStatusBarOut(startDelay, duration); - if (mSplitShadeEnabled) { - // temporary workaround for QS height not being updated during lockscreen to - // shade transition - setQsExpanded(true); - } updateQSMinHeight(); } else if (oldState == StatusBarState.SHADE_LOCKED && statusBarState == KEYGUARD) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java index ec20271ea43b3..ed3f7100ecc52 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java @@ -266,7 +266,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { @Test public void clockPositionedDependingOnMarginInSplitShade() { setSplitShadeTopMargin(400); - mClockPositionAlgorithm.loadDimens(mResources); givenLockScreen(); mIsSplitShade = true; // WHEN the position algorithm is run @@ -294,7 +293,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { public void notifPaddingAccountsForMultiUserSwitcherInSplitShade() { setSplitShadeTopMargin(100); mUserSwitchHeight = 150; - mClockPositionAlgorithm.loadDimens(mResources); givenLockScreen(); mIsSplitShade = true; // WHEN the position algorithm is run @@ -307,7 +305,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { public void clockDoesntAccountForMultiUserSwitcherInSplitShade() { setSplitShadeTopMargin(100); mUserSwitchHeight = 150; - mClockPositionAlgorithm.loadDimens(mResources); givenLockScreen(); mIsSplitShade = true; // WHEN the position algorithm is run @@ -382,10 +379,24 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { mQsExpansion = 1; // WHEN the clock position algorithm is run positionClock(); - // THEN the clock Y position is the middle of the screen (SCREEN_HEIGHT / 2). + // THEN the clock is transparent. assertThat(mClockPosition.clockAlpha).isEqualTo(TRANSPARENT); } + @Test + public void clockNotHiddenWhenQsIsExpandedInSplitShade() { + // GIVEN on the split lock screen with QS expansion + givenLockScreen(); + mIsSplitShade = true; + setSplitShadeTopMargin(100); + mQsExpansion = 1; + + // WHEN the clock position algorithm is run + positionClock(); + + assertThat(mClockPosition.clockAlpha).isEqualTo(1); + } + @Test public void clockPositionMinimizesBurnInMovementToAvoidUdfpsOnAOD() { // GIVEN a center aligned clock @@ -524,6 +535,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private void setSplitShadeTopMargin(int value) { when(mResources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin)) .thenReturn(value); + mClockPositionAlgorithm.loadDimens(mResources); } private void givenHighestBurnInOffset() {