4343import android .os .RemoteException ;
4444import android .os .ServiceManager ;
4545import android .os .UserHandle ;
46+ import android .os .UserManager ;
4647
4748import java .io .File ;
4849import java .lang .reflect .Field ;
@@ -174,6 +175,11 @@ public void run(String[] args) {
174175 return ;
175176 }
176177
178+ if ("get-max-users" .equals (op )) {
179+ runGetMaxUsers ();
180+ return ;
181+ }
182+
177183 try {
178184 if (args .length == 1 ) {
179185 if (args [0 ].equalsIgnoreCase ("-l" )) {
@@ -1017,8 +1023,10 @@ public void runRemoveUser() {
10171023 return ;
10181024 }
10191025 try {
1020- if (!mUm .removeUser (userId )) {
1021- System .err .println ("Error: couldn't remove user #" + userId + "." );
1026+ if (mUm .removeUser (userId )) {
1027+ System .out .println ("Success: removed user" );
1028+ } else {
1029+ System .err .println ("Error: couldn't remove user id " + userId );
10221030 }
10231031 } catch (RemoteException e ) {
10241032 System .err .println (e .toString ());
@@ -1042,6 +1050,11 @@ public void runListUsers() {
10421050 System .err .println (PM_NOT_RUNNING_ERR );
10431051 }
10441052 }
1053+
1054+ public void runGetMaxUsers () {
1055+ System .out .println ("Maximum supported users: " + UserManager .getMaxSupportedUsers ());
1056+ }
1057+
10451058 class PackageDeleteObserver extends IPackageDeleteObserver .Stub {
10461059 boolean finished ;
10471060 boolean result ;
@@ -1451,6 +1464,7 @@ private static void showUsage() {
14511464 System .err .println (" pm trim-caches DESIRED_FREE_SPACE" );
14521465 System .err .println (" pm create-user USER_NAME" );
14531466 System .err .println (" pm remove-user USER_ID" );
1467+ System .err .println (" pm get-max-users" );
14541468 System .err .println ("" );
14551469 System .err .println ("pm list packages: prints all packages, optionally only" );
14561470 System .err .println (" those whose package name contains the text in FILTER. Options:" );
0 commit comments