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

Commit 610b91de authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Always return null when accessing provider unavailable to instant app

When the provider is not cached we first try to resolve it which would
fail and return null. When the provider is cached we would return a
SecurityException.

This unifies the behavior for instant apps.

Fixes: 92984448
Test: cts-instant-tradefed run commandAndExit cts-instant-dev
      -m CtsPermissionTestCases
      --test=android.permission.cts.ProviderPermissionTest

Change-Id: I00120f597bd10ac02232bcc2b25dd0d6c4342bf2
parent 9303f6fd
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -12048,14 +12048,17 @@ public class ActivityManagerService extends IActivityManager.Stub
            if (providerRunning) {
                cpi = cpr.info;
                String msg;
                checkTime(startTime, "getContentProviderImpl: before checkContentProviderPermission");
                if (r != null && cpr.canRunHere(r)) {
                    checkTime(startTime,
                            "getContentProviderImpl: before checkContentProviderPermission");
                    if ((msg = checkContentProviderPermissionLocked(cpi, r, userId, checkCrossUser))
                            != null) {
                        throw new SecurityException(msg);
                    }
                checkTime(startTime, "getContentProviderImpl: after checkContentProviderPermission");
                    checkTime(startTime,
                            "getContentProviderImpl: after checkContentProviderPermission");
                if (r != null && cpr.canRunHere(r)) {
                    // This provider has been published or is in the process
                    // of being published...  but it is also allowed to run
                    // in the caller's process, so don't make a connection
@@ -12066,6 +12069,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    holder.provider = null;
                    return holder;
                }
                // Don't expose providers between normal apps and instant apps
                try {
                    if (AppGlobals.getPackageManager()
@@ -12075,6 +12079,15 @@ public class ActivityManagerService extends IActivityManager.Stub
                } catch (RemoteException e) {
                }
                checkTime(startTime,
                        "getContentProviderImpl: before checkContentProviderPermission");
                if ((msg = checkContentProviderPermissionLocked(cpi, r, userId, checkCrossUser))
                        != null) {
                    throw new SecurityException(msg);
                }
                checkTime(startTime,
                        "getContentProviderImpl: after checkContentProviderPermission");
                final long origId = Binder.clearCallingIdentity();
                checkTime(startTime, "getContentProviderImpl: incProviderCountLocked");