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

Commit c9307272 authored by Tim Murray's avatar Tim Murray
Browse files

RemoteViews: fix BitmapCache after immutable Bitmap switch

Test: widgets appear correctly
Bug: 237256275

Change-Id: I864ac1ba8ac771c326dc215ae4e712ceb0b6057b
parent 57f5c6bc
Loading
Loading
Loading
Loading
+8 −3
Original line number Original line Diff line number Diff line
@@ -1598,7 +1598,13 @@ public class RemoteViews implements Parcelable, Filter {


        public BitmapCache(Parcel source) {
        public BitmapCache(Parcel source) {
            mBitmaps = source.createTypedArrayList(Bitmap.CREATOR);
            mBitmaps = source.createTypedArrayList(Bitmap.CREATOR);
            mBitmapHashes = source.readSparseIntArray();
            mBitmapHashes = new SparseIntArray();
            for (int i = 0; i < mBitmaps.size(); i++) {
                Bitmap b = mBitmaps.get(i);
                if (b != null) {
                    mBitmapHashes.put(b.hashCode(), i);
                }
            }
        }
        }


        public int getBitmapId(Bitmap b) {
        public int getBitmapId(Bitmap b) {
@@ -1614,7 +1620,7 @@ public class RemoteViews implements Parcelable, Filter {
                        b = b.asShared();
                        b = b.asShared();
                    }
                    }
                    mBitmaps.add(b);
                    mBitmaps.add(b);
                    mBitmapHashes.put(mBitmaps.size() - 1, hash);
                    mBitmapHashes.put(hash, mBitmaps.size() - 1);
                    mBitmapMemory = -1;
                    mBitmapMemory = -1;
                    return (mBitmaps.size() - 1);
                    return (mBitmaps.size() - 1);
                }
                }
@@ -1631,7 +1637,6 @@ public class RemoteViews implements Parcelable, Filter {


        public void writeBitmapsToParcel(Parcel dest, int flags) {
        public void writeBitmapsToParcel(Parcel dest, int flags) {
            dest.writeTypedList(mBitmaps, flags);
            dest.writeTypedList(mBitmaps, flags);
            dest.writeSparseIntArray(mBitmapHashes);
        }
        }


        public int getBitmapMemory() {
        public int getBitmapMemory() {