Send broadcasts as Shell.
The BUGREPORT_STARTED was being sent as root, which would cause it to
bypass Shell restrictions when DISALLOW_DEBUGGING_FEATURES is set.
Also added the missing --receiver-background and unhardcoded shell's uid
from previous changes.
BUG: 26814173
Change-Id: I867361efafb96c7e709f83806a9301afc637a27e
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 189f8ef..b183289 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -1178,7 +1178,7 @@
if (do_update_progress) {
std::vector<std::string> am_args = {
- "--receiver-permission", "android.permission.DUMP",
+ "--receiver-permission", "android.permission.DUMP", "--receiver-foreground",
"--es", "android.intent.extra.NAME", suffix,
"--ei", "android.intent.extra.PID", std::to_string(getpid()),
"--ei", "android.intent.extra.MAX", std::to_string(WEIGHT_TOTAL),
@@ -1239,8 +1239,8 @@
if (version == VERSION_DUMPSYS_SPLIT) {
// Invoking the following dumpsys calls before dump_traces() to try and
// keep the system stats as close to its initial state as possible.
- run_command("DUMPSYS MEMINFO", 30, SU_PATH, "2000", "dumpsys", "meminfo", "-a", NULL);
- run_command("DUMPSYS CPUINFO", 30, SU_PATH, "2000", "dumpsys", "cpuinfo", "-a", NULL);
+ run_command("DUMPSYS MEMINFO", 30, SU_PATH, "shell", "dumpsys", "meminfo", "-a", NULL);
+ run_command("DUMPSYS CPUINFO", 30, SU_PATH, "shell", "dumpsys", "cpuinfo", "-a", NULL);
}
/* collect stack traces from Dalvik and native processes (needs root) */
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index b301058..9d42939 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -705,9 +705,9 @@
fprintf(stderr, "send_broadcast: too many arguments (%d)\n", (int) args.size());
return;
}
- const char *am_args[1024] = { "/system/bin/am", "broadcast",
+ const char *am_args[1024] = { SU_PATH, "shell", "/system/bin/am", "broadcast",
"--user", "0", "-a", action.c_str() };
- size_t am_index = 5; // Starts at the index of last initial value above.
+ size_t am_index = 7; // Starts at the index of last initial value above.
for (const std::string& arg : args) {
am_args[++am_index] = arg.c_str();
}