OSDN Git Service

Fixed a bug where the scrim could flash black when snoozing huns
authorSelim Cinek <cinek@google.com>
Thu, 19 May 2016 21:38:10 +0000 (14:38 -0700)
committerSelim Cinek <cinek@google.com>
Thu, 19 May 2016 21:38:10 +0000 (14:38 -0700)
Because of an underflow the alpha could actually become 0xff instead
off 0 which would be visible as a black scrim. This was because of
our local updating of animators.

Change-Id: I4201a4bbfbc7cbf32819f4814c165d0e11adaadb
Fixes: 28840532

packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java

index eae0b8e..9c4480e 100644 (file)
@@ -322,6 +322,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
         if (scrim instanceof ScrimView) {
             float alpha2 = getDozeAlpha(scrim);
             float alpha = 1 - (1 - alpha1) * (1 - alpha2);
+            alpha = Math.max(0, Math.min(1.0f, alpha));
             ((ScrimView) scrim).setScrimColor(Color.argb((int) (alpha * 255), 0, 0, 0));
         } else {
             scrim.setAlpha(alpha1);
@@ -468,6 +469,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
                     PropertyValuesHolder[] values = previousAnimator.getValues();
                     float relativeDiff = alpha - previousEndValue;
                     float newStartValue = previousStartValue + relativeDiff;
+                    newStartValue = Math.max(0, Math.min(1.0f, newStartValue));
                     values[0].setFloatValues(newStartValue, alpha);
                     scrim.setTag(TAG_START_ALPHA, newStartValue);
                     scrim.setTag(TAG_END_ALPHA, alpha);