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

Commit fe714f6f authored by Felipe Leme's avatar Felipe Leme
Browse files

Revert "Created functions to run dumpsys."

This reverts commit dbfe0838.

Change-Id: I488a06f3500817ff54b332d37abce3ff594f37cd
parent dbfe0838
Loading
Loading
Loading
Loading
+13 −52
Original line number Diff line number Diff line
@@ -267,45 +267,6 @@ static bool skip_none(const char *path) {
    return false;
}

static void _run_dumpsys(const std::string& title, RootMode root_mode, int timeout_seconds,
        const std::vector<std::string>& args) {
    DurationReporter duration_reporter(title.c_str());

    std::string timeout_string = std::to_string(timeout_seconds);

    const char *dumpsys_args[ARG_MAX] = { "/system/bin/dumpsys", "-t", timeout_string.c_str()};

    int index = 3; // 'dumpsys' '-t' 'TIMEOUT'
    for (const std::string& arg : args) {
        if (index > ARG_MAX - 2) {
            MYLOGE("Too many arguments for '%s': %d\n", title.c_str(), args.size());
            return;
        }
        dumpsys_args[index++] = arg.c_str();
    }
    // Always terminate with nullptr.
    dumpsys_args[index] = nullptr;

    std::string args_string;
    format_args(index, dumpsys_args, &args_string);
    printf("------ %s (%s) ------\n", title.c_str(), args_string.c_str());
    fflush(stdout);

    ON_DRY_RUN({ update_progress(timeout_seconds); return; });

    run_command_always(title.c_str(), root_mode, NORMAL_STDOUT, timeout_seconds, dumpsys_args);
}

static void run_dumpsys(const std::string& title, int timeout_seconds,
        const std::vector<std::string>& args) {
    _run_dumpsys(title, DONT_DROP_ROOT, timeout_seconds, args);
}

static void run_dumpsys_as_shell(const std::string& title, int timeout_seconds,
        const std::vector<std::string>& args) {
    _run_dumpsys(title, DROP_ROOT, timeout_seconds, args);
}

static const char mmcblk0[] = "/sys/block/mmcblk0/";
unsigned long worst_write_perf = 20000; /* in KB/s */

