From 5a58cf92b7861a30898032558d517b9dc72e1184 Mon Sep 17 00:00:00 2001 From: Kensuke Matsui Date: Wed, 5 Jul 2017 14:53:05 +0900 Subject: [PATCH] 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 --- .../src/com/android/systemui/qs/tileimpl/QSTileImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 672f2c2df06e4..3495f570cc2c4 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 abstract class QSTileImpl implements QSTile { 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 {