Block instant apps before domain verification filtering

Because domain verification itself filters instant apps, and isn't
aware of the allow instant apps toggle that PackageManagerService
holds onto, PMS should filter the set of ResolveInfo candidates before
DomainVerificationService gets them.

This way it can avoid resolving to an instant app that would later be
blocked and thus fail resolution entirely.

Bug: 180628950

Test: manual, see steps in bug

Change-Id: I37ba986bfafd26f6633ff1b6e355a76b4c92552c
This commit is contained in:
Winson
2021-02-23 12:08:07 -08:00
committed by Winson Chiu
parent 7a17ad8ccb
commit f4afcc8a10

View File

@@ -2604,10 +2604,22 @@ public class PackageManagerService extends IPackageManager.Stub
final ArrayList<ResolveInfo> matchAllList = new ArrayList<>();
final ArrayList<ResolveInfo> undefinedList = new ArrayList<>();
// Blocking instant apps is usually done in applyPostResolutionFilter, but since
// domain verification can resolve to a single result, which can be an instant app,
// it will then be filtered to an empty list in that method. Instead, do blocking
// here so that instant apps can be ignored for approval filtering and a lower
// priority result chosen instead.
final boolean blockInstant = intent.isWebIntent() && areWebInstantAppsDisabled(userId);
final int count = candidates.size();
// First, try to use approved apps.
for (int n = 0; n < count; n++) {
ResolveInfo info = candidates.get(n);
if (blockInstant && (info.isInstantAppAvailable
|| isInstantApp(info.activityInfo.packageName, userId))) {
continue;
}
// Add to the special match all list (Browser use case)
if (info.handleAllWebDataURI) {
matchAllList.add(info);