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

Commit bfe43afd authored by Adrian Roos's avatar Adrian Roos Committed by android-build-merger
Browse files

Merge "Perf: Fix RemoteViews memory leak" into oc-dev am: 45543324

am: f277953d

Change-Id: I83dc18991a8e29ea70cb152c850f60f78b66006b
parents 5e8f9ceb f277953d
Loading
Loading
Loading
Loading
+25 −14
Original line number Diff line number Diff line
@@ -413,6 +413,30 @@ public class RemoteViews implements Parcelable, Filter {
        recalculateMemoryUsage();
    }

    private static class RemoteViewsContextWrapper extends ContextWrapper {
        private final Context mContextForResources;

        RemoteViewsContextWrapper(Context context, Context contextForResources) {
            super(context);
            mContextForResources = contextForResources;
        }

        @Override
        public Resources getResources() {
            return mContextForResources.getResources();
        }

        @Override
        public Resources.Theme getTheme() {
            return mContextForResources.getTheme();
        }

        @Override
        public String getPackageName() {
            return mContextForResources.getPackageName();
        }
    }

    private class SetEmptyView extends Action {
        int viewId;
        int emptyViewId;
@@ -3240,20 +3264,7 @@ public class RemoteViews implements Parcelable, Filter {
        // still returns the current users userId so settings like data / time formats
        // are loaded without requiring cross user persmissions.
        final Context contextForResources = getContextForResources(context);
        Context inflationContext = new ContextWrapper(context) {
            @Override
            public Resources getResources() {
                return contextForResources.getResources();
            }
            @Override
            public Resources.Theme getTheme() {
                return contextForResources.getTheme();
            }
            @Override
            public String getPackageName() {
                return contextForResources.getPackageName();
            }
        };
        Context inflationContext = new RemoteViewsContextWrapper(context, contextForResources);

        LayoutInflater inflater = (LayoutInflater)
                context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);