From f6746ce14819b3b153e2d20ae3d85069ae5578a9 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Wed, 5 Apr 2017 14:15:00 -0700 Subject: [PATCH] don't honour domain verification for browsers When a default browser is set, we change its domain verification status to "INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS". This change is global and permanent; it affects all URLs and won't be cleared by resetting the browser's domain handling in settings. To properly handle this, we don't pay attention to the domain verification status for "browser" applications when we determine whether or not to offer an instant app. Change-Id: I1e2766e9856b0c9d3276e33a8db10195c72ae6ea Fixes: 36978307 Test: Install firefox, start a browser intent [from command line], select chrome and choose "use always", start another browser intent that resolves to an instant app, see that ephemeral apps still resolve --- .../server/pm/PackageManagerService.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index fe40efb7ef4a5..f62f115ecd54b 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -5753,20 +5753,23 @@ public class PackageManagerService extends IPackageManager.Stub { synchronized (mPackages) { final int count = (resolvedActivities == null ? 0 : resolvedActivities.size()); for (int n = 0; n < count; n++) { - ResolveInfo info = resolvedActivities.get(n); - String packageName = info.activityInfo.packageName; - PackageSetting ps = mSettings.mPackages.get(packageName); + final ResolveInfo info = resolvedActivities.get(n); + final String packageName = info.activityInfo.packageName; + final PackageSetting ps = mSettings.mPackages.get(packageName); if (ps != null) { - // Try to get the status from User settings first - long packedStatus = getDomainVerificationStatusLPr(ps, userId); - int status = (int) (packedStatus >> 32); - if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS + // only check domain verification status if the app is not a browser + if (!info.handleAllWebDataURI) { + // Try to get the status from User settings first + final long packedStatus = getDomainVerificationStatusLPr(ps, userId); + final int status = (int) (packedStatus >> 32); + if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS || status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK) { - if (DEBUG_EPHEMERAL) { - Slog.v(TAG, "DENY ephemeral apps;" - + " pkg: " + packageName + ", status: " + status); + if (DEBUG_EPHEMERAL) { + Slog.v(TAG, "DENY instant app;" + + " pkg: " + packageName + ", status: " + status); + } + return false; } - return false; } if (ps.getInstantApp(userId)) { if (DEBUG_EPHEMERAL) {