summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sudheer Shanka <sudheersai@google.com> 2016-07-12 19:03:18 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-07-12 19:03:20 +0000
commitd327d73edf9539805bea4b30a54fa82f071e43bc (patch)
treeed4a1472b6d867fc80a7010136d4bbcef17a1721
parentf1d9152f9f07dda8d3a609438345ab9773608bff (diff)
parent20d5bb8be8038fba8d79312d792f8e28a0410459 (diff)
Merge "DO NOT MERGE: Add pm operation to set user restrictions." into lmp-mr1-dev
-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 0a573ca9c734..774c0cf55b22 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")) {
@@ -1274,6 +1278,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;