Pass dumpsys priority to IServiceManager
Modify IServiceManger to accept supported dumpsys priority as a bitmask
with NORMAL being the default priority. Change listServices to return
a list of services filtered by the priority or all services when the
priority is set to ALL.
BUG:27429130
Test: mmm -j32 frameworks/native/cmds/dumpsys && \
adb sync data && adb shell /data/nativetest/dumpsys_test/dumpsys_test && \
adb shell /data/nativetest64/dumpsys_test/dumpsys_test && \
printf "\n\n#### ALL TESTS PASSED ####\n"
Change-Id: Ibccba63035ace9970c2967a621ee2ad8d15cbeea
diff --git a/cmds/dumpsys/dumpsys.cpp b/cmds/dumpsys/dumpsys.cpp
index 3227749..8fe246b 100644
--- a/cmds/dumpsys/dumpsys.cpp
+++ b/cmds/dumpsys/dumpsys.cpp
@@ -53,13 +53,16 @@
static void usage() {
fprintf(stderr,
- "usage: dumpsys\n"
+ "usage: dumpsys\n"
" To dump all services.\n"
"or:\n"
- " dumpsys [-t TIMEOUT] [--help | -l | --skip SERVICES | SERVICE [ARGS]]\n"
+ " dumpsys [-t TIMEOUT] [--priority LEVEL] [--help | -l | --skip SERVICES | "
+ "SERVICE [ARGS]]\n"
" --help: shows this help\n"
" -l: only list services, do not dump them\n"
" -t TIMEOUT: TIMEOUT to use in seconds instead of default 10 seconds\n"
+ " --priority LEVEL: filter services based on specified priority\n"
+ " LEVEL must be one of CRITICAL | HIGH | NORMAL\n"
" --skip SERVICES: dumps all services but SERVICES (comma-separated list)\n"
" SERVICE [ARGS]: dumps only service SERVICE, optionally passing ARGS to it\n");
}
@@ -80,11 +83,11 @@
bool showListOnly = false;
bool skipServices = false;
int timeoutArg = 10;
- static struct option longOptions[] = {
- {"skip", no_argument, 0, 0 },
- {"help", no_argument, 0, 0 },
- { 0, 0, 0, 0 }
- };
+ int dumpPriority = IServiceManager::DUMP_PRIORITY_ALL;
+ static struct option longOptions[] = {{"priority", required_argument, 0, 0},
+ {"skip", no_argument, 0, 0},
+ {"help", no_argument, 0, 0},
+ {0, 0, 0, 0}};
// Must reset optind, otherwise subsequent calls will fail (wouldn't happen on main.cpp, but
// happens on test cases).
@@ -106,6 +109,18 @@
} else if (!strcmp(longOptions[optionIndex].name, "help")) {
usage();
return 0;
+ } else if (!strcmp(longOptions[optionIndex].name, "priority")) {
+ if (!strcmp(optarg, "CRITICAL")) {
+ dumpPriority = IServiceManager::DUMP_PRIORITY_CRITICAL;
+ } else if (!strcmp(optarg, "HIGH")) {
+ dumpPriority = IServiceManager::DUMP_PRIORITY_HIGH;
+ } else if (!strcmp(optarg, "NORMAL")) {
+ dumpPriority = IServiceManager::DUMP_PRIORITY_NORMAL;
+ } else {
+ fprintf(stderr, "\n");
+ usage();
+ return -1;
+ }
}
break;
@@ -151,7 +166,7 @@
if (services.empty() || showListOnly) {
// gets all services
- services = sm_->listServices();
+ services = sm_->listServices(dumpPriority);
services.sort(sort_func);
args.add(String16("-a"));
}