diff options
| author | 2022-11-08 12:25:16 +0000 | |
|---|---|---|
| committer | 2022-11-15 12:41:29 +0000 | |
| commit | b8ec0378df1a55b06c4aaef5bccfa0ad982127f8 (patch) | |
| tree | fa7b1310dd8ddd3d1689c940e8aad19a350c01fd | |
| parent | b725e706443a35f5598a53f646113887155e1a98 (diff) | |
Fixing scrims visible in split shade on lockscreen
This issue occured when we were going to displayed lockscreen directly from expanded shade - compared to turning off the screen and then going to lockscreen after a moment.
Animation didn't have time to fully run and we ended up in not fully clean state of QS. This change forces closing QS and reseting its state when going from unlocked mode to keyguard.
To make it easier to catch similar issues in the future I also added wtf logging which is triggered when we recognize scrims and lockscreen clock visible at the same time.
Also removing mInSplitShade which was just duplicate mSplitShadeEnabled.
Test: NotificationPanelViewControllerTest
Test: display heads-up notification -> long press power button -> lockdown -> see scrims not visible on lockscreen (see b/257930534 for more reproduction steps)
Fixes: 257930534
Change-Id: I79fc78c24d4755d3fc2bbdcf5f4438993a72706b
2 files changed, 43 insertions, 7 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 32c8f3bba6c1..3e09109fae06 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -625,7 +625,6 @@ public final class NotificationPanelViewController implements Dumpable { private float mLastGesturedOverExpansion = -1; /** Whether the current animator is the spring back animation. */ private boolean mIsSpringBackAnimation; - private boolean mInSplitShade; private float mHintDistance; private float mInitialOffsetOnTouch; private boolean mCollapsedAndHeadsUpOnDown; @@ -1061,7 +1060,6 @@ public final class NotificationPanelViewController implements Dumpable { mSlopMultiplier = configuration.getScaledAmbiguousGestureMultiplier(); mHintDistance = mResources.getDimension(R.dimen.hint_move_distance); mPanelFlingOvershootAmount = mResources.getDimension(R.dimen.panel_overshoot_amount); - mInSplitShade = mResources.getBoolean(R.bool.config_use_split_notification_shade); mFlingAnimationUtils = mFlingAnimationUtilsBuilder.get() .setMaxLengthSeconds(0.4f).build(); mStatusBarMinHeight = SystemBarUtils.getStatusBarHeight(mView.getContext()); @@ -1836,6 +1834,10 @@ public final class NotificationPanelViewController implements Dumpable { public void closeQs() { cancelQsAnimation(); setQsExpansionHeight(mQsMinExpansionHeight); + // qsExpandImmediate is a safety latch in case we're calling closeQS while we're in the + // middle of animation - we need to make sure that value is always false when shade if + // fully collapsed or expanded + setQsExpandImmediate(false); } @VisibleForTesting @@ -1938,7 +1940,7 @@ public final class NotificationPanelViewController implements Dumpable { // we want to perform an overshoot animation when flinging open final boolean addOverscroll = expand - && !mInSplitShade // Split shade has its own overscroll logic + && !mSplitShadeEnabled // Split shade has its own overscroll logic && mStatusBarStateController.getState() != KEYGUARD && mOverExpansion == 0.0f && vel >= 0; @@ -2727,8 +2729,10 @@ public final class NotificationPanelViewController implements Dumpable { * as well based on the bounds of the shade and QS state. */ private void setQSClippingBounds() { - final int qsPanelBottomY = calculateQsBottomPosition(computeQsExpansionFraction()); - final boolean qsVisible = (computeQsExpansionFraction() > 0 || qsPanelBottomY > 0); + float qsExpansionFraction = computeQsExpansionFraction(); + final int qsPanelBottomY = calculateQsBottomPosition(qsExpansionFraction); + final boolean qsVisible = (qsExpansionFraction > 0 || qsPanelBottomY > 0); + checkCorrectScrimVisibility(qsExpansionFraction); int top = calculateTopQsClippingBound(qsPanelBottomY); int bottom = calculateBottomQsClippingBound(top); @@ -2739,6 +2743,19 @@ public final class NotificationPanelViewController implements Dumpable { applyQSClippingBounds(left, top, right, bottom, qsVisible); } + private void checkCorrectScrimVisibility(float expansionFraction) { + // issues with scrims visible on keyguard occur only in split shade + if (mSplitShadeEnabled) { + boolean keyguardViewsVisible = mBarState == KEYGUARD && mKeyguardOnlyContentAlpha == 1; + // expansionFraction == 1 means scrims are fully visible as their size/visibility depend + // on QS expansion + if (expansionFraction == 1 && keyguardViewsVisible) { + Log.wtf(TAG, + "Incorrect state, scrim is visible at the same time when clock is visible"); + } + } + } + private int calculateTopQsClippingBound(int qsPanelBottomY) { int top; if (mSplitShadeEnabled) { @@ -4393,7 +4410,7 @@ public final class NotificationPanelViewController implements Dumpable { ipw.print("mPanelFlingOvershootAmount="); ipw.println(mPanelFlingOvershootAmount); ipw.print("mLastGesturedOverExpansion="); ipw.println(mLastGesturedOverExpansion); ipw.print("mIsSpringBackAnimation="); ipw.println(mIsSpringBackAnimation); - ipw.print("mInSplitShade="); ipw.println(mInSplitShade); + ipw.print("mSplitShadeEnabled="); ipw.println(mSplitShadeEnabled); ipw.print("mHintDistance="); ipw.println(mHintDistance); ipw.print("mInitialOffsetOnTouch="); ipw.println(mInitialOffsetOnTouch); ipw.print("mCollapsedAndHeadsUpOnDown="); ipw.println(mCollapsedAndHeadsUpOnDown); @@ -4911,7 +4928,7 @@ public final class NotificationPanelViewController implements Dumpable { float maxPanelHeight = getMaxPanelTransitionDistance(); if (mHeightAnimator == null) { // Split shade has its own overscroll logic - if (mTracking && !mInSplitShade) { + if (mTracking && !mSplitShadeEnabled) { float overExpansionPixels = Math.max(0, h - maxPanelHeight); setOverExpansionInternal(overExpansionPixels, true /* isFromGesture */); } @@ -5459,6 +5476,12 @@ public final class NotificationPanelViewController implements Dumpable { // - from SHADE to KEYGUARD // - from SHADE_LOCKED to SHADE // - getting notified again about the current SHADE or KEYGUARD state + if (mSplitShadeEnabled && oldState == SHADE && statusBarState == KEYGUARD) { + // user can go to keyguard from different shade states and closing animation + // may not fully run - we always want to make sure we close QS when that happens + // as we never need QS open in fresh keyguard state + closeQs(); + } final boolean animatingUnlockedShadeToKeyguard = oldState == SHADE && statusBarState == KEYGUARD && mScreenOffAnimationController.isKeyguardShowDelayed(); 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 7d2251e20021..aa284e09e747 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -1119,6 +1119,19 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { } @Test + public void testUnlockedSplitShadeTransitioningToKeyguard_closesQS() { + enableSplitShade(true); + mStatusBarStateController.setState(SHADE); + mNotificationPanelViewController.setQsExpanded(true); + + mStatusBarStateController.setState(KEYGUARD); + + + assertThat(mNotificationPanelViewController.isQsExpanded()).isEqualTo(false); + assertThat(mNotificationPanelViewController.isQsExpandImmediate()).isEqualTo(false); + } + + @Test public void testSwitchesToCorrectClockInSinglePaneShade() { mStatusBarStateController.setState(KEYGUARD); |