Avoid race condition during grayscale animation of QS tile
DrawableIcon returns the same instance of its Drawable
for both getDrawable() and getInvisibleDrawable().
This could cause a race condition during grayscale animation
of a QS tile which uses the same icon for both ON and OFF state.
Clone the original Drawable and use it for invisible drawable
to solve this.
Fixes: 65437135
Test: manual - put a custom tile at the first position of QS panel
and tap it
Change-Id: Ie74edd9c5e58118a70b5abd8096cdd1297940ef5
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java
index 672f2c2..3495f570 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileImpl.java
@@ -439,15 +439,22 @@
public static class DrawableIcon extends Icon {
protected final Drawable mDrawable;
+ protected final Drawable mInvisibleDrawable;
public DrawableIcon(Drawable drawable) {
mDrawable = drawable;
+ mInvisibleDrawable = drawable.getConstantState().newDrawable();
}
@Override
public Drawable getDrawable(Context context) {
return mDrawable;
}
+
+ @Override
+ public Drawable getInvisibleDrawable(Context context) {
+ return mInvisibleDrawable;
+ }
}
public static class DrawableIconWithRes extends DrawableIcon {