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

Commit f277953d 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

Change-Id: I6f61ecea304c12ef965ad1ed2734c45dc4cee91d
parents 400e29c8 45543324
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);