Fix dumpsys timeouts.
Both dumpstate and dumpsys can timeout when a child process hangs;
usually these values match, except when running dumpsys to dump all
services, in which case we need a timeout for all services (90s) and
individual timeouts for each service (10s).
BUG: 26379932
Test: manual
Change-Id: I37129ba9980976aa9bfe8eb132cdd0870fd93e59
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index fb508af..92c5780 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -1101,7 +1101,8 @@
printf("== Android Framework Services\n");
printf("========================================================\n");
- RunDumpsys("DUMPSYS", {"--skip", "meminfo", "cpuinfo"}, CommandOptions::WithTimeout(60).Build());
+ RunDumpsys("DUMPSYS", {"--skip", "meminfo", "cpuinfo"}, CommandOptions::WithTimeout(90).Build(),
+ 10);
printf("========================================================\n");
printf("== Checkins\n");
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index 3b7c362..d50e68c 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -274,9 +274,12 @@
* |title| description of the command printed on `stdout`.
* |dumpsys_args| `dumpsys` arguments (except `-t`).
* |options| optional argument defining the command's behavior.
+ * |dumpsysTimeout| when > 0, defines the value passed to `dumpsys -t` (otherwise it uses the
+ * timeout from `options`)
*/
void RunDumpsys(const std::string& title, const std::vector<std::string>& dumpsysArgs,
- const CommandOptions& options = CommandOptions::DEFAULT_DUMPSYS);
+ const CommandOptions& options = CommandOptions::DEFAULT_DUMPSYS,
+ long dumpsysTimeout = 0);
/* switch to non-root user and group */
bool drop_root_user();
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index f656266..1eeef51 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -894,9 +894,9 @@
}
void RunDumpsys(const std::string& title, const std::vector<std::string>& dumpsysArgs,
- const CommandOptions& options) {
- std::vector<std::string> dumpsys = {"/system/bin/dumpsys", "-t",
- std::to_string(options.Timeout())};
+ const CommandOptions& options, long dumpsysTimeout) {
+ long timeout = dumpsysTimeout > 0 ? dumpsysTimeout : options.Timeout();
+ std::vector<std::string> dumpsys = {"/system/bin/dumpsys", "-t", std::to_string(timeout)};
dumpsys.insert(dumpsys.end(), dumpsysArgs.begin(), dumpsysArgs.end());
RunCommand(title.c_str(), dumpsys, options);
}