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

Commit 8d3c1aa0 authored by Stevie Kideckel's avatar Stevie Kideckel
Browse files

Copy caches when initializing RemoteViews

If the BitmapCache is not copied when cloning RemoteViews, then Bitmaps
will be dropped.

Fix: 208865678
Test: cts, verified locally

Change-Id: I7547ab3a60ac3ee16b9cfb8d592988d0e410172d
parent 56b6a193
Loading
Loading
Loading
Loading
+7 −4
Original line number Original line Diff line number Diff line
@@ -3696,18 +3696,21 @@ public class RemoteViews implements Parcelable, Filter {
    }
    }


    private void initializeFrom(@NonNull RemoteViews src, @Nullable RemoteViews hierarchyRoot) {
    private void initializeFrom(@NonNull RemoteViews src, @Nullable RemoteViews hierarchyRoot) {
        if (hierarchyRoot == null) {
            mBitmapCache = src.mBitmapCache;
            mApplicationInfoCache = src.mApplicationInfoCache;
        } else {
            mBitmapCache = hierarchyRoot.mBitmapCache;
            mApplicationInfoCache = hierarchyRoot.mApplicationInfoCache;
        }
        if (hierarchyRoot == null || src.mIsRoot) {
        if (hierarchyRoot == null || src.mIsRoot) {
            // If there's no provided root, or if src was itself a root, then this RemoteViews is
            // If there's no provided root, or if src was itself a root, then this RemoteViews is
            // the root of the new hierarchy.
            // the root of the new hierarchy.
            mIsRoot = true;
            mIsRoot = true;
            mBitmapCache = new BitmapCache();
            mApplicationInfoCache = new ApplicationInfoCache();
            hierarchyRoot = this;
            hierarchyRoot = this;
        } else {
        } else {
            // Otherwise, we're a descendant in the hierarchy.
            // Otherwise, we're a descendant in the hierarchy.
            mIsRoot = false;
            mIsRoot = false;
            mBitmapCache = hierarchyRoot.mBitmapCache;
            mApplicationInfoCache = hierarchyRoot.mApplicationInfoCache;
        }
        }
        mApplication = src.mApplication;
        mApplication = src.mApplication;
        mLayoutId = src.mLayoutId;
        mLayoutId = src.mLayoutId;