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

Commit a6a99cbb authored by Sudheer Shanka's avatar Sudheer Shanka Committed by android-build-merger
Browse files

Merge \"Add pm operation to set user restrictions.\" into nyc-dev

am: f6824b51

Change-Id: I355632fa26c9d85a5d41d18ca298fc704117fc48
parents d6011265 f6824b51
Loading
Loading
Loading
Loading
+36 −0
Original line number Original line Diff line number Diff line
@@ -254,6 +254,10 @@ public final class Pm {
            return runMovePrimaryStorage();
            return runMovePrimaryStorage();
        }
        }


        if ("set-user-restriction".equals(op)) {
            return runSetUserRestriction();
        }

        try {
        try {
            if (args.length == 1) {
            if (args.length == 1) {
                if (args[0].equalsIgnoreCase("-l")) {
                if (args[0].equalsIgnoreCase("-l")) {
@@ -1054,6 +1058,38 @@ public final class Pm {
        }
        }
    }
    }


    public int runSetUserRestriction() {
        int userId = UserHandle.USER_SYSTEM;
        String opt = nextOption();
        if (opt != null && "--user".equals(opt)) {
            String arg = nextArg();
            if (arg == null || !isNumber(arg)) {
                System.err.println("Error: valid userId not specified");
                return 1;
            }
            userId = Integer.parseInt(arg);
        }

        String restriction = nextArg();
        String arg = nextArg();
        boolean value;
        if ("1".equals(arg)) {
            value = true;
        } else if ("0".equals(arg)) {
            value = false;
        } else {
            System.err.println("Error: valid value not specified");
            return 1;
        }
        try {
            mUm.setUserRestriction(restriction, value, userId);
            return 0;
        } catch (RemoteException e) {
            System.err.println(e.toString());
            return 1;
        }
    }

    static class ClearDataObserver extends IPackageDataObserver.Stub {
    static class ClearDataObserver extends IPackageDataObserver.Stub {
        boolean finished;
        boolean finished;
        boolean result;
        boolean result;