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

Commit 808c8bbf authored by Songchun Fan's avatar Songchun Fan
Browse files

[pm] fix get-domain-verification-agent command on aosp builds

The V2 domain verification agent is not available on AOSP builds. In
that case, we should return the V1 agent which is the intent filter
verification agent. This CL fixes the shell command results accordingly.

FIXES: 324658473
Test: manual; also with PreVerifiedDomainsTests

Change-Id: Ia9fd389b1dd1ed747cf4761b1a70e19ee763cd36
parent d83b7dbc
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -6519,7 +6519,19 @@ public class PackageManagerService implements PackageSender, TestUtilityService
                throw new SecurityException("Not allowed to query domain verification agent");
            }
            final Computer snapshot = snapshotComputer();
            return getDomainVerificationAgentComponentNameLPr(snapshot, userId);
            final ComponentName agent = mDomainVerificationManager.getProxy().getComponentName();
            final PackageStateInternal ps = snapshot.getPackageStateForInstalledAndFiltered(
                    agent.getPackageName(), callerUid, userId);
            if (ps == null) {
                return null;
            }
            final var disabledComponents =
                    ps.getUserStateOrDefault(userId).getDisabledComponentsNoCopy();
            if (disabledComponents != null && disabledComponents.contains(agent.getClassName())) {
                return null;
            }
            // Only return the result if the agent is installed and enabled on the target user
            return agent;
        }

        @Override
+3 −2
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import static android.content.pm.PackageManager.RESTRICTION_HIDE_NOTIFICATIONS;
import static android.content.pm.PackageManager.RESTRICTION_NONE;

import static com.android.server.LocalManagerRegistry.ManagerNotFoundException;
import static com.android.server.pm.PackageManagerService.DEFAULT_FILE_ACCESS_MODE;

import android.accounts.IAccountManager;
import android.annotation.NonNull;
@@ -4846,8 +4845,10 @@ class PackageManagerShellCommand extends ShellCommand {
        pw.println("    to unarchive an app to the responsible installer. Options are:");
        pw.println("      --user: request unarchival of the app from the given user.");
        pw.println("");
        pw.println("  get-domain-verification-agent");
        pw.println("  get-domain-verification-agent [--user USER_ID]");
        pw.println("    Displays the component name of the domain verification agent on device.");
        pw.println("    If the component isn't enabled, an error message will be displayed.");
        pw.println("      --user: return the agent of the given user (SYSTEM_USER if unspecified)");
        pw.println("");
        printArtServiceHelp();
        pw.println("");