Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5bcce574 authored by Felipe Leme's avatar Felipe Leme
Browse files

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
parent b0f669de
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1101,7 +1101,8 @@ static void dumpstate(const std::string& screenshot_path, const std::string& ver
    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");
+4 −1
Original line number Diff line number Diff line
@@ -274,9 +274,12 @@ int RunCommand(const char* title, const std::vector<std::string>& fullCommand,
 * |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();
+3 −3
Original line number Diff line number Diff line
@@ -894,9 +894,9 @@ int RunCommand(const char* title, const std::vector<std::string>& fullCommand,
}

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);
}