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

Commit bbdd8e4a authored by Todd Kennedy's avatar Todd Kennedy
Browse files

Fix instant app resolution

Resolving intents with a specified component goes down a different
path than regular resolution. For Instant Apps, that meant that
sometimes the Instant App was not able to resolve it's own
activities. Added some new CTS tests to verify that this works.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.EphemeralTest
Change-Id: Ic8a8eaef7eb9e230fdc701c79c85227d0939d974
parent 96b98321
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -6041,16 +6041,24 @@ public class PackageManagerService extends IPackageManager.Stub {
                // used when either 1) the calling package is normal and the activity is within
                // an ephemeral application or 2) the calling package is ephemeral and the
                // activity is not visible to ephemeral applications.
                boolean matchEphemeral =
                final boolean matchInstantApp =
                        (flags & PackageManager.MATCH_INSTANT) != 0;
                boolean ephemeralVisibleOnly =
                final boolean matchVisibleToInstantAppOnly =
                        (flags & PackageManager.MATCH_VISIBLE_TO_INSTANT_APP_ONLY) != 0;
                boolean blockResolution =
                        (!matchEphemeral && instantAppPkgName == null
                                && (ai.applicationInfo.privateFlags
                                        & ApplicationInfo.PRIVATE_FLAG_INSTANT) != 0)
                        || (ephemeralVisibleOnly && instantAppPkgName != null
                                && (ai.flags & ActivityInfo.FLAG_VISIBLE_TO_EPHEMERAL) == 0);
                final boolean isCallerInstantApp =
                        instantAppPkgName != null;
                final boolean isTargetSameInstantApp =
                        comp.getPackageName().equals(instantAppPkgName);
                final boolean isTargetInstantApp =
                        (ai.applicationInfo.privateFlags
                                & ApplicationInfo.PRIVATE_FLAG_INSTANT) != 0;
                final boolean isTargetHiddenFromInstantApp =
                        (ai.flags & ActivityInfo.FLAG_VISIBLE_TO_EPHEMERAL) == 0;
                final boolean blockResolution =
                        !isTargetSameInstantApp
                        && ((!matchInstantApp && !isCallerInstantApp && isTargetInstantApp)
                                || (matchVisibleToInstantAppOnly && isCallerInstantApp
                                        && isTargetHiddenFromInstantApp));
                if (!blockResolution) {
                    final ResolveInfo ri = new ResolveInfo();
                    ri.activityInfo = ai;