Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 57379a8a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Revert "Revert "Icon: make Icon's Bitmaps immutable""" into tm-dev am:...

Merge "Revert "Revert "Icon: make Icon's Bitmaps immutable""" into tm-dev am: edea3fd4 am: 8bf6ebe1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17943164



Change-Id: Iae20da7f457136a0393248290cf534a255455e21
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents b90187d2 8bf6ebe1
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ 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
@@ -156,6 +157,8 @@ 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
@@ -166,9 +169,21 @@ 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;
    }

    /**
     * @return The length of the compressed bitmap byte array held by this {@link #TYPE_DATA} Icon.
@@ -488,6 +503,7 @@ public final class Icon implements Parcelable {
            getBitmap().getAllocationByteCount() >= MIN_ASHMEM_ICON_SIZE) {
            setBitmap(getBitmap().asShared());
        }
        mCachedAshmem = true;
    }

    /**
@@ -913,7 +929,10 @@ public final class Icon implements Parcelable {
        switch (mType) {
            case TYPE_BITMAP:
            case TYPE_ADAPTIVE_BITMAP:
                final Bitmap bits = getBitmap();
                if (!mCachedAshmem) {
                    mObj1 = ((Bitmap) mObj1).asShared();
                    mCachedAshmem = true;
                }
                getBitmap().writeToParcel(dest, flags);
                break;
            case TYPE_RESOURCE: