Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b23fc47d authored by Winson Chiu's avatar Winson Chiu Committed by Android (Google) Code Review
Browse files

Merge "Only run domain verification filtering for valid Intents" into sc-dev

parents aa1d38db 33710636
Loading
Loading
Loading
Loading
+31 −14
Original line number Diff line number Diff line
@@ -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<ResolveInfo> result = new ArrayList<>();
            final ArrayList<ResolveInfo> matchAllList = new ArrayList<>();
            final ArrayList<ResolveInfo> undefinedList = new ArrayList<>();
            final int count = candidates.size();
            // First, try to use approved apps.
@@ -2595,20 +2597,33 @@ 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);
                }
            }
            // We'll want to include browser possibilities in a few cases
            boolean includeBrowser = false;
            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);
                }
                includeBrowser = true;
            } else {
                Pair<List<ResolveInfo>, Integer> infosAndLevel = mDomainVerificationManager
                    .filterToApprovedApp(intent, candidates, userId, mSettings::getPackageLPr);
                        .filterToApprovedApp(intent, undefinedList, userId,
                                mSettings::getPackageLPr);
                List<ResolveInfo> 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 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);
@@ -2619,10 +2634,12 @@ public class PackageManagerService extends IPackageManager.Stub
                    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) {
                    if (xpDomainInfo != null
                            && xpDomainInfo.highestApprovalLevel >= highestApproval) {
                        result.add(xpDomainInfo.resolveInfo);
                    }
                }
            }
            if (includeBrowser) {
                // Also add browsers (all of them or only the default one)
+2 −2
Original line number Diff line number Diff line
@@ -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);