From 22fa97577f39524e3ffbfbbf37040eff540bcb49 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Thu, 26 Sep 2019 16:53:31 -0700 Subject: Only calling finishedwhen all the animations have finished Previously we would finish way too early if any of the scrims finished animation. Since some scrims almost never change, we would have animations being terminated early. Fixes: 141649119 Test: unlock with bypass, observe no lock icon change Change-Id: I6aefd6a27ef315995d8e1ae62c27a5f33cc9e160 --- .../systemui/statusbar/phone/ScrimController.java | 18 ++++++++++++++++++ .../systemui/statusbar/phone/ScrimControllerTest.java | 1 + 2 files changed, 19 insertions(+) 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 45f3b32d8155..fd3c9526149d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -754,6 +754,16 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo } private void onFinished(Callback callback) { + if (!hasReachedFinalState(mScrimBehind) + || !hasReachedFinalState(mScrimInFront) + || !hasReachedFinalState(mScrimForBubble)) { + if (callback != null && callback != mCallback) { + // Since we only notify the callback that we're finished once everything has + // finished, we need to make sure that any changing callbacks are also invoked + callback.onFinished(); + } + return; + } if (mWakeLockHeld) { mWakeLock.release(TAG); mWakeLockHeld = false; @@ -773,9 +783,17 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo mInFrontTint = Color.TRANSPARENT; mBehindTint = Color.TRANSPARENT; mBubbleTint = Color.TRANSPARENT; + updateScrimColor(mScrimInFront, mInFrontAlpha, mInFrontTint); + updateScrimColor(mScrimBehind, mBehindAlpha, mBehindTint); + updateScrimColor(mScrimForBubble, mBubbleAlpha, mBubbleTint); } } + private boolean hasReachedFinalState(ScrimView scrim) { + return scrim.getViewAlpha() == getCurrentScrimAlpha(scrim) + && scrim.getTint() == getCurrentScrimTint(scrim); + } + private boolean isAnimating(View scrim) { return scrim.getTag(TAG_KEY_ANIM) != null; } 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 e05ad09deebf..d4ad4b6d4f16 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 @@ -431,6 +431,7 @@ public class ScrimControllerTest extends SysuiTestCase { TRANSPARENT /* behind */, TRANSPARENT /* bubble */); + // Make sure at the very end of the animation, we're reset to transparent assertScrimTint(false /* front */, false /* behind */, false /* bubble */); -- cgit v1.2.3-59-g8ed1b