From 8fd35436faeee6968dbd1509c118706f34017db9 Mon Sep 17 00:00:00 2001 From: Xiaowen Lei Date: Fri, 22 Apr 2022 22:59:12 +0000 Subject: [PATCH] Revert "Icon: make Icon's Bitmaps immutable" This reverts commit 47032a209517ccdc50bbcc27b2f4e5bbaaf28552. Reason for revert: DroidMonitor: Potential culprit for Bug 230140012 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted. Change-Id: I22f5aa5bd57e37d638292773986b479428e5cdbc --- .../java/android/graphics/drawable/Icon.java | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/graphics/java/android/graphics/drawable/Icon.java b/graphics/java/android/graphics/drawable/Icon.java index a76d74edc0f4d..b04b82629b921 100644 --- a/graphics/java/android/graphics/drawable/Icon.java +++ b/graphics/java/android/graphics/drawable/Icon.java @@ -128,7 +128,6 @@ public final class Icon implements Parcelable { // TYPE_RESOURCE: Resources // TYPE_DATA: DataBytes private Object mObj1; - private boolean mCachedAshmem = false; // TYPE_RESOURCE: package name // TYPE_URI: uri string @@ -157,8 +156,6 @@ public final class Icon implements Parcelable { /** * @return The {@link android.graphics.Bitmap} held by this {@link #TYPE_BITMAP} or * {@link #TYPE_ADAPTIVE_BITMAP} Icon. - * - * Note that this will always return an immutable Bitmap. * @hide */ @UnsupportedAppUsage @@ -169,20 +166,8 @@ public final class Icon implements Parcelable { return (Bitmap) mObj1; } - /** - * Sets the Icon's contents to a particular Bitmap. Note that this may make a copy of the Bitmap - * if the supplied Bitmap is mutable. In that case, the value returned by getBitmap() may not - * equal the Bitmap passed to setBitmap(). - * - * @hide - */ private void setBitmap(Bitmap b) { - if (b.isMutable()) { - mObj1 = b.copy(b.getConfig(), false); - } else { - mObj1 = b; - } - mCachedAshmem = false; + mObj1 = b; } /** @@ -503,7 +488,6 @@ public final class Icon implements Parcelable { getBitmap().getAllocationByteCount() >= MIN_ASHMEM_ICON_SIZE) { setBitmap(getBitmap().asShared()); } - mCachedAshmem = true; } /** @@ -929,10 +913,7 @@ public final class Icon implements Parcelable { switch (mType) { case TYPE_BITMAP: case TYPE_ADAPTIVE_BITMAP: - if (!mCachedAshmem) { - mObj1 = ((Bitmap) mObj1).asShared(); - mCachedAshmem = true; - } + final Bitmap bits = getBitmap(); getBitmap().writeToParcel(dest, flags); break; case TYPE_RESOURCE: