Skip to content

Commit 4c76ea6

Browse files
committed
Pm command to get maximum users.
Used to drive CTS tests. Also print success message when removing a user. Bug: 7334718 Change-Id: Ia3886ddf860cd000ce567b0fed2ef0a4e2a2295c
1 parent e6d3ccc commit 4c76ea6

File tree

1 file changed

+16
-2
lines changed
  • cmds/pm/src/com/android/commands/pm

1 file changed

+16
-2
lines changed

cmds/pm/src/com/android/commands/pm/Pm.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import android.os.RemoteException;
4444
import android.os.ServiceManager;
4545
import android.os.UserHandle;
46+
import android.os.UserManager;
4647

4748
import java.io.File;
4849
import 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

Comments
 (0)