diff options
author | Lucas Dupin <dupin@google.com> | 2021-08-05 09:18:32 -0700 |
---|---|---|
committer | Lucas Dupin <dupin@google.com> | 2021-08-05 09:18:32 -0700 |
commit | 84922f4f430536323b17ac4088a5996136a64950 (patch) | |
tree | 2c0cd4e1a6dca425e4e8760be44321d9f62a9dce /graphics | |
parent | 50ff5ac8b8a53eda807bcef56bc86b8060fb99df (diff) |
Do not run background animation without a Looper
Apps that create RippleDrawable on a background thread could crash,
making them incompatible with S.
Test: manual with MindBody app
Fixes: 194952073
Change-Id: I9d16d5c63c192e96191b4fbc859ff3bc3da733cb
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/graphics/drawable/RippleDrawable.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/graphics/java/android/graphics/drawable/RippleDrawable.java b/graphics/java/android/graphics/drawable/RippleDrawable.java index d3cff5cb81ff..7354c90c5c98 100644 --- a/graphics/java/android/graphics/drawable/RippleDrawable.java +++ b/graphics/java/android/graphics/drawable/RippleDrawable.java @@ -49,7 +49,9 @@ import android.graphics.RecordingCanvas; import android.graphics.Rect; import android.graphics.Shader; import android.os.Build; +import android.os.Looper; import android.util.AttributeSet; +import android.util.Log; import android.view.animation.AnimationUtils; import android.view.animation.LinearInterpolator; @@ -113,6 +115,7 @@ import java.util.Arrays; * @attr ref android.R.styleable#RippleDrawable_color */ public class RippleDrawable extends LayerDrawable { + private static final String TAG = "RippleDrawable"; /** * Radius value that specifies the ripple radius should be computed based * on the size of the ripple's container. @@ -848,6 +851,10 @@ public class RippleDrawable extends LayerDrawable { private void startBackgroundAnimation() { mRunBackgroundAnimation = false; + if (Looper.myLooper() == null) { + Log.w(TAG, "Thread doesn't have a looper. Skipping animation."); + return; + } mBackgroundAnimation = ValueAnimator.ofFloat(mBackgroundOpacity, mTargetBackgroundOpacity); mBackgroundAnimation.setInterpolator(LINEAR_INTERPOLATOR); mBackgroundAnimation.setDuration(BACKGROUND_OPACITY_DURATION); |