From 4c76ea6b88fad2b0147c050c02c6fd3d886d6743 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 12 Oct 2012 10:44:47 -0700 Subject: Pm command to get maximum users. Used to drive CTS tests. Also print success message when removing a user. Bug: 7334718 Change-Id: Ia3886ddf860cd000ce567b0fed2ef0a4e2a2295c --- cmds/pm/src/com/android/commands/pm/Pm.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'cmds/pm') diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index 463a18c..16d4ad6 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -43,6 +43,7 @@ import android.os.IUserManager; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; +import android.os.UserManager; import java.io.File; import java.lang.reflect.Field; @@ -174,6 +175,11 @@ public final class Pm { return; } + if ("get-max-users".equals(op)) { + runGetMaxUsers(); + return; + } + try { if (args.length == 1) { if (args[0].equalsIgnoreCase("-l")) { @@ -1017,8 +1023,10 @@ public final class Pm { return; } try { - if (!mUm.removeUser(userId)) { - System.err.println("Error: couldn't remove user #" + userId + "."); + if (mUm.removeUser(userId)) { + System.out.println("Success: removed user"); + } else { + System.err.println("Error: couldn't remove user id " + userId); } } catch (RemoteException e) { System.err.println(e.toString()); @@ -1042,6 +1050,11 @@ public final class Pm { System.err.println(PM_NOT_RUNNING_ERR); } } + + public void runGetMaxUsers() { + System.out.println("Maximum supported users: " + UserManager.getMaxSupportedUsers()); + } + class PackageDeleteObserver extends IPackageDeleteObserver.Stub { boolean finished; boolean result; @@ -1451,6 +1464,7 @@ public final class Pm { System.err.println(" pm trim-caches DESIRED_FREE_SPACE"); System.err.println(" pm create-user USER_NAME"); System.err.println(" pm remove-user USER_ID"); + System.err.println(" pm get-max-users"); System.err.println(""); System.err.println("pm list packages: prints all packages, optionally only"); System.err.println(" those whose package name contains the text in FILTER. Options:"); -- cgit v1.1