From bfa11e4ab8e4f85e711e8dd95db51dbd106a3c0f Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Wed, 5 Aug 2015 21:44:42 -0700 Subject: Avoid changing internal state of shared drawable An optimization in ImageView nulled out the internal bitmap of a cached internal BitmapDrawable object created to wrap a bitmap set on the ImageView. However, apps can get ahold of that cached object via Drawable.getBitmap(), resulting in having the state of that object they may be using changing out from under them. The change is to null out the cached object when getDrawable() is called, to avoid leaking internal state that we may change. That way, the app can continue to use that object if they want to, but we are no longer relying on it internally, and will create a new one when needed. Issue #22930646 [1P Regression from L] ImageView is blanked out in Activity in Google Express Change-Id: Ic86cb93be4897b6ba247c1fabcda507e4ba01300 --- core/java/android/widget/ImageView.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'core') diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index e13b96f..ddbaa9d 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -384,6 +384,10 @@ public class ImageView extends View { assigned. */ public Drawable getDrawable() { + if (mDrawable == mRecycleableBitmapDrawable) { + // Consider our cached version dirty since app code now has a reference to it + mRecycleableBitmapDrawable = null; + } return mDrawable; } -- cgit v1.1