Loading services/core/java/com/android/server/am/ActivityManagerService.java +68 −8 Original line number Diff line number Diff line Loading @@ -402,6 +402,7 @@ import com.android.server.firewall.IntentFirewall; import com.android.server.job.JobSchedulerInternal; import com.android.server.pm.Installer; import com.android.server.pm.Installer.InstallerException; import com.android.server.utils.PriorityDump; import com.android.server.vr.VrManagerInternal; import com.android.server.wm.PinnedStackWindowController; import com.android.server.wm.WindowManagerService; Loading Loading @@ -707,6 +708,42 @@ public class ActivityManagerService extends IActivityManager.Stub @VisibleForTesting long mWaitForNetworkTimeoutMs; /** * Helper class which parses out priority arguments and dumps sections according to their * priority. If priority arguments are omitted, function calls the legacy dump command. */ private final PriorityDump.PriorityDumper mPriorityDumper = new PriorityDump.PriorityDumper() { @Override public void dumpCritical(FileDescriptor fd, PrintWriter pw, String[] args) { doDump(fd, pw, new String[] {"activities"}); } @Override public void dumpNormal(FileDescriptor fd, PrintWriter pw, String[] args) { doDump(fd, pw, new String[] {"settings"}); doDump(fd, pw, new String[] {"intents"}); doDump(fd, pw, new String[] {"broadcasts"}); doDump(fd, pw, new String[] {"providers"}); doDump(fd, pw, new String[] {"permissions"}); doDump(fd, pw, new String[] {"services"}); doDump(fd, pw, new String[] {"recents"}); doDump(fd, pw, new String[] {"lastanr"}); doDump(fd, pw, new String[] {"starter"}); if (mAssociations.size() > 0) { doDump(fd, pw, new String[] {"associations"}); } doDump(fd, pw, new String[] {"processes"}); doDump(fd, pw, new String[] {"-v", "all"}); doDump(fd, pw, new String[] {"service", "all"}); doDump(fd, pw, new String[] {"provider", "all"}); } @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { doDump(fd, pw, args); } }; public boolean canShowErrorDialogs() { return mShowDialogs && !mSleeping && !mShuttingDown && !mKeyguardController.isKeyguardShowing(DEFAULT_DISPLAY) Loading Loading @@ -2503,6 +2540,14 @@ public class ActivityManagerService extends IActivityManager.Stub static class MemBinder extends Binder { ActivityManagerService mActivityManagerService; private final PriorityDump.PriorityDumper mPriorityDumper = new PriorityDump.PriorityDumper() { @Override public void dumpNormal(FileDescriptor fd, PrintWriter pw, String[] args) { mActivityManagerService.dumpApplicationMemoryUsage(fd, pw, " ", args, false, null); } }; MemBinder(ActivityManagerService activityManagerService) { mActivityManagerService = activityManagerService; } Loading @@ -2511,7 +2556,7 @@ public class ActivityManagerService extends IActivityManager.Stub protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpAndUsageStatsPermission(mActivityManagerService.mContext, "meminfo", pw)) return; mActivityManagerService.dumpApplicationMemoryUsage(fd, pw, " ", args, false, null); PriorityDump.dump(mPriorityDumper, fd, pw, args); } } Loading Loading @@ -2545,12 +2590,10 @@ public class ActivityManagerService extends IActivityManager.Stub static class CpuBinder extends Binder { ActivityManagerService mActivityManagerService; CpuBinder(ActivityManagerService activityManagerService) { mActivityManagerService = activityManagerService; } private final PriorityDump.PriorityDumper mPriorityDumper = new PriorityDump.PriorityDumper() { @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { public void dumpCritical(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpAndUsageStatsPermission(mActivityManagerService.mContext, "cpuinfo", pw)) return; synchronized (mActivityManagerService.mProcessCpuTracker) { Loading @@ -2559,6 +2602,16 @@ public class ActivityManagerService extends IActivityManager.Stub SystemClock.uptimeMillis())); } } }; CpuBinder(ActivityManagerService activityManagerService) { mActivityManagerService = activityManagerService; } @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { PriorityDump.dump(mPriorityDumper, fd, pw, args); } } public static final class Lifecycle extends SystemService { Loading Loading @@ -14793,6 +14846,13 @@ public class ActivityManagerService extends IActivityManager.Stub @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { PriorityDump.dump(mPriorityDumper, fd, pw, args); } /** * Wrapper function to print out debug data filtered by specified arguments. */ private void doDump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpAndUsageStatsPermission(mContext, TAG, pw)) return; boolean dumpAll = false; services/core/java/com/android/server/utils/PriorityDump.java +7 −7 Original line number Diff line number Diff line Loading @@ -59,10 +59,10 @@ public class SpringfieldNuclearPowerPlant extends Binder { Donuts in the box: 1 Nuclear reactor status: DANGER - MELTDOWN IMMINENT $ adb shell dumpsys snpp --dump_priority CRITICAL $ adb shell dumpsys snpp --dump-priority CRITICAL Donuts in the box: 1 $ adb shell dumpsys snpp --dump_priority NORMAL $ adb shell dumpsys snpp --dump-priority NORMAL Nuclear reactor status: DANGER - MELTDOWN IMMINENT * </code></pre> Loading @@ -84,7 +84,7 @@ public class SpringfieldNuclearPowerPlant extends Binder { */ public final class PriorityDump { public static final String PRIORITY_ARG = "--dump_priority"; public static final String PRIORITY_ARG = "--dump-priority"; private PriorityDump() { throw new UnsupportedOperationException(); Loading @@ -92,12 +92,12 @@ public final class PriorityDump { /** * Parses {@code} and call the proper {@link PriorityDumper} method when the first argument is * {@code --dump_priority}, stripping the priority and its type. * {@code --dump-priority}, stripping the priority and its type. * <p> * For example, if called as {@code --dump_priority HIGH arg1 arg2 arg3}, it will call * For example, if called as {@code --dump-priority HIGH arg1 arg2 arg3}, it will call * <code>dumper.dumpHigh(fd, pw, {"arg1", "arg2", "arg3"}) </code> * <p> * If the {@code --dump_priority} is not set, it calls * If the {@code --dump-priority} is not set, it calls * {@link PriorityDumper#dump(FileDescriptor, PrintWriter, String[])} passing the whole * {@code args} instead. */ Loading @@ -124,7 +124,7 @@ public final class PriorityDump { } /** * Gets an array without the {@code --dump_priority PRIORITY} prefix. * Gets an array without the {@code --dump-priority PRIORITY} prefix. */ private static String[] getStrippedArgs(String[] args) { final String[] stripped = new String[args.length - 2]; Loading services/core/java/com/android/server/wm/WindowManagerService.java +17 −1 Original line number Diff line number Diff line Loading @@ -247,6 +247,7 @@ import com.android.server.Watchdog; import com.android.server.input.InputManagerService; import com.android.server.power.BatterySaverPolicy.ServiceType; import com.android.server.power.ShutdownThread; import com.android.server.utils.PriorityDump; import java.io.BufferedWriter; import java.io.DataInputStream; Loading Loading @@ -391,6 +392,18 @@ public class WindowManagerService extends IWindowManager.Stub }; final WindowSurfacePlacer mWindowPlacerLocked; private final PriorityDump.PriorityDumper mPriorityDumper = new PriorityDump.PriorityDumper() { @Override public void dumpCritical(FileDescriptor fd, PrintWriter pw, String[] args) { doDump(fd, pw, new String[] {"-a"}); } @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { doDump(fd, pw, args); } }; /** * Current user when multi-user is enabled. Don't show windows of * non-current user. Also see mCurrentProfileIds. Loading Loading @@ -6794,8 +6807,11 @@ public class WindowManagerService extends IWindowManager.Stub @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; PriorityDump.dump(mPriorityDumper, fd, pw, args); } private void doDump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; boolean dumpAll = false; boolean useProto = false; Loading services/tests/servicestests/src/com/android/server/utils/PriorityDumpTest.java +9 −9 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ public class PriorityDumpTest { @Test public void testMissingPriority() { final String[] args = { "--dump_priority" "--dump-priority" }; dump(mDumper, mFd, mPw, args); verify(mDumper).dump(same(mFd), same(mPw), same(args)); Loading @@ -89,7 +89,7 @@ public class PriorityDumpTest { @Test public void testInvalidPriorityNoExtraArgs() { final String[] args = { "--dump_priority", "SUPER_HIGH" "--dump-priority", "SUPER_HIGH" }; dump(mDumper, mFd, mPw, args); verify(mDumper).dump(same(mFd), same(mPw), same(args)); Loading @@ -98,7 +98,7 @@ public class PriorityDumpTest { @Test public void testInvalidPriorityExtraArgs() { final String[] args = { "--dump_priority", "SUPER_HIGH", "--high", "--five" "--dump-priority", "SUPER_HIGH", "--high", "--five" }; dump(mDumper, mFd, mPw, args); verify(mDumper).dump(same(mFd), same(mPw), same(args)); Loading Loading @@ -129,7 +129,7 @@ public class PriorityDumpTest { @Test public void testCriticalNoExtraArgs() { dump(mDumper, mFd, mPw, new String[] { "--dump_priority", "CRITICAL" "--dump-priority", "CRITICAL" }); verify(mDumper).dumpCritical(same(mFd), same(mPw), eq(EMPTY_ARGS)); } Loading @@ -137,7 +137,7 @@ public class PriorityDumpTest { @Test public void testCriticalExtraArgs() { dump(mDumper, mFd, mPw, new String[] { "--dump_priority", "CRITICAL", "--high", "--five" "--dump-priority", "CRITICAL", "--high", "--five" }); verify(mDumper).dumpCritical(same(mFd), same(mPw), eq(new String[] { "--high", "--five" Loading @@ -147,7 +147,7 @@ public class PriorityDumpTest { @Test public void testHighNoExtraArgs() { dump(mDumper, mFd, mPw, new String[] { "--dump_priority", "HIGH" "--dump-priority", "HIGH" }); verify(mDumper).dumpHigh(same(mFd), same(mPw), eq(EMPTY_ARGS)); } Loading @@ -155,7 +155,7 @@ public class PriorityDumpTest { @Test public void testHighExtraArgs() { dump(mDumper, mFd, mPw, new String[] { "--dump_priority", "HIGH", "--high", "--five" "--dump-priority", "HIGH", "--high", "--five" }); verify(mDumper).dumpHigh(same(mFd), same(mPw), eq(new String[] { "--high", "--five" Loading @@ -165,7 +165,7 @@ public class PriorityDumpTest { @Test public void testNormalNoExtraArgs() { dump(mDumper, mFd, mPw, new String[] { "--dump_priority", "NORMAL" "--dump-priority", "NORMAL" }); verify(mDumper).dumpNormal(same(mFd), same(mPw), eq(EMPTY_ARGS)); } Loading @@ -173,7 +173,7 @@ public class PriorityDumpTest { @Test public void testNormalExtraArgs() { dump(mDumper, mFd, mPw, new String[] { "--dump_priority", "NORMAL", "--high", "--five" "--dump-priority", "NORMAL", "--high", "--five" }); verify(mDumper).dumpNormal(same(mFd), same(mPw), eq(new String[] { "--high", "--five" Loading Loading
services/core/java/com/android/server/am/ActivityManagerService.java +68 −8 Original line number Diff line number Diff line Loading @@ -402,6 +402,7 @@ import com.android.server.firewall.IntentFirewall; import com.android.server.job.JobSchedulerInternal; import com.android.server.pm.Installer; import com.android.server.pm.Installer.InstallerException; import com.android.server.utils.PriorityDump; import com.android.server.vr.VrManagerInternal; import com.android.server.wm.PinnedStackWindowController; import com.android.server.wm.WindowManagerService; Loading Loading @@ -707,6 +708,42 @@ public class ActivityManagerService extends IActivityManager.Stub @VisibleForTesting long mWaitForNetworkTimeoutMs; /** * Helper class which parses out priority arguments and dumps sections according to their * priority. If priority arguments are omitted, function calls the legacy dump command. */ private final PriorityDump.PriorityDumper mPriorityDumper = new PriorityDump.PriorityDumper() { @Override public void dumpCritical(FileDescriptor fd, PrintWriter pw, String[] args) { doDump(fd, pw, new String[] {"activities"}); } @Override public void dumpNormal(FileDescriptor fd, PrintWriter pw, String[] args) { doDump(fd, pw, new String[] {"settings"}); doDump(fd, pw, new String[] {"intents"}); doDump(fd, pw, new String[] {"broadcasts"}); doDump(fd, pw, new String[] {"providers"}); doDump(fd, pw, new String[] {"permissions"}); doDump(fd, pw, new String[] {"services"}); doDump(fd, pw, new String[] {"recents"}); doDump(fd, pw, new String[] {"lastanr"}); doDump(fd, pw, new String[] {"starter"}); if (mAssociations.size() > 0) { doDump(fd, pw, new String[] {"associations"}); } doDump(fd, pw, new String[] {"processes"}); doDump(fd, pw, new String[] {"-v", "all"}); doDump(fd, pw, new String[] {"service", "all"}); doDump(fd, pw, new String[] {"provider", "all"}); } @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { doDump(fd, pw, args); } }; public boolean canShowErrorDialogs() { return mShowDialogs && !mSleeping && !mShuttingDown && !mKeyguardController.isKeyguardShowing(DEFAULT_DISPLAY) Loading Loading @@ -2503,6 +2540,14 @@ public class ActivityManagerService extends IActivityManager.Stub static class MemBinder extends Binder { ActivityManagerService mActivityManagerService; private final PriorityDump.PriorityDumper mPriorityDumper = new PriorityDump.PriorityDumper() { @Override public void dumpNormal(FileDescriptor fd, PrintWriter pw, String[] args) { mActivityManagerService.dumpApplicationMemoryUsage(fd, pw, " ", args, false, null); } }; MemBinder(ActivityManagerService activityManagerService) { mActivityManagerService = activityManagerService; } Loading @@ -2511,7 +2556,7 @@ public class ActivityManagerService extends IActivityManager.Stub protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpAndUsageStatsPermission(mActivityManagerService.mContext, "meminfo", pw)) return; mActivityManagerService.dumpApplicationMemoryUsage(fd, pw, " ", args, false, null); PriorityDump.dump(mPriorityDumper, fd, pw, args); } } Loading Loading @@ -2545,12 +2590,10 @@ public class ActivityManagerService extends IActivityManager.Stub static class CpuBinder extends Binder { ActivityManagerService mActivityManagerService; CpuBinder(ActivityManagerService activityManagerService) { mActivityManagerService = activityManagerService; } private final PriorityDump.PriorityDumper mPriorityDumper = new PriorityDump.PriorityDumper() { @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { public void dumpCritical(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpAndUsageStatsPermission(mActivityManagerService.mContext, "cpuinfo", pw)) return; synchronized (mActivityManagerService.mProcessCpuTracker) { Loading @@ -2559,6 +2602,16 @@ public class ActivityManagerService extends IActivityManager.Stub SystemClock.uptimeMillis())); } } }; CpuBinder(ActivityManagerService activityManagerService) { mActivityManagerService = activityManagerService; } @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { PriorityDump.dump(mPriorityDumper, fd, pw, args); } } public static final class Lifecycle extends SystemService { Loading Loading @@ -14793,6 +14846,13 @@ public class ActivityManagerService extends IActivityManager.Stub @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { PriorityDump.dump(mPriorityDumper, fd, pw, args); } /** * Wrapper function to print out debug data filtered by specified arguments. */ private void doDump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpAndUsageStatsPermission(mContext, TAG, pw)) return; boolean dumpAll = false;
services/core/java/com/android/server/utils/PriorityDump.java +7 −7 Original line number Diff line number Diff line Loading @@ -59,10 +59,10 @@ public class SpringfieldNuclearPowerPlant extends Binder { Donuts in the box: 1 Nuclear reactor status: DANGER - MELTDOWN IMMINENT $ adb shell dumpsys snpp --dump_priority CRITICAL $ adb shell dumpsys snpp --dump-priority CRITICAL Donuts in the box: 1 $ adb shell dumpsys snpp --dump_priority NORMAL $ adb shell dumpsys snpp --dump-priority NORMAL Nuclear reactor status: DANGER - MELTDOWN IMMINENT * </code></pre> Loading @@ -84,7 +84,7 @@ public class SpringfieldNuclearPowerPlant extends Binder { */ public final class PriorityDump { public static final String PRIORITY_ARG = "--dump_priority"; public static final String PRIORITY_ARG = "--dump-priority"; private PriorityDump() { throw new UnsupportedOperationException(); Loading @@ -92,12 +92,12 @@ public final class PriorityDump { /** * Parses {@code} and call the proper {@link PriorityDumper} method when the first argument is * {@code --dump_priority}, stripping the priority and its type. * {@code --dump-priority}, stripping the priority and its type. * <p> * For example, if called as {@code --dump_priority HIGH arg1 arg2 arg3}, it will call * For example, if called as {@code --dump-priority HIGH arg1 arg2 arg3}, it will call * <code>dumper.dumpHigh(fd, pw, {"arg1", "arg2", "arg3"}) </code> * <p> * If the {@code --dump_priority} is not set, it calls * If the {@code --dump-priority} is not set, it calls * {@link PriorityDumper#dump(FileDescriptor, PrintWriter, String[])} passing the whole * {@code args} instead. */ Loading @@ -124,7 +124,7 @@ public final class PriorityDump { } /** * Gets an array without the {@code --dump_priority PRIORITY} prefix. * Gets an array without the {@code --dump-priority PRIORITY} prefix. */ private static String[] getStrippedArgs(String[] args) { final String[] stripped = new String[args.length - 2]; Loading
services/core/java/com/android/server/wm/WindowManagerService.java +17 −1 Original line number Diff line number Diff line Loading @@ -247,6 +247,7 @@ import com.android.server.Watchdog; import com.android.server.input.InputManagerService; import com.android.server.power.BatterySaverPolicy.ServiceType; import com.android.server.power.ShutdownThread; import com.android.server.utils.PriorityDump; import java.io.BufferedWriter; import java.io.DataInputStream; Loading Loading @@ -391,6 +392,18 @@ public class WindowManagerService extends IWindowManager.Stub }; final WindowSurfacePlacer mWindowPlacerLocked; private final PriorityDump.PriorityDumper mPriorityDumper = new PriorityDump.PriorityDumper() { @Override public void dumpCritical(FileDescriptor fd, PrintWriter pw, String[] args) { doDump(fd, pw, new String[] {"-a"}); } @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { doDump(fd, pw, args); } }; /** * Current user when multi-user is enabled. Don't show windows of * non-current user. Also see mCurrentProfileIds. Loading Loading @@ -6794,8 +6807,11 @@ public class WindowManagerService extends IWindowManager.Stub @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; PriorityDump.dump(mPriorityDumper, fd, pw, args); } private void doDump(FileDescriptor fd, PrintWriter pw, String[] args) { if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; boolean dumpAll = false; boolean useProto = false; Loading
services/tests/servicestests/src/com/android/server/utils/PriorityDumpTest.java +9 −9 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ public class PriorityDumpTest { @Test public void testMissingPriority() { final String[] args = { "--dump_priority" "--dump-priority" }; dump(mDumper, mFd, mPw, args); verify(mDumper).dump(same(mFd), same(mPw), same(args)); Loading @@ -89,7 +89,7 @@ public class PriorityDumpTest { @Test public void testInvalidPriorityNoExtraArgs() { final String[] args = { "--dump_priority", "SUPER_HIGH" "--dump-priority", "SUPER_HIGH" }; dump(mDumper, mFd, mPw, args); verify(mDumper).dump(same(mFd), same(mPw), same(args)); Loading @@ -98,7 +98,7 @@ public class PriorityDumpTest { @Test public void testInvalidPriorityExtraArgs() { final String[] args = { "--dump_priority", "SUPER_HIGH", "--high", "--five" "--dump-priority", "SUPER_HIGH", "--high", "--five" }; dump(mDumper, mFd, mPw, args); verify(mDumper).dump(same(mFd), same(mPw), same(args)); Loading Loading @@ -129,7 +129,7 @@ public class PriorityDumpTest { @Test public void testCriticalNoExtraArgs() { dump(mDumper, mFd, mPw, new String[] { "--dump_priority", "CRITICAL" "--dump-priority", "CRITICAL" }); verify(mDumper).dumpCritical(same(mFd), same(mPw), eq(EMPTY_ARGS)); } Loading @@ -137,7 +137,7 @@ public class PriorityDumpTest { @Test public void testCriticalExtraArgs() { dump(mDumper, mFd, mPw, new String[] { "--dump_priority", "CRITICAL", "--high", "--five" "--dump-priority", "CRITICAL", "--high", "--five" }); verify(mDumper).dumpCritical(same(mFd), same(mPw), eq(new String[] { "--high", "--five" Loading @@ -147,7 +147,7 @@ public class PriorityDumpTest { @Test public void testHighNoExtraArgs() { dump(mDumper, mFd, mPw, new String[] { "--dump_priority", "HIGH" "--dump-priority", "HIGH" }); verify(mDumper).dumpHigh(same(mFd), same(mPw), eq(EMPTY_ARGS)); } Loading @@ -155,7 +155,7 @@ public class PriorityDumpTest { @Test public void testHighExtraArgs() { dump(mDumper, mFd, mPw, new String[] { "--dump_priority", "HIGH", "--high", "--five" "--dump-priority", "HIGH", "--high", "--five" }); verify(mDumper).dumpHigh(same(mFd), same(mPw), eq(new String[] { "--high", "--five" Loading @@ -165,7 +165,7 @@ public class PriorityDumpTest { @Test public void testNormalNoExtraArgs() { dump(mDumper, mFd, mPw, new String[] { "--dump_priority", "NORMAL" "--dump-priority", "NORMAL" }); verify(mDumper).dumpNormal(same(mFd), same(mPw), eq(EMPTY_ARGS)); } Loading @@ -173,7 +173,7 @@ public class PriorityDumpTest { @Test public void testNormalExtraArgs() { dump(mDumper, mFd, mPw, new String[] { "--dump_priority", "NORMAL", "--high", "--five" "--dump-priority", "NORMAL", "--high", "--five" }); verify(mDumper).dumpNormal(same(mFd), same(mPw), eq(new String[] { "--high", "--five" Loading