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

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

Merge \\"DO NOT MERGE: Add pm operation to set user restrictions.\\" into...

Merge \\"DO NOT MERGE: Add pm operation to set user restrictions.\\" into lmp-mr1-dev am: d327d73e
am: cb7e0643

Change-Id: I42d732fcc3ed8745dcc35e433e066ee8babe3e42
parents fd0757f1 cb7e0643
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -235,6 +235,10 @@ public final class Pm {
            return runForceDexOpt();
        }

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

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

    public int runSetUserRestriction() {
        int userId = UserHandle.USER_OWNER;
        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 {
            Bundle restrictions = new Bundle();
            restrictions.putBoolean(restriction, value);
            mUm.setUserRestrictions(restrictions, userId);
            return 0;
        } catch (RemoteException e) {
            System.err.println(e.toString());
            return 1;
        }
    }

    private int runUninstall() throws RemoteException {
        int flags = 0;
        int userId = UserHandle.USER_ALL;