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) */