diff options
| -rw-r--r-- | services/core/java/com/android/server/am/ActiveServices.java | 18 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 15 |
2 files changed, 25 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java index 872902626fb4..4165200d837a 100644 --- a/services/core/java/com/android/server/am/ActiveServices.java +++ b/services/core/java/com/android/server/am/ActiveServices.java @@ -4987,14 +4987,16 @@ public final class ActiveServices { * - the first arg isn't the flattened component name of an existing service: * dump all services whose component contains the first arg as a substring */ - protected boolean dumpService(FileDescriptor fd, PrintWriter pw, final String name, + protected boolean dumpService(FileDescriptor fd, PrintWriter pw, String name, int[] users, String[] args, int opti, boolean dumpAll) { final ArrayList<ServiceRecord> services = new ArrayList<>(); final Predicate<ServiceRecord> filter = DumpUtils.filterRecord(name); synchronized (mAm) { - int[] users = mAm.mUserController.getUsers(); + if (users == null) { + users = mAm.mUserController.getUsers(); + } for (int user : users) { ServiceMap smap = mServiceMap.get(user); @@ -5039,11 +5041,13 @@ public final class ActiveServices { String innerPrefix = prefix + " "; synchronized (mAm) { pw.print(prefix); pw.print("SERVICE "); - pw.print(r.shortInstanceName); pw.print(" "); - pw.print(Integer.toHexString(System.identityHashCode(r))); - pw.print(" pid="); - if (r.app != null) pw.println(r.app.pid); - else pw.println("(not running)"); + pw.print(r.shortInstanceName); pw.print(" "); + pw.print(Integer.toHexString(System.identityHashCode(r))); + pw.print(" pid="); + if (r.app != null) { + pw.print(r.app.pid); + pw.print(" user="); pw.println(r.userId); + } else pw.println("(not running)"); if (dumpAll) { r.dump(pw, innerPrefix); } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 8f1160aecc92..df1081e43262 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -8664,17 +8664,30 @@ public class ActivityManagerService extends IActivityManager.Stub } else if ("service".equals(cmd)) { String[] newArgs; String name; + int[] users = null; if (opti >= args.length) { name = null; newArgs = EMPTY_STRING_ARRAY; } else { name = args[opti]; opti++; + if ("--user".equals(name) && opti < args.length) { + int userId = UserHandle.parseUserArg(args[opti]); + opti++; + if (userId != UserHandle.USER_ALL) { + if (userId == UserHandle.USER_CURRENT) { + userId = getCurrentUser().id; + } + users = new int[] { userId }; + } + name = args[opti]; + opti++; + } newArgs = new String[args.length - opti]; if (args.length > 2) System.arraycopy(args, opti, newArgs, 0, args.length - opti); } - if (!mServices.dumpService(fd, pw, name, newArgs, 0, dumpAll)) { + if (!mServices.dumpService(fd, pw, name, users, newArgs, 0, dumpAll)) { pw.println("No services match: " + name); pw.println("Use -h for help."); } |