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

Commit fb810ed7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[ADI][35/N] Remove "set-developer-verification-policy" shell command" into main

parents 772910e4 cc202537
Loading
Loading
Loading
Loading
+0 −50
Original line number Diff line number Diff line
@@ -402,8 +402,6 @@ class PackageManagerShellCommand extends ShellCommand {
                    return runGetDomainVerificationAgent();
                case "get-developer-verification-policy":
                    return runGetDeveloperVerificationPolicy();
                case "set-developer-verification-policy":
                    return runSetDeveloperVerificationPolicy();
                case "get-developer-verification-service-provider":
                    return runGetDeveloperVerificationServiceProvider();
                default: {
@@ -4705,51 +4703,6 @@ class PackageManagerShellCommand extends ShellCommand {
        return 0;
    }

    private int runSetDeveloperVerificationPolicy() 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 String policyStr = getNextArg();
        if (policyStr == null) {
            pw.println("Error: policy not specified");
            return 1;
        }
        final int translatedUserId =
                translateUserId(userId, UserHandle.USER_SYSTEM,
                        "runSetDeveloperVerificationPolicy");
        try {
            final IPackageInstaller installer = mInterface.getPackageInstaller();
            final boolean success = installer.setDeveloperVerificationPolicy(
                    Integer.parseInt(policyStr), translatedUserId);
            if (!success) {
                pw.println("Failure setting verification policy.");
                return 1;
            }
        } catch (Exception e) {
            pw.println("Failure [" + e.getMessage() + "]");
            return 1;
        }
        return 0;
    }

    private int runGetDeveloperVerificationServiceProvider() {
        final PrintWriter pw = getOutPrintWriter();
        try {
@@ -5201,9 +5154,6 @@ class PackageManagerShellCommand extends ShellCommand {
        pw.println("    Display current verification enforcement policy which will be applied to");
        pw.println("    all the future installation sessions");
        pw.println("      --user: show the policy of the given user (SYSTEM_USER if unspecified)");
        pw.println("  set-verification-policy POLICY [--user USER_ID]");
        pw.println("    Sets the verification policy of all the future installation sessions.");
        pw.println("      --user: set the policy of the given user (SYSTEM_USER if unspecified)");
        pw.println("");
        pw.println("");
        printArtServiceHelp();