From 5a90c4c75b97ab1e2d0cb1c9abffb4e6969224af Mon Sep 17 00:00:00 2001 From: Winson Date: Wed, 9 Dec 2020 17:00:23 -0800 Subject: Only allow BROWSABLE && DEFAULT Intents to be always opened Auto verification of app links requires that an intent filter declare action=VIEW, scheme=HTTP(S), category=BROWSABLE. However, PackageManagerService was not taking that into account, missing the category requirement. But the app info Settings UI did take category into account, so it was possible for a user to set an application to automatically open web URIs without understanding that this also granted domains that were not visible in the app info UI. To resolve both this, this change makes it so that both auto verification and the Settings state can only consider the app as "always" open only if the Intent contains both BROWSABLE and DEFAULT. Bug: 175139501 Bug: 175319005 Test: manual, see bug for reproduction steps Merged-In: Ib957258735893bf2779bed19bd400c6726ee6478 Change-Id: Ib957258735893bf2779bed19bd400c6726ee6478 (cherry picked from commit 4266f938c6705466d3844385c2031d1e80ee7b2d) --- .../core/java/com/android/server/pm/PackageManagerService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 50b5f79eab20..eaabf468fc46 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -29,6 +29,8 @@ import static android.content.Intent.CATEGORY_DEFAULT; import static android.content.Intent.CATEGORY_HOME; import static android.content.pm.PackageManager.CERT_INPUT_RAW_X509; import static android.content.pm.PackageManager.CERT_INPUT_SHA256; +import static android.content.Intent.CATEGORY_BROWSABLE; +import static android.content.Intent.CATEGORY_DEFAULT; import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT; import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED; import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED; @@ -7780,6 +7782,13 @@ public class PackageManagerService extends IPackageManager.Stub Slog.i(TAG, " + always: " + info.activityInfo.packageName + " : linkgen=" + linkGeneration); } + + if (!intent.hasCategory(CATEGORY_BROWSABLE) + || !intent.hasCategory(CATEGORY_DEFAULT)) { + undefinedList.add(info); + continue; + } + // Use link-enabled generation as preferredOrder, i.e. // prefer newly-enabled over earlier-enabled. info.preferredOrder = linkGeneration; -- cgit v1.2.3-59-g8ed1b