@@ -927,7 +888,7 @@ static void dumpstate(const std::string& screenshot_path, const std::string& ver
#endif
    dump_file("INTERRUPTS (1)", "/proc/interrupts");

    run_dumpsys("NETWORK DIAGNOSTICS", 10, {"connectivity", "--diag"});
    run_command("NETWORK DIAGNOSTICS", 10, "dumpsys", "-t", "10", "connectivity", "--diag", NULL);

#ifdef FWDUMP_bcmdhd
    run_command("DUMP WIFI STATUS", 20,
@@ -997,36 +958,36 @@ static void dumpstate(const std::string& screenshot_path, const std::string& ver
    printf("== Android Framework Services\n");
    printf("========================================================\n");

    run_dumpsys("DUMPSYS", 60, {"--skip", "meminfo", "cpuinfo"});
    run_command("DUMPSYS", 60, "dumpsys", "-t", "60", "--skip", "meminfo", "cpuinfo", NULL);

    printf("========================================================\n");
    printf("== Checkins\n");
    printf("========================================================\n");

    run_dumpsys("CHECKIN BATTERYSTATS", 30, {"batterystats", "-c"});
    run_dumpsys("CHECKIN MEMINFO", 30, {"meminfo", "--checkin"});
    run_dumpsys("CHECKIN NETSTATS", 30, {"netstats", "--checkin"});
    run_dumpsys("CHECKIN PROCSTATS", 30, {"procstats", "-c"});
    run_dumpsys("CHECKIN USAGESTATS", 30, {"usagestats", "-c"});
    run_dumpsys("CHECKIN PACKAGE", 30, {"package", "--checkin"});
    run_command("CHECKIN BATTERYSTATS", 30, "dumpsys", "-t", "30", "batterystats", "-c", NULL);
    run_command("CHECKIN MEMINFO", 30, "dumpsys", "-t", "30", "meminfo", "--checkin", NULL);
    run_command("CHECKIN NETSTATS", 30, "dumpsys", "-t", "30", "netstats", "--checkin", NULL);
    run_command("CHECKIN PROCSTATS", 30, "dumpsys", "-t", "30", "procstats", "-c", NULL);
    run_command("CHECKIN USAGESTATS", 30, "dumpsys", "-t", "30", "usagestats", "-c", NULL);
    run_command("CHECKIN PACKAGE", 30, "dumpsys", "-t", "30", "package", "--checkin", NULL);

    printf("========================================================\n");
    printf("== Running Application Activities\n");
    printf("========================================================\n");

    run_dumpsys("APP ACTIVITIES", 30, {"activity", "all"});
    run_command("APP ACTIVITIES", 30, "dumpsys", "-t", "30", "activity", "all", NULL);

    printf("========================================================\n");
    printf("== Running Application Services\n");
    printf("========================================================\n");

    run_dumpsys("APP SERVICES", 30, {"activity", "service", "all"});
    run_command("APP SERVICES", 30, "dumpsys", "-t", "30", "activity", "service", "all", NULL);

    printf("========================================================\n");
    printf("== Running Application Providers\n");
    printf("========================================================\n");

    run_dumpsys("APP PROVIDERS", 30, {"activity", "provider", "all"});
    run_command("APP PROVIDERS", 30, "dumpsys", "-t", "30", "activity", "provider", "all", NULL);


    printf("========================================================\n");
@@ -1402,8 +1363,8 @@ int main(int argc, char *argv[]) {

    // Invoking the following dumpsys calls before dump_traces() to try and
    // keep the system stats as close to its initial state as possible.
    run_dumpsys_as_shell("DUMPSYS MEMINFO", 90, {"meminfo", "-a"});
    run_dumpsys_as_shell("DUMPSYS CPUINFO", 10, {"cpuinfo", "-a"});
    run_command_as_shell("DUMPSYS MEMINFO", 90, "dumpsys", "-t", "90", "meminfo", "-a", NULL);
    run_command_as_shell("DUMPSYS CPUINFO", 10, "dumpsys", "-t", "10", "cpuinfo", "-a", NULL);

    /* collect stack traces from Dalvik and native processes (needs root) */
    dump_traces_path = dump_traces();
+6 −10
Original line number Diff line number Diff line
@@ -644,7 +644,7 @@ int run_command(const char *title, int timeout_seconds, const char *command, ...
    DurationReporter duration_reporter(title);
    fflush(stdout);

    const char *args[ARG_MAX] = {command};
    const char *args[1024] = {command};
    size_t arg;
    va_list ap;
    va_start(ap, command);
@@ -682,7 +682,7 @@ int run_command_as_shell(const char *title, int timeout_seconds, const char *com
    DurationReporter duration_reporter(title);
    fflush(stdout);

    const char *args[ARG_MAX] = {command};
    const char *args[1024] = {command};
    size_t arg;
    va_list ap;
    va_start(ap, command);
@@ -871,18 +871,14 @@ void send_broadcast(const std::string& action, const std::vector<std::string>& a
        MYLOGE("send_broadcast: too many arguments (%d)\n", (int) args.size());
        return;
    }
    const char *am_args[ARG_MAX] = { "/system/bin/am", "broadcast", "--user", "0", "-a",
    const char *am_args[1024] = { "/system/bin/am", "broadcast", "--user", "0", "-a",
                                  action.c_str() };
    size_t am_index = 5; // Starts at the index of last initial value above.
    for (const std::string& arg : args) {
        if (am_index > ARG_MAX - 2) {
            MYLOGE("send_broadcast: too many arguments (%d)\n", args.size());
            return;
        }
        am_args[++am_index] = arg.c_str();
    }
    // Always terminate with nullptr.
    am_args[am_index + 1] = nullptr;
    // Always terminate with NULL.
    am_args[am_index + 1] = NULL;
    std::string args_string;
    format_args(am_index + 1, am_args, &args_string);
    MYLOGD("send_broadcast command: %s\n", args_string.c_str());