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

Commit bb23d537 authored by Hai Zhang's avatar Hai Zhang
Browse files

Fix InstantAppRegistry for secondary users.

This changes adds an initialization in PackageManagerService
constructor for per-user Instant App list in InstantAppRegistry so
that the list is initialized for all users. It also fixes callers
passing uid instead of app id when calling grantEphemeralAccess().

Bug: 111370050
Bug: 111436542
Test: cl/209819423
Change-Id: I42c72188365dd67e903f80a1c1e425124f0db241
parent 02360205
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1628,7 +1628,7 @@ public final class ActiveServices {
            // Once the apps have become associated, if one of them is caller is ephemeral
            // the target app should now be able to see the calling app
            mAm.grantEphemeralAccessLocked(callerApp.userId, service,
                    s.appInfo.uid, UserHandle.getAppId(callerApp.uid));
                    UserHandle.getAppId(s.appInfo.uid), UserHandle.getAppId(callerApp.uid));

            AppBindRecord b = s.retrieveAppBindingLocked(service, callerApp);
            ConnectionRecord c = new ConnectionRecord(b, activity,
@@ -2581,8 +2581,8 @@ public final class ActiveServices {
                mAm.mUgmInternal.grantUriPermissionUncheckedFromIntent(si.neededGrants,
                        si.getUriPermissionsLocked());
            }
            mAm.grantEphemeralAccessLocked(r.userId, si.intent,
                    r.appInfo.uid, UserHandle.getAppId(si.callingId));
            mAm.grantEphemeralAccessLocked(r.userId, si.intent, UserHandle.getAppId(r.appInfo.uid),
                    UserHandle.getAppId(si.callingId));
            bumpServiceExecutingLocked(r, execInFg, "start");
            if (!oomAdjusted) {
                oomAdjusted = true;
+2 −1
Original line number Diff line number Diff line
@@ -8236,7 +8236,8 @@ public class ActivityManagerService extends IActivityManager.Stub
            checkTime(startTime, "getContentProviderImpl: done!");
            grantEphemeralAccessLocked(userId, null /*intent*/,
                    cpi.applicationInfo.uid, UserHandle.getAppId(Binder.getCallingUid()));
                    UserHandle.getAppId(cpi.applicationInfo.uid),
                    UserHandle.getAppId(Binder.getCallingUid()));
        }
        // Wait for the provider to be published...
+1 −1
Original line number Diff line number Diff line
@@ -1469,7 +1469,7 @@ class ActivityStarter {
        mService.mUgmInternal.grantUriPermissionFromIntent(mCallingUid, mStartActivity.packageName,
                mIntent, mStartActivity.getUriPermissionsLocked(), mStartActivity.userId);
        mService.mAm.grantEphemeralAccessLocked(mStartActivity.userId, mIntent,
                mStartActivity.appInfo.uid, UserHandle.getAppId(mCallingUid));
                UserHandle.getAppId(mStartActivity.appInfo.uid), UserHandle.getAppId(mCallingUid));
        if (newTask) {
            EventLog.writeEvent(EventLogTags.AM_CREATE_TASK, mStartActivity.userId,
                    mStartActivity.getTask().taskId);
+16 −2
Original line number Diff line number Diff line
@@ -3246,6 +3246,21 @@ public class PackageManagerService extends IPackageManager.Stub
                mRequiredPermissionControllerPackage = null;
            }
            // Initialize InstantAppRegistry's Instant App list for all users.
            final int[] userIds = UserManagerService.getInstance().getUserIds();
            for (PackageParser.Package pkg : mPackages.values()) {
                if (pkg.isSystem()) {
                    continue;
                }
                for (int userId : userIds) {
                    final PackageSetting ps = (PackageSetting) pkg.mExtras;
                    if (ps == null || !ps.getInstantApp(userId) || !ps.getInstalled(userId)) {
                        continue;
                    }
                    mInstantAppRegistry.addInstantAppLPw(userId, ps.appId);
                }
            }
            mInstallerService = new PackageInstallerService(context, this);
            final Pair<ComponentName, String> instantAppResolverComponent =
                    getInstantAppResolverLPr();
@@ -3273,8 +3288,7 @@ public class PackageManagerService extends IPackageManager.Stub
            // should take a fairly small time compare to the other activities (e.g. package
            // scanning).
            final Map<Integer, List<PackageInfo>> userPackages = new HashMap<>();
            final int[] currentUserIds = UserManagerService.getInstance().getUserIds();
            for (int userId : currentUserIds) {
            for (int userId : userIds) {
                userPackages.put(userId, getInstalledPackages(/*flags*/ 0, userId).getList());
            }
            mDexManager.load(userPackages);