From 64355c06ce5e8f31e73c879179959a85f593810f Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Wed, 23 Mar 2022 00:27:57 +0000 Subject: [PATCH] Bouncer: Remove overlap with shade and bouncer Scale values of fading away shade content. Also scale the notification scrim alpha as well when state is SHADE_LOCKED. There are a few ternaries to preserve the state of the notification shade when device is unlocked. (The notification shade content will not disapper as quickly if the bouncer is not about to show). There also seems to be some flickering of the notification scrim alpha when enter bouncer from the notification shade and successfully passing the security method, but this seems to be a separate issue. Bug: 226108150 Test: Manual on device Change-Id: Id717191cefe3901983ef6a46174383110d89f5ae --- .../src/com/android/systemui/qs/QSFragment.java | 5 ++++- .../statusbar/phone/PanelViewController.java | 6 +++++- .../systemui/statusbar/phone/ScrimController.java | 13 +++++-------- .../statusbar/phone/ScrimControllerTest.java | 11 ++++++----- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java index e751d549788ce..8d0494afbb897 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSFragment.java @@ -37,6 +37,7 @@ import android.view.ViewTreeObserver; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; +import com.android.keyguard.BouncerPanelExpansionCalculator; import com.android.systemui.R; import com.android.systemui.animation.Interpolators; import com.android.systemui.animation.ShadeInterpolation; @@ -593,7 +594,9 @@ public class QSFragment extends LifecycleFragment implements QS, CommandQueue.Ca } else if (progress > 0 && view.getVisibility() != View.VISIBLE) { view.setVisibility((View.VISIBLE)); } - float alpha = ShadeInterpolation.getContentAlpha(progress); + float alpha = (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) + ? BouncerPanelExpansionCalculator.getBackScrimScaledExpansion(progress) + : ShadeInterpolation.getContentAlpha(progress); view.setAlpha(alpha); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java index 9398fcd3fabc9..be50a17b85363 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java @@ -48,6 +48,7 @@ import android.view.animation.Interpolator; import com.android.internal.jank.InteractionJankMonitor; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.util.LatencyTracker; +import com.android.keyguard.BouncerPanelExpansionCalculator; import com.android.systemui.DejankUtils; import com.android.systemui.R; import com.android.systemui.animation.Interpolators; @@ -796,7 +797,10 @@ public abstract class PanelViewController { } mExpandedFraction = Math.min(1f, maxPanelHeight == 0 ? 0 : mExpandedHeight / maxPanelHeight); - mAmbientState.setExpansionFraction(mExpandedFraction); + mAmbientState.setExpansionFraction(mKeyguardStateController.isUnlocked() + ? mExpandedFraction + : BouncerPanelExpansionCalculator + .getBackScrimScaledExpansion(mExpandedFraction)); onHeightUpdated(mExpandedHeight); updatePanelExpansionAndVisibility(); }); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java index 7e22510c99afe..63eb355bfd0c4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -836,14 +836,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump private Pair calculateBackStateForState(ScrimState state) { // Either darken of make the scrim transparent when you // pull down the shade - float interpolatedFract; - - if (state == ScrimState.KEYGUARD) { - interpolatedFract = BouncerPanelExpansionCalculator - .getBackScrimScaledExpansion(mPanelExpansionFraction); - } else { - interpolatedFract = getInterpolatedFraction(); - } + float interpolatedFract = getInterpolatedFraction(); float stateBehind = mClipsQsScrim ? state.getNotifAlpha() : state.getBehindAlpha(); float behindAlpha; @@ -1025,6 +1018,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump } private float getInterpolatedFraction() { + if (mState == ScrimState.KEYGUARD || mState == ScrimState.SHADE_LOCKED) { + return BouncerPanelExpansionCalculator + .getBackScrimScaledExpansion(mPanelExpansionFraction); + } return ShadeInterpolation.getNotificationScrimAlpha(mPanelExpansionFraction); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java index 134ad4b9d0fbf..de3627b7cb796 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java @@ -1228,8 +1228,8 @@ public class ScrimControllerTest extends SysuiTestCase { public void testNotificationTransparency_followsPanelExpansionInShadeLockedState() { mScrimController.transitionTo(ScrimState.SHADE_LOCKED); - assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.8f, /* expansion */ 0.8f); - assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.47f, /* expansion */ 0.2f); + assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0f, /* expansion */ 0.8f); + assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0f, /* expansion */ 0.2f); } @Test @@ -1242,15 +1242,16 @@ public class ScrimControllerTest extends SysuiTestCase { // Verify normal behavior after mScrimController.setUnocclusionAnimationRunning(false); - assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.2f, /* expansion */ 0.4f); + assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 1f, /* expansion */ 0.4f); } @Test public void testNotificationTransparency_inKeyguardState() { mScrimController.transitionTo(ScrimState.KEYGUARD); - assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.2f, /* expansion */ 0.4f); - assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.52f, /* expansion */ 0.2f); + assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 1f, /* expansion */ 0.8f); + assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 1f, /* expansion */ 0.4f); + assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 1f, /* expansion */ 0.2f); } @Test