From 22d8bb2ca310a929803be4c4ab99c44bc43d1a93 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Mon, 15 May 2017 10:25:02 -0700 Subject: [PATCH] Always add the instant app installer Even if we filter out an instant app because the caller doesn't have access to it, always make sure to add the installer when we have the possibility of an instant app. NOTE: This does not have CTS tests since it's impossible to test without involving the resolver. CTS tests will be added in MR1+ when we can make changes to the APIs and add the necessary methods to mock out the resolver service. Change-Id: I92c88eb04520c0c5e0c58db6d668ed0a0e552a35 Fixes: 38268052 Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.EphemeralTest --- .../com/android/server/pm/PackageManagerService.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 093cdbc580193..cb8ae49d61fa3 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -6474,18 +6474,22 @@ public class PackageManagerService extends IPackageManager.Stub } } else { final PackageParser.Package pkg = mPackages.get(pkgName); + result = null; if (pkg != null) { - return applyPostResolutionFilter(filterIfNotSystemUser( + result = filterIfNotSystemUser( mActivities.queryIntentForPackage( intent, resolvedType, flags, pkg.activities, userId), - userId), instantAppPkgName); - } else { + userId); + } + if (result == null || result.size() == 0) { // the caller wants to resolve for a particular package; however, there // were no installed results, so, try to find an ephemeral result addEphemeral = !ephemeralDisabled && isInstantAppAllowed( intent, null /*result*/, userId, true /*skipPackageCheck*/); - result = new ArrayList(); + if (result == null) { + result = new ArrayList<>(); + } } } }