summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChet Haase <chet@google.com>2015-08-05 21:44:42 -0700
committerChet Haase <chet@google.com>2015-08-06 07:55:24 -0700
commitbfa11e4ab8e4f85e711e8dd95db51dbd106a3c0f (patch)
treeae7eb40ad288290a8df29b214a95cb139908c292
parente72377e17a837acbe1e537ac737731f6b869fe1e (diff)
downloadframeworks_base-bfa11e4ab8e4f85e711e8dd95db51dbd106a3c0f.zip
frameworks_base-bfa11e4ab8e4f85e711e8dd95db51dbd106a3c0f.tar.gz
frameworks_base-bfa11e4ab8e4f85e711e8dd95db51dbd106a3c0f.tar.bz2
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
-rw-r--r--core/java/android/widget/ImageView.java4
1 files changed, 4 insertions, 0 deletions
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;
}