From 0671bf432c31ace8f81a5a794437cd37644d7344 Mon Sep 17 00:00:00 2001 From: Josh Tsuji Date: Mon, 2 May 2022 16:09:07 -0400 Subject: [PATCH] Ensure light reveal scrim is fully revealed once we're unlocked. We've had some difficult to reproduce bugs where the lightreveal remains visible in the shade while unlocked. These are likely related to bugs in the keyguard state code, which we intend to refactor in U. In the meantime, the scrim should never be anything but fully revealed once the keyguard going away transition ends. Fixes: 229778554 Test: manually force all lightreveal animations to end at 0.5f, then unlock Test: can't add test to centralsurfacestest because start() is not called Change-Id: I6bd65738635a2f966227014a4920f8e8367b91e6 --- .../systemui/biometrics/AuthRippleController.kt | 13 ++++++++++++- .../statusbar/phone/CentralSurfacesImpl.java | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt index 76c1dbcaf20c7..d9aa1bae3c691 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt @@ -80,6 +80,7 @@ class AuthRippleController @Inject constructor( @VisibleForTesting internal var startLightRevealScrimOnKeyguardFadingAway = false + var lightRevealScrimAnimator: ValueAnimator? = null var fingerprintSensorLocation: PointF? = null private var faceSensorLocation: PointF? = null private var circleReveal: LightRevealEffect? = null @@ -163,7 +164,8 @@ class AuthRippleController @Inject constructor( if (keyguardStateController.isKeyguardFadingAway) { val lightRevealScrim = centralSurfaces.lightRevealScrim if (startLightRevealScrimOnKeyguardFadingAway && lightRevealScrim != null) { - ValueAnimator.ofFloat(.1f, 1f).apply { + lightRevealScrimAnimator?.cancel() + lightRevealScrimAnimator = ValueAnimator.ofFloat(.1f, 1f).apply { interpolator = Interpolators.LINEAR_OUT_SLOW_IN duration = RIPPLE_ANIMATION_DURATION startDelay = keyguardStateController.keyguardFadingAwayDelay @@ -183,6 +185,8 @@ class AuthRippleController @Inject constructor( if (lightRevealScrim.revealEffect == circleReveal) { lightRevealScrim.revealEffect = LiftReveal } + + lightRevealScrimAnimator = null } }) start() @@ -192,6 +196,13 @@ class AuthRippleController @Inject constructor( } } + /** + * Whether we're animating the light reveal scrim from a call to [onKeyguardFadingAwayChanged]. + */ + fun isAnimatingLightRevealScrim(): Boolean { + return lightRevealScrimAnimator?.isRunning ?: false + } + override fun onStartedGoingToSleep() { // reset the light reveal start in case we were pending an unlock startLightRevealScrimOnKeyguardFadingAway = false diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index ef24d77935622..5c12671726f43 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -1022,6 +1022,23 @@ public class CentralSurfacesImpl extends CoreStartable implements public void onUnlockedChanged() { logStateToEventlog(); } + + @Override + public void onKeyguardGoingAwayChanged() { + // The light reveal scrim should always be fully revealed by the time the keyguard + // is done going away. Double check that this is true. + if (!mKeyguardStateController.isKeyguardGoingAway()) { + if (mLightRevealScrim.getRevealAmount() != 1f) { + Log.e(TAG, "Keyguard is done going away, but someone left the light reveal " + + "scrim at reveal amount: " + mLightRevealScrim.getRevealAmount()); + } + + // If the auth ripple is still playing, let it finish. + if (!mAuthRippleController.isAnimatingLightRevealScrim()) { + mLightRevealScrim.setRevealAmount(1f); + } + } + } }); startKeyguard();