@@ -262,6 +262,10 @@ public int run(String[] args) throws IOException, RemoteException {
262262 return runMovePrimaryStorage ();
263263 }
264264
265+ if ("set-user-restriction" .equals (op )) {
266+ return runSetUserRestriction ();
267+ }
268+
265269 try {
266270 if (args .length == 1 ) {
267271 if (args [0 ].equalsIgnoreCase ("-l" )) {
@@ -1518,6 +1522,38 @@ public int runMovePrimaryStorage() {
15181522 }
15191523 }
15201524
1525+ public int runSetUserRestriction () {
1526+ int userId = UserHandle .USER_OWNER ;
1527+ String opt = nextOption ();
1528+ if (opt != null && "--user" .equals (opt )) {
1529+ String arg = nextArg ();
1530+ if (arg == null || !isNumber (arg )) {
1531+ System .err .println ("Error: valid userId not specified" );
1532+ return 1 ;
1533+ }
1534+ userId = Integer .parseInt (arg );
1535+ }
1536+
1537+ String restriction = nextArg ();
1538+ String arg = nextArg ();
1539+ boolean value ;
1540+ if ("1" .equals (arg )) {
1541+ value = true ;
1542+ } else if ("0" .equals (arg )) {
1543+ value = false ;
1544+ } else {
1545+ System .err .println ("Error: valid value not specified" );
1546+ return 1 ;
1547+ }
1548+ try {
1549+ mUm .setUserRestriction (restriction , value , userId );
1550+ return 0 ;
1551+ } catch (RemoteException e ) {
1552+ System .err .println (e .toString ());
1553+ return 1 ;
1554+ }
1555+ }
1556+
15211557 private int runUninstall () throws RemoteException {
15221558 int flags = 0 ;
15231559 int userId = UserHandle .USER_ALL ;
0 commit comments