From 2cd3b901f9f21168881eaad777d375a504045289 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 13 Jul 2020 21:32:08 -0700 Subject: [PATCH] Ensure that animated key button drawable has callbacks - The animated drawable never has callbacks set, so if nothing else invalidates while the AVD is drawing, we may not end up invalidating. Haven't actually been able to repro the original issue but, this is a potential cause. Bug: 158680912 Test: Haven't been able to repro the original issue, but we ensure that the rotation button still works ehange-Id: Iba00785cf85df2e85a19e1b44a17953877514b68 Change-Id: I4dc673824e1cf068ee0eb9953c7e3264c22fa7f5 --- .../statusbar/policy/KeyButtonDrawable.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java index 8fcaa67e76149..23d03a4b225a0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonDrawable.java @@ -80,6 +80,22 @@ public class KeyButtonDrawable extends Drawable { private final Paint mShadowPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); private final ShadowDrawableState mState; private AnimatedVectorDrawable mAnimatedDrawable; + private final Callback mAnimatedDrawableCallback = new Callback() { + @Override + public void invalidateDrawable(@NonNull Drawable who) { + invalidateSelf(); + } + + @Override + public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when) { + scheduleSelf(what, when); + } + + @Override + public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) { + unscheduleSelf(what); + } + }; public KeyButtonDrawable(Drawable d, @ColorInt int lightColor, @ColorInt int darkColor, boolean horizontalFlip, Color ovalBackgroundColor) { @@ -97,6 +113,7 @@ public class KeyButtonDrawable extends Drawable { } if (canAnimate()) { mAnimatedDrawable = (AnimatedVectorDrawable) mState.mChildState.newDrawable().mutate(); + mAnimatedDrawable.setCallback(mAnimatedDrawableCallback); setDrawableBounds(mAnimatedDrawable); } }