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

Commit 7beb85c5 authored by Songchun Fan's avatar Songchun Fan
Browse files

[PreVerfiedDomains] shell command to report domain verification agent

We need a way for CTS to disable the current domain verification agent
on device. The disablement is needed to test the pre-verified states.
Otherwise, the pre-verified states will get overwritten by the domain
verification agent very soon after the app installation. This CL add a
shell command that reports the component name of the current domain
verification agent.

BUG: 307327678
Test: adb shell pm get-domain-verification-agent

Change-Id: I9ae4113ed22222674b84c79e29a2fe957f54a991
parent 39a77217
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -846,4 +846,6 @@ interface IPackageManager {

    @EnforcePermission("GET_APP_METADATA")
    int getAppMetadataSource(String packageName, int userId);

    ComponentName getDomainVerificationAgent();
}
+11 −0
Original line number Diff line number Diff line
@@ -6482,6 +6482,17 @@ public class PackageManagerService implements PackageSender, TestUtilityService
            return true;
        }

        @Override
        @Nullable
        public ComponentName getDomainVerificationAgent() {
            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);
        }

        @Override
        public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
                throws RemoteException {
+18 −0
Original line number Diff line number Diff line
@@ -396,6 +396,8 @@ class PackageManagerShellCommand extends ShellCommand {
                    return runArchive();
                case "request-unarchive":
                    return runUnarchive();
                case "get-domain-verification-agent":
                    return runGetDomainVerificationAgent();
                default: {
                    if (ART_SERVICE_COMMANDS.contains(cmd)) {
                        if (DexOptHelper.useArtService()) {
@@ -4794,6 +4796,19 @@ class PackageManagerShellCommand extends ShellCommand {
        return 0;
    }

    private int runGetDomainVerificationAgent() throws RemoteException {
        final PrintWriter pw = getOutPrintWriter();
        try {
            final ComponentName domainVerificationAgent = mInterface.getDomainVerificationAgent();
            pw.println(domainVerificationAgent == null
                    ? "No Domain Verifier available!" : domainVerificationAgent.toString());
        } catch (Exception e) {
            pw.println("Failure [" + e.getMessage() + "]");
            return 1;
        }
        return 0;
    }

    @Override
    public void onHelp() {
        final PrintWriter pw = getOutPrintWriter();
@@ -5194,6 +5209,9 @@ 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("    Displays the component name of the domain verification agent on device.");
        pw.println("");
        if (DexOptHelper.useArtService()) {
            printArtServiceHelp();
        } else {