Deprecate run_command() and dump_file().
This change will break dumpstate_board() implementations that were not
refactored to use the equivalent functions in the Dumpstate
class. For example:
void dumpstate_board() {
dump_file("INTERRUPTS", "/proc/interrupts");
run_command("SUBSYSTEM TOMBSTONES", 5, SU_PATH, "root",
"ls", "-l", "/data/tombstones/ramdump", NULL);
}
Should be refactored to:
void dumpstate_board(){
Dumpstate& ds = Dumpstate::GetInstance();
ds.DumpFile("INTERRUPTS", "/proc/interrupts");
ds.RunCommand("SUBSYSTEM TOMBSTONES",
{"ls", "-l", "/data/tombstones/ramdump"},
CommandOptions::AS_ROOT_5);
}
BUG: 26379932
Test: manual / refactored code
Change-Id: Ia74515cc57abc18bc6966a5aed71dd679422fd0e
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index d1a96c1..f3e68b3 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -367,7 +367,7 @@
if (RunCommand("SYSTRACE", {"/system/bin/atrace", "--async_dump", "-o", systrace_path},
CommandOptions::WithTimeout(120).Build())) {
MYLOGE("systrace timed out, its zip entry will be incomplete\n");
- // TODO: run_command tries to kill the process, but atrace doesn't die
+ // TODO: RunCommand tries to kill the process, but atrace doesn't die
// peacefully; ideally, we should call strace to stop itself, but there is no such option
// yet (just a --async_stop, which stops and dump
// if (RunCommand("SYSTRACE", {"/system/bin/atrace", "--kill"})) {
@@ -1621,7 +1621,7 @@
dump_iptables();
// Run ss as root so we can see socket marks.
- run_command("DETAILED SOCKET STATE", 10, "ss", "-eionptu", NULL);
+ RunCommand("DETAILED SOCKET STATE", {"ss", "-eionptu"}, CommandOptions::WithTimeout(10).Build());
if (!drop_root_user()) {
return -1;