From 2deec664a258d113838500b949a72e19202aea63 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Mon, 4 Jun 2018 14:26:24 -0700 Subject: Allow instant apps to launch instant apps Instant apps should be able to launch other instant apps indirectly using a web URI or with the MATCH_EXTERNAL flag set.. Change-Id: I2566937dd5d47076701c49435365dedd8593067a Fixes: 92742631 Test: atest CtsAppSecurityHostTestCases:EphemeralTest --- .../android/server/pm/PackageManagerService.java | 34 +++++++++++++++------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index d496ab67fec4..96fe2f4a62c3 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -6626,7 +6626,8 @@ public class PackageManagerService extends IPackageManager.Stub } } return applyPostResolutionFilter( - list, instantAppPkgName, allowDynamicSplits, filterCallingUid, userId, intent); + list, instantAppPkgName, allowDynamicSplits, filterCallingUid, resolveForStart, + userId, intent); } // reader @@ -6645,7 +6646,7 @@ public class PackageManagerService extends IPackageManager.Stub xpResult.add(xpResolveInfo); return applyPostResolutionFilter( filterIfNotSystemUser(xpResult, userId), instantAppPkgName, - allowDynamicSplits, filterCallingUid, userId, intent); + allowDynamicSplits, filterCallingUid, resolveForStart, userId, intent); } // Check for results in the current profile. @@ -6685,14 +6686,16 @@ public class PackageManagerService extends IPackageManager.Stub // result straight away. result.add(xpDomainInfo.resolveInfo); return applyPostResolutionFilter(result, instantAppPkgName, - allowDynamicSplits, filterCallingUid, userId, intent); + allowDynamicSplits, filterCallingUid, resolveForStart, userId, + intent); } } else if (result.size() <= 1 && !addInstant) { // No result in parent user and <= 1 result in current profile, and we // are not going to add emphemeral app, so we can return the result without // further processing. return applyPostResolutionFilter(result, instantAppPkgName, - allowDynamicSplits, filterCallingUid, userId, intent); + allowDynamicSplits, filterCallingUid, resolveForStart, userId, + intent); } // We have more than one candidate (combining results from current and parent // profile), so we need filtering and sorting. @@ -6728,7 +6731,8 @@ public class PackageManagerService extends IPackageManager.Stub Collections.sort(result, mResolvePrioritySorter); } return applyPostResolutionFilter( - result, instantAppPkgName, allowDynamicSplits, filterCallingUid, userId, intent); + result, instantAppPkgName, allowDynamicSplits, filterCallingUid, resolveForStart, + userId, intent); } private List maybeAddInstantAppInstaller(List result, Intent intent, @@ -6938,8 +6942,8 @@ public class PackageManagerService extends IPackageManager.Stub * @return A filtered list of resolved activities. */ private List applyPostResolutionFilter(List resolveInfos, - String ephemeralPkgName, boolean allowDynamicSplits, int filterCallingUid, int userId, - Intent intent) { + String ephemeralPkgName, boolean allowDynamicSplits, int filterCallingUid, + boolean resolveForStart, int userId, Intent intent) { final boolean blockInstant = intent.isWebIntent() && areWebInstantAppsDisabled(); for (int i = resolveInfos.size() - 1; i >= 0; i--) { final ResolveInfo info = resolveInfos.get(i); @@ -6998,6 +7002,13 @@ public class PackageManagerService extends IPackageManager.Stub } else if (ephemeralPkgName.equals(info.activityInfo.packageName)) { // caller is same app; don't need to apply any other filtering continue; + } else if (resolveForStart + && (intent.isWebIntent() + || (intent.getFlags() & Intent.FLAG_ACTIVITY_MATCH_EXTERNAL) != 0) + && intent.getPackage() == null + && intent.getComponent() == null) { + // ephemeral apps can launch other ephemeral apps indirectly + continue; } // allow activities that have been explicitly exposed to ephemeral apps final boolean isEphemeralApp = info.activityInfo.applicationInfo.isInstantApp(); @@ -7576,7 +7587,8 @@ public class PackageManagerService extends IPackageManager.Stub } } return applyPostResolutionFilter( - list, instantAppPkgName, allowDynamicSplits, callingUid, userId, intent); + list, instantAppPkgName, allowDynamicSplits, callingUid, false, userId, + intent); } // reader @@ -7586,14 +7598,16 @@ public class PackageManagerService extends IPackageManager.Stub final List result = mReceivers.queryIntent(intent, resolvedType, flags, userId); return applyPostResolutionFilter( - result, instantAppPkgName, allowDynamicSplits, callingUid, userId, intent); + result, instantAppPkgName, allowDynamicSplits, callingUid, false, userId, + intent); } final PackageParser.Package pkg = mPackages.get(pkgName); if (pkg != null) { final List result = mReceivers.queryIntentForPackage( intent, resolvedType, flags, pkg.receivers, userId); return applyPostResolutionFilter( - result, instantAppPkgName, allowDynamicSplits, callingUid, userId, intent); + result, instantAppPkgName, allowDynamicSplits, callingUid, false, userId, + intent); } return Collections.emptyList(); } -- cgit v1.2.3-59-g8ed1b