OSDN Git Service

Always add the instant app installer
authorTodd Kennedy <toddke@google.com>
Mon, 15 May 2017 17:25:02 +0000 (10:25 -0700)
committerTodd Kennedy <toddke@google.com>
Tue, 16 May 2017 18:48:44 +0000 (11:48 -0700)
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

services/core/java/com/android/server/pm/PackageManagerService.java

index 093cdbc..cb8ae49 100644 (file)
@@ -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<ResolveInfo>();
+                    if (result == null) {
+                        result = new ArrayList<>();
+                    }
                 }
             }
         }