summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sudheer Shanka <sudheersai@google.com> 2016-07-12 19:20:38 +0000
committer android-build-merger <android-build-merger@google.com> 2016-07-12 19:20:38 +0000
commit76c9d707568e10d1d6560abed4511692db07b98f (patch)
tree5d753615debb50493a90fab635a26935a10c70e2
parentfd0757f195657012c2b22fc295df428f32fbc806 (diff)
parentcb7e0643c9e8cb990947300560e8c0c83ad6b5b4 (diff)
Merge \\"DO NOT MERGE: Add pm operation to set user restrictions.\\" into lmp-mr1-dev am: d327d73edf
am: cb7e0643c9 Change-Id: I42d732fcc3ed8745dcc35e433e066ee8babe3e42
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java38
1 files changed, 38 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 7a01701f8dda..bee7a30864e5 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -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;