Loading services/core/java/com/android/server/am/ActivityManagerService.java +39 −19 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ import static android.provider.Settings.Global.DEBUG_APP; import static android.provider.Settings.Global.WAIT_FOR_DEBUGGER; import static android.text.format.DateUtils.DAY_IN_MILLIS; import static android.util.FeatureFlagUtils.SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS; import static android.view.Display.INVALID_DISPLAY; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_CONFIGURATION; import static com.android.internal.util.FrameworkStatsLog.UNSAFE_INTENT_EVENT_REPORTED__EVENT_TYPE__INTERNAL_NON_EXPORTED_COMPONENT_MATCH; Loading Loading @@ -9681,8 +9682,8 @@ public class ActivityManagerService extends IActivityManager.Stub } private void dumpEverything(FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, String dumpPackage, boolean dumpClient, boolean dumpNormalPriority, int dumpAppId, boolean dumpProxies) { boolean dumpAll, String dumpPackage, int displayIdFilter, boolean dumpClient, boolean dumpNormalPriority, int dumpAppId, boolean dumpProxies) { ActiveServices.ServiceDumper sdumper; Loading Loading @@ -9762,27 +9763,27 @@ public class ActivityManagerService extends IActivityManager.Stub if (dumpAll) { pw.println("-------------------------------------------------------------------------------"); } mAtmInternal.dump( DUMP_RECENTS_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); mAtmInternal.dump(DUMP_RECENTS_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter); pw.println(); if (dumpAll) { pw.println("-------------------------------------------------------------------------------"); } mAtmInternal.dump( DUMP_LASTANR_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); mAtmInternal.dump(DUMP_LASTANR_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter); pw.println(); if (dumpAll) { pw.println("-------------------------------------------------------------------------------"); } mAtmInternal.dump( DUMP_STARTER_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); mAtmInternal.dump(DUMP_STARTER_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter); if (dumpPackage == null) { pw.println(); if (dumpAll) { pw.println("-------------------------------------------------------------------------------"); } mAtmInternal.dump( DUMP_CONTAINERS_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); mAtmInternal.dump(DUMP_CONTAINERS_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter); } // Activities section is dumped as part of the Critical priority dump. Exclude the // section if priority is Normal. Loading @@ -9791,8 +9792,8 @@ public class ActivityManagerService extends IActivityManager.Stub if (dumpAll) { pw.println("-------------------------------------------------------------------------------"); } mAtmInternal.dump( DUMP_ACTIVITIES_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); mAtmInternal.dump(DUMP_ACTIVITIES_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter); } if (mAssociations.size() > 0) { pw.println(); Loading Loading @@ -9865,6 +9866,8 @@ public class ActivityManagerService extends IActivityManager.Stub boolean dumpNormalPriority = false; boolean dumpVisibleStacksOnly = false; boolean dumpFocusedStackOnly = false; boolean dumpVerbose = false; int dumpDisplayId = INVALID_DISPLAY; String dumpPackage = null; int dumpUserId = UserHandle.USER_ALL; Loading Loading @@ -9909,11 +9912,27 @@ public class ActivityManagerService extends IActivityManager.Stub pw.println("Error: --user option requires user id argument"); return; } } else if ("-d".equals(opt)) { if (opti < args.length) { dumpDisplayId = Integer.parseInt(args[opti]); if (dumpDisplayId == INVALID_DISPLAY) { pw.println("Error: -d cannot be used with INVALID_DISPLAY"); return; } opti++; } else { pw.println("Error: -d option requires display argument"); return; } dumpClient = true; } else if ("--verbose".equals(opt)) { dumpVerbose = true; } else if ("-h".equals(opt)) { ActivityManagerShellCommand.dumpHelp(pw, true); return; } else { pw.println("Unknown argument: " + opt + "; use -h for help"); return; } } Loading Loading @@ -10026,8 +10045,8 @@ public class ActivityManagerService extends IActivityManager.Stub || DUMP_RECENTS_CMD.equals(cmd) || DUMP_RECENTS_SHORT_CMD.equals(cmd) || DUMP_TOP_RESUMED_ACTIVITY.equals(cmd) || DUMP_VISIBLE_ACTIVITIES.equals(cmd)) { mAtmInternal.dump( cmd, fd, pw, args, opti, true /* dumpAll */, dumpClient, dumpPackage); mAtmInternal.dump(cmd, fd, pw, args, opti, /* dumpAll= */ true , dumpClient, dumpPackage, dumpDisplayId); } else if ("binder-proxies".equals(cmd)) { if (opti >= args.length) { dumpBinderProxies(pw, 0 /* minToDump */); Loading Loading @@ -10194,7 +10213,8 @@ public class ActivityManagerService extends IActivityManager.Stub } else { // Dumping a single activity? if (!mAtmInternal.dumpActivity(fd, pw, cmd, args, opti, dumpAll, dumpVisibleStacksOnly, dumpFocusedStackOnly, dumpUserId)) { dumpVisibleStacksOnly, dumpFocusedStackOnly, dumpVerbose, dumpDisplayId, dumpUserId)) { ActivityManagerShellCommand shell = new ActivityManagerShellCommand(this, true); int res = shell.exec(this, null, fd, null, args, null, new ResultReceiver(null)); Loading @@ -10217,15 +10237,15 @@ public class ActivityManagerService extends IActivityManager.Stub if (dumpClient) { // dumpEverything() will take the lock when needed, and momentarily drop // it for dumping client state. dumpEverything(fd, pw, args, opti, dumpAll, dumpPackage, dumpClient, dumpNormalPriority, dumpAppId, true /* dumpProxies */); dumpEverything(fd, pw, args, opti, dumpAll, dumpPackage, dumpDisplayId, dumpClient, dumpNormalPriority, dumpAppId, /* dumpProxies= */ true); } else { // Take the lock here, so we get a consistent state for the entire dump; // dumpEverything() will take the lock as well, which is fine for everything // except dumping proxies, which can take a long time; exclude them. synchronized(this) { dumpEverything(fd, pw, args, opti, dumpAll, dumpPackage, dumpClient, dumpNormalPriority, dumpAppId, false /* dumpProxies */); dumpEverything(fd, pw, args, opti, dumpAll, dumpPackage, dumpDisplayId, dumpClient, dumpNormalPriority, dumpAppId, /* dumpProxies= */ false); } } if (dumpAll) { Loading services/core/java/com/android/server/am/ActivityManagerShellCommand.java +3 −0 Original line number Diff line number Diff line Loading @@ -3945,6 +3945,7 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println(" package [PACKAGE_NAME]: all state related to given package"); pw.println(" all: dump all activities"); pw.println(" top: dump the top activity"); pw.println(" users: user state"); pw.println(" WHAT may also be a COMP_SPEC to dump activities."); pw.println(" COMP_SPEC may be a component name (com.foo/.myApp),"); pw.println(" a partial substring in a component name, a"); Loading @@ -3952,9 +3953,11 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println(" -a: include all available server state."); pw.println(" -c: include client state."); pw.println(" -p: limit output to given package."); pw.println(" -d: limit output to given display."); pw.println(" --checkin: output checkin format, resetting data."); pw.println(" --C: output checkin format, not resetting data."); pw.println(" --proto: output dump in protocol buffer format."); pw.println(" --verbose: dumps extra information."); pw.printf(" %s: dump just the DUMPABLE-related state of an activity. Use the %s " + "option to list the supported DUMPABLEs\n", Activity.DUMP_ARG_DUMP_DUMPABLE, Activity.DUMP_ARG_LIST_DUMPABLES); Loading services/core/java/com/android/server/am/AppProfiler.java +3 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT; import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL; import static android.os.Process.FIRST_APPLICATION_UID; import static android.util.FeatureFlagUtils.SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS; import static android.view.Display.INVALID_DISPLAY; import static com.android.internal.app.procstats.ProcessStats.ADJ_MEM_FACTOR_CRITICAL; import static com.android.internal.app.procstats.ProcessStats.ADJ_MEM_FACTOR_LOW; Loading Loading @@ -1604,8 +1605,8 @@ public class AppProfiler { mService.mServices.newServiceDumperLocked(null, catPw, emptyArgs, 0, false, null).dumpLocked(); catPw.println(); mService.mAtmInternal.dump( DUMP_ACTIVITIES_CMD, null, catPw, emptyArgs, 0, false, false, null); mService.mAtmInternal.dump(DUMP_ACTIVITIES_CMD, null, catPw, emptyArgs, 0, false, false, null, INVALID_DISPLAY); catPw.flush(); } dropBuilder.append(catSw.toString()); Loading services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java +5 −3 Original line number Diff line number Diff line Loading @@ -473,9 +473,10 @@ public abstract class ActivityTaskManagerInternal { /** Writes current activity states to the proto stream. */ public abstract void writeActivitiesToProto(ProtoOutputStream proto); /** Dump the current state based on the command. */ /** Dump the current state based on the command and filters. */ public abstract void dump(String cmd, FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, boolean dumpClient, String dumpPackage); int opti, boolean dumpAll, boolean dumpClient, String dumpPackage, int displayIdFilter); /** Dump the current state for inclusion in process dump. */ public abstract boolean dumpForProcesses(FileDescriptor fd, PrintWriter pw, boolean dumpAll, Loading @@ -489,7 +490,8 @@ public abstract class ActivityTaskManagerInternal { /** Dump the current activities state. */ public abstract boolean dumpActivity(FileDescriptor fd, PrintWriter pw, String name, String[] args, int opti, boolean dumpAll, boolean dumpVisibleRootTasksOnly, boolean dumpFocusedRootTaskOnly, @UserIdInt int userId); boolean dumpFocusedRootTaskOnly, boolean dumpVerbose, int displayIdFilter, @UserIdInt int userId); /** Dump the current state for inclusion in oom dump. */ public abstract void dumpForOom(PrintWriter pw); Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +69 −22 Original line number Diff line number Diff line Loading @@ -229,6 +229,7 @@ import android.util.Slog; import android.util.SparseArray; import android.util.TimeUtils; import android.util.proto.ProtoOutputStream; import android.view.Display; import android.view.IRecentsAnimationRunner; import android.view.RemoteAnimationAdapter; import android.view.RemoteAnimationDefinition; Loading Loading @@ -4103,42 +4104,50 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } void dumpVisibleActivitiesLocked(PrintWriter pw) { void dumpVisibleActivitiesLocked(PrintWriter pw, int displayIdFilter) { pw.println("ACTIVITY MANAGER VISIBLE ACTIVITIES (dumpsys activity visible)"); ArrayList<ActivityRecord> activities = mRootWindowContainer.getDumpActivities("all", /* dumpVisibleRootTasksOnly */ true, /* dumpFocusedRootTaskOnly */ false, UserHandle.USER_ALL); boolean needSeparator = false; boolean printedAnything = false; for (int i = activities.size() - 1; i >= 0; i--) { ActivityRecord activity = activities.get(i); if (!activity.isVisible()) { if (!activity.isVisible() || (displayIdFilter != INVALID_DISPLAY && activity.getDisplayId() != displayIdFilter)) { continue; } if (needSeparator) { pw.println(); } printedAnything = true; activity.dump(pw, "", true); needSeparator = true; } if (!printedAnything) { pw.println("(nothing)"); } } void dumpActivitiesLocked(FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, boolean dumpClient, String dumpPackage) { dumpActivitiesLocked(fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, int opti, boolean dumpAll, boolean dumpClient, String dumpPackage, int displayIdFilter) { dumpActivitiesLocked(fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter, "ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)"); } void dumpActivitiesLocked(FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, boolean dumpClient, String dumpPackage, String header) { int opti, boolean dumpAll, boolean dumpClient, String dumpPackage, int displayIdFilter, String header) { pw.println(header); boolean printedAnything = mRootWindowContainer.dumpActivities(fd, pw, dumpAll, dumpClient, dumpPackage); dumpPackage, displayIdFilter); boolean needSep = printedAnything; boolean printed = ActivityTaskSupervisor.printThisActivity(pw, mRootWindowContainer.getTopResumedActivity(), dumpPackage, needSep, " ResumedActivity: ", null); mRootWindowContainer.getTopResumedActivity(), dumpPackage, displayIdFilter, needSep, " ResumedActivity: ", /* header= */ null); if (printed) { printedAnything = true; needSep = false; Loading Loading @@ -4196,7 +4205,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { */ protected boolean dumpActivity(FileDescriptor fd, PrintWriter pw, String name, String[] args, int opti, boolean dumpAll, boolean dumpVisibleRootTasksOnly, boolean dumpFocusedRootTaskOnly, @UserIdInt int userId) { boolean dumpFocusedRootTaskOnly, boolean dumpVerbose, int displayIdFilter, @UserIdInt int userId) { ArrayList<ActivityRecord> activities; synchronized (mGlobalLock) { Loading @@ -4213,6 +4223,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { Task lastTask = null; boolean needSep = false; boolean printedAnything = false; for (int i = activities.size() - 1; i >= 0; i--) { ActivityRecord r = activities.get(i); if (needSep) { Loading @@ -4220,21 +4231,31 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } needSep = true; synchronized (mGlobalLock) { final Task task = r.getTask(); Task task = r.getTask(); int displayId = task.getDisplayId(); if (displayIdFilter != INVALID_DISPLAY && displayId != displayIdFilter) { continue; } if (lastTask != task) { printedAnything = true; lastTask = task; pw.print("TASK "); pw.print(lastTask.affinity); pw.print(" id="); pw.print(lastTask.mTaskId); pw.print(" userId="); pw.println(lastTask.mUserId); pw.print(lastTask.mUserId); printDisplayInfoAndNewLine(pw, r); if (dumpAll) { lastTask.dump(pw, " "); } } } dumpActivity(" ", fd, pw, activities.get(i), newArgs, dumpAll); dumpActivity(" ", fd, pw, activities.get(i), newArgs, dumpAll, dumpVerbose); } if (!printedAnything) { // Typically happpens when no task matches displayIdFilter pw.println("(nothing)"); } return true; } Loading @@ -4244,7 +4265,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { * there is a thread associated with the activity. */ private void dumpActivity(String prefix, FileDescriptor fd, PrintWriter pw, final ActivityRecord r, String[] args, boolean dumpAll) { ActivityRecord r, String[] args, boolean dumpAll, boolean dumpVerbose) { String innerPrefix = prefix + " "; IApplicationThread appThread = null; synchronized (mGlobalLock) { Loading @@ -4255,13 +4276,22 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { pw.print(Integer.toHexString(System.identityHashCode(r))); pw.print(" pid="); if (r.hasProcess()) { pw.println(r.app.getPid()); pw.print(r.app.getPid()); appThread = r.app.getThread(); } else { pw.println("(not running)"); pw.print("(not running)"); } if (dumpVerbose) { pw.print(" userId="); pw.print(r.mUserId); pw.print(" uid="); pw.print(r.getUid()); printDisplayInfoAndNewLine(pw, r); } else { pw.println(); } if (dumpAll) { r.dump(pw, innerPrefix, true /* dumpAll */); r.dump(pw, innerPrefix, /* dumpAll= */ true); } } if (appThread != null) { Loading @@ -4279,6 +4309,20 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } private void printDisplayInfoAndNewLine(PrintWriter pw, ActivityRecord r) { pw.print(" displayId="); DisplayContent displayContent = r.getDisplayContent(); if (displayContent == null) { pw.println("N/A"); return; } Display display = displayContent.getDisplay(); pw.print(display.getDisplayId()); pw.print("(type="); pw.print(Display.typeToString(display.getType())); pw.println(")"); } private void writeSleepStateToProto(ProtoOutputStream proto, int wakeFullness, boolean testPssMode) { final long sleepToken = proto.start(ActivityManagerServiceDumpProcessesProto.SLEEP_STATUS); Loading Loading @@ -5308,7 +5352,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { + "------------"); dumpActivitiesLocked(null /* fd */, pw, null /* args */, 0 /* opti */, true /* dumpAll */, false /* dumpClient */, null /* dumpPackage */, "" /* header */); INVALID_DISPLAY, "" /* header */); pw.println(); pw.close(); Loading Loading @@ -6359,10 +6403,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { @Override public void dump(String cmd, FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, boolean dumpClient, String dumpPackage) { boolean dumpAll, boolean dumpClient, String dumpPackage, int displayIdFilter) { synchronized (mGlobalLock) { if (DUMP_ACTIVITIES_CMD.equals(cmd) || DUMP_ACTIVITIES_SHORT_CMD.equals(cmd)) { dumpActivitiesLocked(fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); dumpActivitiesLocked(fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter); } else if (DUMP_LASTANR_CMD.equals(cmd)) { dumpLastANRLocked(pw); } else if (DUMP_LASTANR_TRACES_CMD.equals(cmd)) { Loading @@ -6378,7 +6423,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } else if (DUMP_TOP_RESUMED_ACTIVITY.equals(cmd)) { dumpTopResumedActivityLocked(pw); } else if (DUMP_VISIBLE_ACTIVITIES.equals(cmd)) { dumpVisibleActivitiesLocked(pw); dumpVisibleActivitiesLocked(pw, displayIdFilter); } } } Loading Loading @@ -6573,9 +6618,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { @Override public boolean dumpActivity(FileDescriptor fd, PrintWriter pw, String name, String[] args, int opti, boolean dumpAll, boolean dumpVisibleRootTasksOnly, boolean dumpFocusedRootTaskOnly, @UserIdInt int userId) { boolean dumpFocusedRootTaskOnly, boolean dumpVerbose, int displayIdFilter, @UserIdInt int userId) { return ActivityTaskManagerService.this.dumpActivity(fd, pw, name, args, opti, dumpAll, dumpVisibleRootTasksOnly, dumpFocusedRootTaskOnly, userId); dumpVisibleRootTasksOnly, dumpFocusedRootTaskOnly, dumpVerbose, displayIdFilter, userId); } @Override Loading Loading
services/core/java/com/android/server/am/ActivityManagerService.java +39 −19 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ import static android.provider.Settings.Global.DEBUG_APP; import static android.provider.Settings.Global.WAIT_FOR_DEBUGGER; import static android.text.format.DateUtils.DAY_IN_MILLIS; import static android.util.FeatureFlagUtils.SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS; import static android.view.Display.INVALID_DISPLAY; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_CONFIGURATION; import static com.android.internal.util.FrameworkStatsLog.UNSAFE_INTENT_EVENT_REPORTED__EVENT_TYPE__INTERNAL_NON_EXPORTED_COMPONENT_MATCH; Loading Loading @@ -9681,8 +9682,8 @@ public class ActivityManagerService extends IActivityManager.Stub } private void dumpEverything(FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, String dumpPackage, boolean dumpClient, boolean dumpNormalPriority, int dumpAppId, boolean dumpProxies) { boolean dumpAll, String dumpPackage, int displayIdFilter, boolean dumpClient, boolean dumpNormalPriority, int dumpAppId, boolean dumpProxies) { ActiveServices.ServiceDumper sdumper; Loading Loading @@ -9762,27 +9763,27 @@ public class ActivityManagerService extends IActivityManager.Stub if (dumpAll) { pw.println("-------------------------------------------------------------------------------"); } mAtmInternal.dump( DUMP_RECENTS_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); mAtmInternal.dump(DUMP_RECENTS_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter); pw.println(); if (dumpAll) { pw.println("-------------------------------------------------------------------------------"); } mAtmInternal.dump( DUMP_LASTANR_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); mAtmInternal.dump(DUMP_LASTANR_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter); pw.println(); if (dumpAll) { pw.println("-------------------------------------------------------------------------------"); } mAtmInternal.dump( DUMP_STARTER_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); mAtmInternal.dump(DUMP_STARTER_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter); if (dumpPackage == null) { pw.println(); if (dumpAll) { pw.println("-------------------------------------------------------------------------------"); } mAtmInternal.dump( DUMP_CONTAINERS_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); mAtmInternal.dump(DUMP_CONTAINERS_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter); } // Activities section is dumped as part of the Critical priority dump. Exclude the // section if priority is Normal. Loading @@ -9791,8 +9792,8 @@ public class ActivityManagerService extends IActivityManager.Stub if (dumpAll) { pw.println("-------------------------------------------------------------------------------"); } mAtmInternal.dump( DUMP_ACTIVITIES_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); mAtmInternal.dump(DUMP_ACTIVITIES_CMD, fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter); } if (mAssociations.size() > 0) { pw.println(); Loading Loading @@ -9865,6 +9866,8 @@ public class ActivityManagerService extends IActivityManager.Stub boolean dumpNormalPriority = false; boolean dumpVisibleStacksOnly = false; boolean dumpFocusedStackOnly = false; boolean dumpVerbose = false; int dumpDisplayId = INVALID_DISPLAY; String dumpPackage = null; int dumpUserId = UserHandle.USER_ALL; Loading Loading @@ -9909,11 +9912,27 @@ public class ActivityManagerService extends IActivityManager.Stub pw.println("Error: --user option requires user id argument"); return; } } else if ("-d".equals(opt)) { if (opti < args.length) { dumpDisplayId = Integer.parseInt(args[opti]); if (dumpDisplayId == INVALID_DISPLAY) { pw.println("Error: -d cannot be used with INVALID_DISPLAY"); return; } opti++; } else { pw.println("Error: -d option requires display argument"); return; } dumpClient = true; } else if ("--verbose".equals(opt)) { dumpVerbose = true; } else if ("-h".equals(opt)) { ActivityManagerShellCommand.dumpHelp(pw, true); return; } else { pw.println("Unknown argument: " + opt + "; use -h for help"); return; } } Loading Loading @@ -10026,8 +10045,8 @@ public class ActivityManagerService extends IActivityManager.Stub || DUMP_RECENTS_CMD.equals(cmd) || DUMP_RECENTS_SHORT_CMD.equals(cmd) || DUMP_TOP_RESUMED_ACTIVITY.equals(cmd) || DUMP_VISIBLE_ACTIVITIES.equals(cmd)) { mAtmInternal.dump( cmd, fd, pw, args, opti, true /* dumpAll */, dumpClient, dumpPackage); mAtmInternal.dump(cmd, fd, pw, args, opti, /* dumpAll= */ true , dumpClient, dumpPackage, dumpDisplayId); } else if ("binder-proxies".equals(cmd)) { if (opti >= args.length) { dumpBinderProxies(pw, 0 /* minToDump */); Loading Loading @@ -10194,7 +10213,8 @@ public class ActivityManagerService extends IActivityManager.Stub } else { // Dumping a single activity? if (!mAtmInternal.dumpActivity(fd, pw, cmd, args, opti, dumpAll, dumpVisibleStacksOnly, dumpFocusedStackOnly, dumpUserId)) { dumpVisibleStacksOnly, dumpFocusedStackOnly, dumpVerbose, dumpDisplayId, dumpUserId)) { ActivityManagerShellCommand shell = new ActivityManagerShellCommand(this, true); int res = shell.exec(this, null, fd, null, args, null, new ResultReceiver(null)); Loading @@ -10217,15 +10237,15 @@ public class ActivityManagerService extends IActivityManager.Stub if (dumpClient) { // dumpEverything() will take the lock when needed, and momentarily drop // it for dumping client state. dumpEverything(fd, pw, args, opti, dumpAll, dumpPackage, dumpClient, dumpNormalPriority, dumpAppId, true /* dumpProxies */); dumpEverything(fd, pw, args, opti, dumpAll, dumpPackage, dumpDisplayId, dumpClient, dumpNormalPriority, dumpAppId, /* dumpProxies= */ true); } else { // Take the lock here, so we get a consistent state for the entire dump; // dumpEverything() will take the lock as well, which is fine for everything // except dumping proxies, which can take a long time; exclude them. synchronized(this) { dumpEverything(fd, pw, args, opti, dumpAll, dumpPackage, dumpClient, dumpNormalPriority, dumpAppId, false /* dumpProxies */); dumpEverything(fd, pw, args, opti, dumpAll, dumpPackage, dumpDisplayId, dumpClient, dumpNormalPriority, dumpAppId, /* dumpProxies= */ false); } } if (dumpAll) { Loading
services/core/java/com/android/server/am/ActivityManagerShellCommand.java +3 −0 Original line number Diff line number Diff line Loading @@ -3945,6 +3945,7 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println(" package [PACKAGE_NAME]: all state related to given package"); pw.println(" all: dump all activities"); pw.println(" top: dump the top activity"); pw.println(" users: user state"); pw.println(" WHAT may also be a COMP_SPEC to dump activities."); pw.println(" COMP_SPEC may be a component name (com.foo/.myApp),"); pw.println(" a partial substring in a component name, a"); Loading @@ -3952,9 +3953,11 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println(" -a: include all available server state."); pw.println(" -c: include client state."); pw.println(" -p: limit output to given package."); pw.println(" -d: limit output to given display."); pw.println(" --checkin: output checkin format, resetting data."); pw.println(" --C: output checkin format, not resetting data."); pw.println(" --proto: output dump in protocol buffer format."); pw.println(" --verbose: dumps extra information."); pw.printf(" %s: dump just the DUMPABLE-related state of an activity. Use the %s " + "option to list the supported DUMPABLEs\n", Activity.DUMP_ARG_DUMP_DUMPABLE, Activity.DUMP_ARG_LIST_DUMPABLES); Loading
services/core/java/com/android/server/am/AppProfiler.java +3 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static android.app.ActivityManager.PROCESS_STATE_NONEXISTENT; import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL; import static android.os.Process.FIRST_APPLICATION_UID; import static android.util.FeatureFlagUtils.SETTINGS_ENABLE_MONITOR_PHANTOM_PROCS; import static android.view.Display.INVALID_DISPLAY; import static com.android.internal.app.procstats.ProcessStats.ADJ_MEM_FACTOR_CRITICAL; import static com.android.internal.app.procstats.ProcessStats.ADJ_MEM_FACTOR_LOW; Loading Loading @@ -1604,8 +1605,8 @@ public class AppProfiler { mService.mServices.newServiceDumperLocked(null, catPw, emptyArgs, 0, false, null).dumpLocked(); catPw.println(); mService.mAtmInternal.dump( DUMP_ACTIVITIES_CMD, null, catPw, emptyArgs, 0, false, false, null); mService.mAtmInternal.dump(DUMP_ACTIVITIES_CMD, null, catPw, emptyArgs, 0, false, false, null, INVALID_DISPLAY); catPw.flush(); } dropBuilder.append(catSw.toString()); Loading
services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java +5 −3 Original line number Diff line number Diff line Loading @@ -473,9 +473,10 @@ public abstract class ActivityTaskManagerInternal { /** Writes current activity states to the proto stream. */ public abstract void writeActivitiesToProto(ProtoOutputStream proto); /** Dump the current state based on the command. */ /** Dump the current state based on the command and filters. */ public abstract void dump(String cmd, FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, boolean dumpClient, String dumpPackage); int opti, boolean dumpAll, boolean dumpClient, String dumpPackage, int displayIdFilter); /** Dump the current state for inclusion in process dump. */ public abstract boolean dumpForProcesses(FileDescriptor fd, PrintWriter pw, boolean dumpAll, Loading @@ -489,7 +490,8 @@ public abstract class ActivityTaskManagerInternal { /** Dump the current activities state. */ public abstract boolean dumpActivity(FileDescriptor fd, PrintWriter pw, String name, String[] args, int opti, boolean dumpAll, boolean dumpVisibleRootTasksOnly, boolean dumpFocusedRootTaskOnly, @UserIdInt int userId); boolean dumpFocusedRootTaskOnly, boolean dumpVerbose, int displayIdFilter, @UserIdInt int userId); /** Dump the current state for inclusion in oom dump. */ public abstract void dumpForOom(PrintWriter pw); Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +69 −22 Original line number Diff line number Diff line Loading @@ -229,6 +229,7 @@ import android.util.Slog; import android.util.SparseArray; import android.util.TimeUtils; import android.util.proto.ProtoOutputStream; import android.view.Display; import android.view.IRecentsAnimationRunner; import android.view.RemoteAnimationAdapter; import android.view.RemoteAnimationDefinition; Loading Loading @@ -4103,42 +4104,50 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } void dumpVisibleActivitiesLocked(PrintWriter pw) { void dumpVisibleActivitiesLocked(PrintWriter pw, int displayIdFilter) { pw.println("ACTIVITY MANAGER VISIBLE ACTIVITIES (dumpsys activity visible)"); ArrayList<ActivityRecord> activities = mRootWindowContainer.getDumpActivities("all", /* dumpVisibleRootTasksOnly */ true, /* dumpFocusedRootTaskOnly */ false, UserHandle.USER_ALL); boolean needSeparator = false; boolean printedAnything = false; for (int i = activities.size() - 1; i >= 0; i--) { ActivityRecord activity = activities.get(i); if (!activity.isVisible()) { if (!activity.isVisible() || (displayIdFilter != INVALID_DISPLAY && activity.getDisplayId() != displayIdFilter)) { continue; } if (needSeparator) { pw.println(); } printedAnything = true; activity.dump(pw, "", true); needSeparator = true; } if (!printedAnything) { pw.println("(nothing)"); } } void dumpActivitiesLocked(FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, boolean dumpClient, String dumpPackage) { dumpActivitiesLocked(fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, int opti, boolean dumpAll, boolean dumpClient, String dumpPackage, int displayIdFilter) { dumpActivitiesLocked(fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter, "ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)"); } void dumpActivitiesLocked(FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, boolean dumpClient, String dumpPackage, String header) { int opti, boolean dumpAll, boolean dumpClient, String dumpPackage, int displayIdFilter, String header) { pw.println(header); boolean printedAnything = mRootWindowContainer.dumpActivities(fd, pw, dumpAll, dumpClient, dumpPackage); dumpPackage, displayIdFilter); boolean needSep = printedAnything; boolean printed = ActivityTaskSupervisor.printThisActivity(pw, mRootWindowContainer.getTopResumedActivity(), dumpPackage, needSep, " ResumedActivity: ", null); mRootWindowContainer.getTopResumedActivity(), dumpPackage, displayIdFilter, needSep, " ResumedActivity: ", /* header= */ null); if (printed) { printedAnything = true; needSep = false; Loading Loading @@ -4196,7 +4205,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { */ protected boolean dumpActivity(FileDescriptor fd, PrintWriter pw, String name, String[] args, int opti, boolean dumpAll, boolean dumpVisibleRootTasksOnly, boolean dumpFocusedRootTaskOnly, @UserIdInt int userId) { boolean dumpFocusedRootTaskOnly, boolean dumpVerbose, int displayIdFilter, @UserIdInt int userId) { ArrayList<ActivityRecord> activities; synchronized (mGlobalLock) { Loading @@ -4213,6 +4223,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { Task lastTask = null; boolean needSep = false; boolean printedAnything = false; for (int i = activities.size() - 1; i >= 0; i--) { ActivityRecord r = activities.get(i); if (needSep) { Loading @@ -4220,21 +4231,31 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } needSep = true; synchronized (mGlobalLock) { final Task task = r.getTask(); Task task = r.getTask(); int displayId = task.getDisplayId(); if (displayIdFilter != INVALID_DISPLAY && displayId != displayIdFilter) { continue; } if (lastTask != task) { printedAnything = true; lastTask = task; pw.print("TASK "); pw.print(lastTask.affinity); pw.print(" id="); pw.print(lastTask.mTaskId); pw.print(" userId="); pw.println(lastTask.mUserId); pw.print(lastTask.mUserId); printDisplayInfoAndNewLine(pw, r); if (dumpAll) { lastTask.dump(pw, " "); } } } dumpActivity(" ", fd, pw, activities.get(i), newArgs, dumpAll); dumpActivity(" ", fd, pw, activities.get(i), newArgs, dumpAll, dumpVerbose); } if (!printedAnything) { // Typically happpens when no task matches displayIdFilter pw.println("(nothing)"); } return true; } Loading @@ -4244,7 +4265,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { * there is a thread associated with the activity. */ private void dumpActivity(String prefix, FileDescriptor fd, PrintWriter pw, final ActivityRecord r, String[] args, boolean dumpAll) { ActivityRecord r, String[] args, boolean dumpAll, boolean dumpVerbose) { String innerPrefix = prefix + " "; IApplicationThread appThread = null; synchronized (mGlobalLock) { Loading @@ -4255,13 +4276,22 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { pw.print(Integer.toHexString(System.identityHashCode(r))); pw.print(" pid="); if (r.hasProcess()) { pw.println(r.app.getPid()); pw.print(r.app.getPid()); appThread = r.app.getThread(); } else { pw.println("(not running)"); pw.print("(not running)"); } if (dumpVerbose) { pw.print(" userId="); pw.print(r.mUserId); pw.print(" uid="); pw.print(r.getUid()); printDisplayInfoAndNewLine(pw, r); } else { pw.println(); } if (dumpAll) { r.dump(pw, innerPrefix, true /* dumpAll */); r.dump(pw, innerPrefix, /* dumpAll= */ true); } } if (appThread != null) { Loading @@ -4279,6 +4309,20 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } private void printDisplayInfoAndNewLine(PrintWriter pw, ActivityRecord r) { pw.print(" displayId="); DisplayContent displayContent = r.getDisplayContent(); if (displayContent == null) { pw.println("N/A"); return; } Display display = displayContent.getDisplay(); pw.print(display.getDisplayId()); pw.print("(type="); pw.print(Display.typeToString(display.getType())); pw.println(")"); } private void writeSleepStateToProto(ProtoOutputStream proto, int wakeFullness, boolean testPssMode) { final long sleepToken = proto.start(ActivityManagerServiceDumpProcessesProto.SLEEP_STATUS); Loading Loading @@ -5308,7 +5352,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { + "------------"); dumpActivitiesLocked(null /* fd */, pw, null /* args */, 0 /* opti */, true /* dumpAll */, false /* dumpClient */, null /* dumpPackage */, "" /* header */); INVALID_DISPLAY, "" /* header */); pw.println(); pw.close(); Loading Loading @@ -6359,10 +6403,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { @Override public void dump(String cmd, FileDescriptor fd, PrintWriter pw, String[] args, int opti, boolean dumpAll, boolean dumpClient, String dumpPackage) { boolean dumpAll, boolean dumpClient, String dumpPackage, int displayIdFilter) { synchronized (mGlobalLock) { if (DUMP_ACTIVITIES_CMD.equals(cmd) || DUMP_ACTIVITIES_SHORT_CMD.equals(cmd)) { dumpActivitiesLocked(fd, pw, args, opti, dumpAll, dumpClient, dumpPackage); dumpActivitiesLocked(fd, pw, args, opti, dumpAll, dumpClient, dumpPackage, displayIdFilter); } else if (DUMP_LASTANR_CMD.equals(cmd)) { dumpLastANRLocked(pw); } else if (DUMP_LASTANR_TRACES_CMD.equals(cmd)) { Loading @@ -6378,7 +6423,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } else if (DUMP_TOP_RESUMED_ACTIVITY.equals(cmd)) { dumpTopResumedActivityLocked(pw); } else if (DUMP_VISIBLE_ACTIVITIES.equals(cmd)) { dumpVisibleActivitiesLocked(pw); dumpVisibleActivitiesLocked(pw, displayIdFilter); } } } Loading Loading @@ -6573,9 +6618,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { @Override public boolean dumpActivity(FileDescriptor fd, PrintWriter pw, String name, String[] args, int opti, boolean dumpAll, boolean dumpVisibleRootTasksOnly, boolean dumpFocusedRootTaskOnly, @UserIdInt int userId) { boolean dumpFocusedRootTaskOnly, boolean dumpVerbose, int displayIdFilter, @UserIdInt int userId) { return ActivityTaskManagerService.this.dumpActivity(fd, pw, name, args, opti, dumpAll, dumpVisibleRootTasksOnly, dumpFocusedRootTaskOnly, userId); dumpVisibleRootTasksOnly, dumpFocusedRootTaskOnly, dumpVerbose, displayIdFilter, userId); } @Override Loading