From 4d133725d4b263018555cbba99bb3a2524508707 Mon Sep 17 00:00:00 2001 From: chaviw Date: Fri, 9 Feb 2018 14:36:10 -0800 Subject: [PATCH] Prevent setting negative alpha for dim animations. When apply in the dim animation is called, the currentPlayTime value can be greater than the total duration. If that's the case, the alpha value would be set to a negative value. Instead, if the currentPlayTime is greater than duration, just set the final alpha value. Change-Id: I77b7c512cc8832c2a31e20d49c14550da2cff7cd Fixes: 73152600 Test: No more flashing dim --- .../java/com/android/server/wm/SurfaceAnimationRunner.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java b/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java index 1b2f9542df11d..98fcb0be935c8 100644 --- a/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java +++ b/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java @@ -169,7 +169,12 @@ class SurfaceAnimationRunner { anim.addUpdateListener(animation -> { synchronized (mCancelLock) { if (!a.mCancelled) { - applyTransformation(a, mFrameTransaction, anim.getCurrentPlayTime()); + final long duration = anim.getDuration(); + long currentPlayTime = anim.getCurrentPlayTime(); + if (currentPlayTime > duration) { + currentPlayTime = duration; + } + applyTransformation(a, mFrameTransaction, currentPlayTime); } }