Support dumpsys timeouts in milliseconds
- add new dumpsys argument to specify timeouts in milliseconds
- use milliseconds to define timeouts in dumpstate
- minor dumpsys output format changes:
"SERVICE '<service_name>' DUMP TIMEOUT (1s) EXPIRED" ->
"SERVICE '<service_name>' DUMP TIMEOUT (1000ms) EXPIRED"
Bug: 27429130
Test: mmm -j32 frameworks/native/cmds/dumpsys && \
mmm -j32 frameworks/native/cmds/dumpstate && \
adb sync data && adb shell /data/nativetest/dumpsys_test/dumpsys_test && \
adb shell /data/nativetest64/dumpsys_test/dumpsys_test && \
adb shell /data/nativetest/dumpstate_test/dumpstate_test && \
adb shell /data/nativetest64/dumpstate_test/dumpstate_test && \
printf "\n\n#### ALL TESTS PASSED ####\n"
Change-Id: Ibc96ad030bb2c6d880b8201c9b6241fce20b284f
Change-Id: I6ef2ff19787f2b6d940d56e453a1a7462a8c854a
diff --git a/cmds/dumpsys/dumpsys.cpp b/cmds/dumpsys/dumpsys.cpp
index c36ab08..0862a40 100644
--- a/cmds/dumpsys/dumpsys.cpp
+++ b/cmds/dumpsys/dumpsys.cpp
@@ -61,7 +61,8 @@
"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"
+ " -t TIMEOUT_SEC: TIMEOUT to use in seconds instead of default 10 seconds\n"
+ " -T TIMEOUT_MS: TIMEOUT to use in milliseconds instead of default 10 seconds\n"
" --proto: filter services that support dumping data in proto format. Dumps"
" will be in proto format.\n"
" --priority LEVEL: filter services based on specified priority\n"
@@ -104,7 +105,7 @@
bool showListOnly = false;
bool skipServices = false;
bool filterByProto = false;
- int timeoutArg = 10;
+ int timeoutArgMs = 10000;
int dumpPriorityFlags = IServiceManager::DUMP_FLAG_PRIORITY_ALL;
static struct option longOptions[] = {{"priority", required_argument, 0, 0},
{"proto", no_argument, 0, 0},
@@ -119,7 +120,7 @@
int c;
int optionIndex = 0;
- c = getopt_long(argc, argv, "+t:l", longOptions, &optionIndex);
+ c = getopt_long(argc, argv, "+t:T:l", longOptions, &optionIndex);
if (c == -1) {
break;
@@ -146,10 +147,22 @@
case 't':
{
- char *endptr;
- timeoutArg = strtol(optarg, &endptr, 10);
- if (*endptr != '\0' || timeoutArg <= 0) {
- fprintf(stderr, "Error: invalid timeout number: '%s'\n", optarg);
+ char* endptr;
+ timeoutArgMs = strtol(optarg, &endptr, 10);
+ timeoutArgMs = timeoutArgMs * 1000;
+ if (*endptr != '\0' || timeoutArgMs <= 0) {
+ fprintf(stderr, "Error: invalid timeout(seconds) number: '%s'\n", optarg);
+ return -1;
+ }
+ }
+ break;
+
+ case 'T':
+ {
+ char* endptr;
+ timeoutArgMs = strtol(optarg, &endptr, 10);
+ if (*endptr != '\0' || timeoutArgMs <= 0) {
+ fprintf(stderr, "Error: invalid timeout(milliseconds) number: '%s'\n", optarg);
return -1;
}
}
@@ -269,7 +282,7 @@
}
});
- auto timeout = std::chrono::seconds(timeoutArg);
+ auto timeout = std::chrono::milliseconds(timeoutArgMs);
auto start = std::chrono::steady_clock::now();
auto end = start + timeout;
@@ -321,8 +334,8 @@
if (timed_out) {
aout << endl
- << "*** SERVICE '" << service_name << "' DUMP TIMEOUT (" << timeoutArg
- << "s) EXPIRED ***" << endl
+ << "*** SERVICE '" << service_name << "' DUMP TIMEOUT (" << timeoutArgMs
+ << "ms) EXPIRED ***" << endl
<< endl;
}