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

Commit f88a8463 authored by Song Chun Fan's avatar Song Chun Fan Committed by Android (Google) Code Review
Browse files

Merge "[PreVerifiedDomains] specify userId in the get-domain-verification-agent command" into main

parents 021ecf5c 72df67df
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -847,5 +847,5 @@ interface IPackageManager {
    @EnforcePermission("GET_APP_METADATA")
    int getAppMetadataSource(String packageName, int userId);

    ComponentName getDomainVerificationAgent();
    ComponentName getDomainVerificationAgent(int userId);
}
+8 −7
Original line number Diff line number Diff line
@@ -2446,7 +2446,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
            ComponentName intentFilterVerifierComponent =
                    getIntentFilterVerifierComponentNameLPr(computer);
            ComponentName domainVerificationAgent =
                    getDomainVerificationAgentComponentNameLPr(computer);
                    getDomainVerificationAgentComponentNameLPr(computer, UserHandle.USER_SYSTEM);

            DomainVerificationProxy domainVerificationProxy = DomainVerificationProxy.makeProxy(
                    intentFilterVerifierComponent, domainVerificationAgent, mContext,
@@ -2754,12 +2754,13 @@ public class PackageManagerService implements PackageSender, TestUtilityService
    }

    @Nullable
    private ComponentName getDomainVerificationAgentComponentNameLPr(@NonNull Computer computer) {
    private ComponentName getDomainVerificationAgentComponentNameLPr(@NonNull Computer computer,
            int userId) {
        Intent intent = new Intent(Intent.ACTION_DOMAINS_NEED_VERIFICATION);
        List<ResolveInfo> matches =
                mResolveIntentHelper.queryIntentReceiversInternal(computer, intent, null,
                        MATCH_SYSTEM_ONLY | MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE,
                        UserHandle.USER_SYSTEM, Binder.getCallingUid());
                        userId, Binder.getCallingUid());
        ResolveInfo best = null;
        final int N = matches.size();
        for (int i = 0; i < N; i++) {
@@ -2767,7 +2768,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
            final String packageName = cur.getComponentInfo().packageName;
            if (checkPermission(
                    android.Manifest.permission.DOMAIN_VERIFICATION_AGENT, packageName,
                    UserHandle.USER_SYSTEM) != PackageManager.PERMISSION_GRANTED) {
                    userId) != PackageManager.PERMISSION_GRANTED) {
                Slog.w(TAG, "Domain verification agent found but does not hold permission: "
                        + packageName);
                continue;
@@ -2775,7 +2776,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService

            if (best == null || cur.priority > best.priority) {
                if (computer.isComponentEffectivelyEnabled(cur.getComponentInfo(),
                        UserHandle.SYSTEM)) {
                        UserHandle.of(userId))) {
                    best = cur;
                } else {
                    Slog.w(TAG, "Domain verification agent found but not enabled");
@@ -6512,13 +6513,13 @@ public class PackageManagerService implements PackageSender, TestUtilityService

        @Override
        @Nullable
        public ComponentName getDomainVerificationAgent() {
        public ComponentName getDomainVerificationAgent(int userId) {
            final int callerUid = Binder.getCallingUid();
            if (!PackageManagerServiceUtils.isRootOrShell(callerUid)) {
                throw new SecurityException("Not allowed to query domain verification agent");
            }
            final Computer snapshot = snapshotComputer();
            return getDomainVerificationAgentComponentNameLPr(snapshot);
            return getDomainVerificationAgentComponentNameLPr(snapshot, userId);
        }

        @Override
+24 −1
Original line number Diff line number Diff line
@@ -4412,8 +4412,31 @@ class PackageManagerShellCommand extends ShellCommand {

    private int runGetDomainVerificationAgent() throws RemoteException {
        final PrintWriter pw = getOutPrintWriter();
        int userId = UserHandle.USER_ALL;

        String opt;
        while ((opt = getNextOption()) != null) {
            if (opt.equals("--user")) {
                userId = UserHandle.parseUserArg(getNextArgRequired());
                if (userId != UserHandle.USER_ALL && userId != UserHandle.USER_CURRENT) {
                    UserManagerInternal umi =
                            LocalServices.getService(UserManagerInternal.class);
                    UserInfo userInfo = umi.getUserInfo(userId);
                    if (userInfo == null) {
                        pw.println("Failure [user " + userId + " doesn't exist]");
                        return 1;
                    }
                }
            } else {
                pw.println("Error: Unknown option: " + opt);
                return 1;
            }
        }
        final int translatedUserId =
                translateUserId(userId, UserHandle.USER_SYSTEM, "runGetDomainVerificationAgent");
        try {
            final ComponentName domainVerificationAgent = mInterface.getDomainVerificationAgent();
            final ComponentName domainVerificationAgent =
                    mInterface.getDomainVerificationAgent(translatedUserId);
            pw.println(domainVerificationAgent == null
                    ? "No Domain Verifier available!" : domainVerificationAgent.flattenToString());
        } catch (Exception e) {