diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index e6789d4ba8aca..14d15ac492270 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -389,6 +389,7 @@ import com.android.server.pm.permission.PermissionManagerService; import com.android.server.pm.permission.PermissionManagerServiceInternal; import com.android.server.pm.verify.domain.DomainVerificationManagerInternal; import com.android.server.pm.verify.domain.DomainVerificationService; +import com.android.server.pm.verify.domain.DomainVerificationUtils; import com.android.server.pm.verify.domain.proxy.DomainVerificationProxy; import com.android.server.pm.verify.domain.proxy.DomainVerificationProxyV1; import com.android.server.pm.verify.domain.proxy.DomainVerificationProxyV2; @@ -2587,6 +2588,7 @@ public class PackageManagerService extends IPackageManager.Stub CrossProfileDomainInfo xpDomainInfo, int userId, boolean debug) { final ArrayList result = new ArrayList<>(); final ArrayList matchAllList = new ArrayList<>(); + final ArrayList undefinedList = new ArrayList<>(); final int count = candidates.size(); // First, try to use approved apps. @@ -2595,32 +2597,47 @@ public class PackageManagerService extends IPackageManager.Stub // Add to the special match all list (Browser use case) if (info.handleAllWebDataURI) { matchAllList.add(info); + } else { + undefinedList.add(info); } } - Pair, Integer> infosAndLevel = mDomainVerificationManager - .filterToApprovedApp(intent, candidates, userId, mSettings::getPackageLPr); - List approvedInfos = infosAndLevel.first; - Integer highestApproval = infosAndLevel.second; - // We'll want to include browser possibilities in a few cases boolean includeBrowser = false; - // If no apps are approved for the domain, resolve only to browsers - if (approvedInfos.isEmpty()) { - // If the other profile has a result, include that and delegate to ResolveActivity + if (!DomainVerificationUtils.isDomainVerificationIntent(intent)) { + result.addAll(undefinedList); + // Maybe add one for the other profile. if (xpDomainInfo != null && xpDomainInfo.highestApprovalLevel > DomainVerificationManagerInternal.APPROVAL_LEVEL_NONE) { result.add(xpDomainInfo.resolveInfo); - } else { - includeBrowser = true; } + includeBrowser = true; } else { - result.addAll(approvedInfos); + Pair, Integer> infosAndLevel = mDomainVerificationManager + .filterToApprovedApp(intent, undefinedList, userId, + mSettings::getPackageLPr); + List approvedInfos = infosAndLevel.first; + Integer highestApproval = infosAndLevel.second; - // If the other profile has an app that's of equal or higher approval, add it - if (xpDomainInfo != null && xpDomainInfo.highestApprovalLevel >= highestApproval) { - result.add(xpDomainInfo.resolveInfo); + // If no apps are approved for the domain, resolve only to browsers + if (approvedInfos.isEmpty()) { + // If the other profile has a result, include that and delegate to + // ResolveActivity + if (xpDomainInfo != null && xpDomainInfo.highestApprovalLevel + > DomainVerificationManagerInternal.APPROVAL_LEVEL_NONE) { + result.add(xpDomainInfo.resolveInfo); + } else { + includeBrowser = true; + } + } else { + result.addAll(approvedInfos); + + // If the other profile has an app that's of equal or higher approval, add it + if (xpDomainInfo != null + && xpDomainInfo.highestApprovalLevel >= highestApproval) { + result.add(xpDomainInfo.resolveInfo); + } } } diff --git a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationUtils.java b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationUtils.java index 474f822d6a730..475d3a87b4275 100644 --- a/services/core/java/com/android/server/pm/verify/domain/DomainVerificationUtils.java +++ b/services/core/java/com/android/server/pm/verify/domain/DomainVerificationUtils.java @@ -28,7 +28,7 @@ import com.android.server.compat.PlatformCompat; import com.android.server.pm.PackageManagerService; import com.android.server.pm.parsing.pkg.AndroidPackage; -final class DomainVerificationUtils { +public final class DomainVerificationUtils { /** * Consolidates package exception messages. A generic unavailable message is included since the @@ -40,7 +40,7 @@ final class DomainVerificationUtils { throw new NameNotFoundException("Package " + packageName + " unavailable"); } - static boolean isDomainVerificationIntent(Intent intent) { + public static boolean isDomainVerificationIntent(Intent intent) { return intent.isWebIntent() && intent.hasCategory(Intent.CATEGORY_BROWSABLE) && intent.hasCategory(Intent.CATEGORY_DEFAULT);