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

Commit 7a05fd78 authored by Willie Koomson's avatar Willie Koomson
Browse files

Write UID in RemoteViews proto

Adds UID to the RemoteViews proto, and uses
PackageManager.getApplicationInfoAsUser instead. This ensures the
RemoteViews is deserialized to the same user's ApplicationInfo as
it was serialized to.

Bug: 364420494
Test: RemoteViewsSerializersTest
Flag: android.appwidget.flags.remote_views_proto
Change-Id: Id44175b526532d5feb4ce54a18eb82776b5fe8db
parent 380d8d52
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -10077,6 +10077,7 @@ public class RemoteViews implements Parcelable, Filter {
        if (mApplication != null) {
            // mApplication may be null if this was created with DrawInstructions constructor.
            out.write(RemoteViewsProto.PACKAGE_NAME, mApplication.packageName);
            out.write(RemoteViewsProto.UID, mApplication.uid);
        }
        Resources appResources = getContextForResourcesEnsuringCorrectCachedApkPaths(
                context).getResources();
@@ -10158,6 +10159,7 @@ public class RemoteViews implements Parcelable, Filter {
            int mApplyFlags = 0;
            long mProviderInstanceId = -1;
            String mPackageName = null;
            Integer mUid = null;
            SizeF mIdealSize = null;
            String mLayoutResName = null;
            String mLightBackgroundResName = null;
@@ -10180,6 +10182,9 @@ public class RemoteViews implements Parcelable, Filter {
                    case (int) RemoteViewsProto.PACKAGE_NAME:
                        ref.mPackageName = in.readString(RemoteViewsProto.PACKAGE_NAME);
                        break;
                    case (int) RemoteViewsProto.UID:
                        ref.mUid = in.readInt(RemoteViewsProto.UID);
                        break;
                    case (int) RemoteViewsProto.IDEAL_SIZE:
                        final long idealSizeToken = in.start(RemoteViewsProto.IDEAL_SIZE);
                        ref.mIdealSize = createSizeFFromProto(in);
@@ -10281,8 +10286,9 @@ public class RemoteViews implements Parcelable, Filter {
            Resources appResources = null;
            if (!ref.mHasDrawInstructions) {
                checkProtoResultNotNull(ref.mPackageName, "No application info");
                rv.mApplication = context.getPackageManager().getApplicationInfo(ref.mPackageName,
                        /* flags= */ 0);
                checkProtoResultNotNull(ref.mUid, "No uid");
                rv.mApplication = context.getPackageManager().getApplicationInfoAsUser(
                        ref.mPackageName, /* flags= */ 0, UserHandle.getUserId(ref.mUid));
                appContext = rv.getContextForResourcesEnsuringCorrectCachedApkPaths(context);
                appResources = appContext.getResources();

+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ message RemoteViewsProto {
    repeated bytes bitmap_cache = 14;
    optional RemoteCollectionCache remote_collection_cache = 15;
    repeated Action actions = 16;
    optional int32 uid = 17;

    message RemoteCollectionCache {
        message Entry {