diff options
author | Sudheer Shanka <sudheersai@google.com> | 2016-06-16 08:58:00 -0700 |
---|---|---|
committer | The Android Automerger <android-build@android.com> | 2016-06-24 16:53:07 -0700 |
commit | 4e4743a354e26467318b437892a9980eb9b8328a (patch) | |
tree | 0b3074ad0b7ad79882a83480e256aea439d02fcb /cmds/pm | |
parent | 01875b0274e74f97edf6b0d5c92de822e0555d03 (diff) | |
download | frameworks_base-4e4743a354e26467318b437892a9980eb9b8328a.zip frameworks_base-4e4743a354e26467318b437892a9980eb9b8328a.tar.gz frameworks_base-4e4743a354e26467318b437892a9980eb9b8328a.tar.bz2 |
Add pm operation to set user restrictions.
Bug: 29189712
Change-Id: I6fdb3b68dfe3f51119e5ce8008880fc7d9c793df
Diffstat (limited to 'cmds/pm')
-rw-r--r-- | cmds/pm/src/com/android/commands/pm/Pm.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index 58c3a9c..4869adf 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -262,6 +262,10 @@ public final class Pm { return runMovePrimaryStorage(); } + if ("set-user-restriction".equals(op)) { + return runSetUserRestriction(); + } + try { if (args.length == 1) { if (args[0].equalsIgnoreCase("-l")) { @@ -1518,6 +1522,38 @@ 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 { + mUm.setUserRestriction(restriction, value, 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; |