summaryrefslogtreecommitdiff
path: root/cmds
diff options
context:
space:
mode:
author Sudheer Shanka <sudheersai@google.com> 2016-06-17 22:15:56 +0000
committer android-build-merger <android-build-merger@google.com> 2016-06-17 22:15:56 +0000
commit867805775800d37cf93debd6e63fac0ffc98c617 (patch)
tree182256ed67b28a30391737db209e2b77d5f9b89b /cmds
parenteea56b9cfe48ddc6ac6e8c2cf3ee3ac8e1ac8e4d (diff)
parent098bc0d84010db02c9f0072c4c8a564211bc2319 (diff)
Merge \\"Add pm operation to set user restrictions.\\" into nyc-dev am: f6824b51cc
am: 098bc0d840 Change-Id: I30e1aa159407cdd7b55f8fa0ae1e6f54c37a62c8
Diffstat (limited to 'cmds')
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java36
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 4470eda0a2fa..c6834f940554 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -254,6 +254,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")) {
@@ -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 {
boolean finished;
boolean result;