summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src
diff options
context:
space:
mode:
authorLucas Dupin <dupin@google.com>2020-03-07 04:34:57 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-07 04:34:57 +0000
commite8788abc539e2936c78c112b499033d0a862a3e0 (patch)
treea9e59299320ae286819a3e2e37ec47ab472fd42c /packages/SystemUI/src
parentcf0544b0228d7c17f84963117c4b577acd81b246 (diff)
parent7a66c7b39c50376efa042ef849fcecf7e41b2a17 (diff)
downloadbase-e8788abc539e2936c78c112b499033d0a862a3e0.tar.gz
Merge "Do not accept NaN as scrim values" into qt-qpr1-dev
Diffstat (limited to 'packages/SystemUI/src')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java25
2 files changed, 29 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java b/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
index 04f1c3248a6f..1524b0799084 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ScrimView.java
@@ -16,6 +16,8 @@
package com.android.systemui.statusbar;
+import static java.lang.Float.isNaN;
+
import android.annotation.NonNull;
import android.content.Context;
import android.graphics.Canvas;
@@ -179,6 +181,9 @@ public class ScrimView extends View {
* @param alpha Gradient alpha from 0 to 1.
*/
public void setViewAlpha(float alpha) {
+ if (isNaN(alpha)) {
+ throw new IllegalArgumentException("alpha cannot be NaN");
+ }
if (alpha != mViewAlpha) {
mViewAlpha = alpha;
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 9019e9a3f44b..d9bb995c5da8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -16,6 +16,8 @@
package com.android.systemui.statusbar.phone;
+import static java.lang.Float.isNaN;
+
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
@@ -261,6 +263,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
mCurrentBehindTint = state.getBehindTint();
mCurrentInFrontAlpha = state.getFrontAlpha();
mCurrentBehindAlpha = state.getBehindAlpha();
+ if (isNaN(mCurrentBehindAlpha) || isNaN(mCurrentInFrontAlpha)) {
+ throw new IllegalStateException("Scrim opacity is NaN for state: " + state + ", front: "
+ + mCurrentInFrontAlpha + ", back: " + mCurrentBehindAlpha);
+ }
applyExpansionToAlpha();
// Scrim might acquire focus when user is navigating with a D-pad or a keyboard.
@@ -390,6 +396,9 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
* @param fraction From 0 to 1 where 0 means collapsed and 1 expanded.
*/
public void setPanelExpansion(float fraction) {
+ if (isNaN(fraction)) {
+ throw new IllegalArgumentException("Fraction should not be NaN");
+ }
if (mExpansionFraction != fraction) {
mExpansionFraction = fraction;
@@ -464,6 +473,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
mCurrentBehindTint = ColorUtils.blendARGB(ScrimState.BOUNCER.getBehindTint(),
mState.getBehindTint(), interpolatedFract);
}
+ if (isNaN(mBehindAlpha) || isNaN(mInFrontAlpha)) {
+ throw new IllegalStateException("Scrim opacity is NaN for state: " + mState
+ + ", front: " + mInFrontAlpha + ", back: " + mBehindAlpha);
+ }
}
/**
@@ -523,6 +536,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
float newBehindAlpha = mState.getBehindAlpha();
if (mCurrentBehindAlpha != newBehindAlpha) {
mCurrentBehindAlpha = newBehindAlpha;
+ if (isNaN(mCurrentBehindAlpha)) {
+ throw new IllegalStateException("Scrim opacity is NaN for state: " + mState
+ + ", back: " + mCurrentBehindAlpha);
+ }
updateScrims();
}
}
@@ -903,7 +920,9 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
pw.print(" alpha="); pw.print(mCurrentBehindAlpha);
pw.print(" tint=0x"); pw.println(Integer.toHexString(mScrimBehind.getTint()));
- pw.print(" mTracking="); pw.println(mTracking);
+ pw.print(" mTracking="); pw.println(mTracking);
+
+ pw.print(" mExpansionFraction="); pw.println(mExpansionFraction);
}
public void setWallpaperSupportsAmbientMode(boolean wallpaperSupportsAmbientMode) {
@@ -950,6 +969,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
// in this case, back-scrim needs to be re-evaluated
if (mState == ScrimState.AOD || mState == ScrimState.PULSING) {
float newBehindAlpha = mState.getBehindAlpha();
+ if (isNaN(newBehindAlpha)) {
+ throw new IllegalStateException("Scrim opacity is NaN for state: " + mState
+ + ", back: " + mCurrentBehindAlpha);
+ }
if (mCurrentBehindAlpha != newBehindAlpha) {
mCurrentBehindAlpha = newBehindAlpha;
updateScrims();