Loading cmds/dumpstate/dumpstate.cpp +13 −9 Original line number Original line Diff line number Diff line Loading @@ -601,7 +601,7 @@ static void usage() { " -b: play sound file instead of vibrate, at beginning of job\n" " -b: play sound file instead of vibrate, at beginning of job\n" " -e: play sound file instead of vibrate, at end of job\n" " -e: play sound file instead of vibrate, at end of job\n" " -q: disable vibrate\n" " -q: disable vibrate\n" " -B: send broadcast when finished (requires -o and -p)\n" " -B: send broadcast when finished (requires -o)\n" ); ); } } Loading Loading @@ -729,7 +729,7 @@ int main(int argc, char *argv[]) { } } } } if ((do_zip_file || do_add_date) && !use_outfile) { if ((do_zip_file || do_add_date || do_broadcast) && !use_outfile) { usage(); usage(); exit(1); exit(1); } } Loading Loading @@ -870,15 +870,19 @@ int main(int argc, char *argv[]) { } } /* tell activity manager we're done */ /* tell activity manager we're done */ if (do_broadcast && use_outfile && do_fb) { if (do_broadcast && use_outfile) { if (!path.empty()) { if (!path.empty()) { ALOGI("Final bugreport path: %s\n", path.c_str()); ALOGI("Final bugreport path: %s\n", path.c_str()); const char *args[] = { "/system/bin/am", "broadcast", "--user", "0", std::vector<std::string> am_args = { "-a", "android.intent.action.BUGREPORT_FINISHED", "--receiver-permission", "android.permission.DUMP", "--es", "android.intent.extra.BUGREPORT", path.c_str(), "--es", "android.intent.extra.BUGREPORT", path "--es", "android.intent.extra.SCREENSHOT", screenshot_path.c_str(), }; "--receiver-permission", "android.permission.DUMP", NULL }; if (do_fb) { run_command_always(NULL, 5, args); am_args.push_back("--es"); am_args.push_back("android.intent.extra.SCREENSHOT"); am_args.push_back(screenshot_path); } send_broadcast("android.intent.action.BUGREPORT_FINISHED", am_args); } else { } else { ALOGE("Skipping broadcast because bugreport could not be generated\n"); ALOGE("Skipping broadcast because bugreport could not be generated\n"); } } Loading cmds/dumpstate/dumpstate.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,7 @@ #include <unistd.h> #include <unistd.h> #include <stdbool.h> #include <stdbool.h> #include <stdio.h> #include <stdio.h> #include <vector> #define SU_PATH "/system/xbin/su" #define SU_PATH "/system/xbin/su" Loading Loading @@ -70,6 +71,9 @@ int run_command(const char *title, int timeout_seconds, const char *command, ... command is always ran, even when _DUMPSTATE_DRY_RUN_ is defined. */ command is always ran, even when _DUMPSTATE_DRY_RUN_ is defined. */ int run_command_always(const char *title, int timeout_seconds, const char *args[]); int run_command_always(const char *title, int timeout_seconds, const char *args[]); /* sends a broadcast using Activity Manager */ void send_broadcast(const std::string& action, const std::vector<std::string>& args); /* prints all the system properties */ /* prints all the system properties */ void print_properties(); void print_properties(); Loading cmds/dumpstate/utils.cpp +19 −1 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <stdarg.h> #include <stdarg.h> #include <stdio.h> #include <stdio.h> #include <stdlib.h> #include <stdlib.h> #include <string> #include <string.h> #include <string.h> #include <sys/inotify.h> #include <sys/inotify.h> #include <sys/stat.h> #include <sys/stat.h> Loading @@ -31,6 +32,7 @@ #include <sys/klog.h> #include <sys/klog.h> #include <time.h> #include <time.h> #include <unistd.h> #include <unistd.h> #include <vector> #include <sys/prctl.h> #include <sys/prctl.h> #include <cutils/debugger.h> #include <cutils/debugger.h> Loading Loading @@ -477,8 +479,8 @@ int run_command(const char *title, int timeout_seconds, const char *command, ... /* forks a command and waits for it to finish */ /* forks a command and waits for it to finish */ int run_command_always(const char *title, int timeout_seconds, const char *args[]) { int run_command_always(const char *title, int timeout_seconds, const char *args[]) { const char *command = args[0]; const char *command = args[0]; uint64_t start = nanotime(); uint64_t start = nanotime(); pid_t pid = fork(); pid_t pid = fork(); Loading Loading @@ -538,6 +540,22 @@ int run_command_always(const char *title, int timeout_seconds, const char *args[ return status; return status; } } void send_broadcast(const std::string& action, const std::vector<std::string>& args) { if (args.size() > 1000) { fprintf(stderr, "send_broadcast: too many arguments (%d)\n", args.size()); return; } 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) { am_args[++am_index] = arg.c_str(); } // Always terminate with NULL. am_args[am_index + 1] = NULL; run_command_always(NULL, 5, am_args); } size_t num_props = 0; size_t num_props = 0; static char* props[2000]; static char* props[2000]; Loading Loading
cmds/dumpstate/dumpstate.cpp +13 −9 Original line number Original line Diff line number Diff line Loading @@ -601,7 +601,7 @@ static void usage() { " -b: play sound file instead of vibrate, at beginning of job\n" " -b: play sound file instead of vibrate, at beginning of job\n" " -e: play sound file instead of vibrate, at end of job\n" " -e: play sound file instead of vibrate, at end of job\n" " -q: disable vibrate\n" " -q: disable vibrate\n" " -B: send broadcast when finished (requires -o and -p)\n" " -B: send broadcast when finished (requires -o)\n" ); ); } } Loading Loading @@ -729,7 +729,7 @@ int main(int argc, char *argv[]) { } } } } if ((do_zip_file || do_add_date) && !use_outfile) { if ((do_zip_file || do_add_date || do_broadcast) && !use_outfile) { usage(); usage(); exit(1); exit(1); } } Loading Loading @@ -870,15 +870,19 @@ int main(int argc, char *argv[]) { } } /* tell activity manager we're done */ /* tell activity manager we're done */ if (do_broadcast && use_outfile && do_fb) { if (do_broadcast && use_outfile) { if (!path.empty()) { if (!path.empty()) { ALOGI("Final bugreport path: %s\n", path.c_str()); ALOGI("Final bugreport path: %s\n", path.c_str()); const char *args[] = { "/system/bin/am", "broadcast", "--user", "0", std::vector<std::string> am_args = { "-a", "android.intent.action.BUGREPORT_FINISHED", "--receiver-permission", "android.permission.DUMP", "--es", "android.intent.extra.BUGREPORT", path.c_str(), "--es", "android.intent.extra.BUGREPORT", path "--es", "android.intent.extra.SCREENSHOT", screenshot_path.c_str(), }; "--receiver-permission", "android.permission.DUMP", NULL }; if (do_fb) { run_command_always(NULL, 5, args); am_args.push_back("--es"); am_args.push_back("android.intent.extra.SCREENSHOT"); am_args.push_back(screenshot_path); } send_broadcast("android.intent.action.BUGREPORT_FINISHED", am_args); } else { } else { ALOGE("Skipping broadcast because bugreport could not be generated\n"); ALOGE("Skipping broadcast because bugreport could not be generated\n"); } } Loading
cmds/dumpstate/dumpstate.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,7 @@ #include <unistd.h> #include <unistd.h> #include <stdbool.h> #include <stdbool.h> #include <stdio.h> #include <stdio.h> #include <vector> #define SU_PATH "/system/xbin/su" #define SU_PATH "/system/xbin/su" Loading Loading @@ -70,6 +71,9 @@ int run_command(const char *title, int timeout_seconds, const char *command, ... command is always ran, even when _DUMPSTATE_DRY_RUN_ is defined. */ command is always ran, even when _DUMPSTATE_DRY_RUN_ is defined. */ int run_command_always(const char *title, int timeout_seconds, const char *args[]); int run_command_always(const char *title, int timeout_seconds, const char *args[]); /* sends a broadcast using Activity Manager */ void send_broadcast(const std::string& action, const std::vector<std::string>& args); /* prints all the system properties */ /* prints all the system properties */ void print_properties(); void print_properties(); Loading
cmds/dumpstate/utils.cpp +19 −1 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <stdarg.h> #include <stdarg.h> #include <stdio.h> #include <stdio.h> #include <stdlib.h> #include <stdlib.h> #include <string> #include <string.h> #include <string.h> #include <sys/inotify.h> #include <sys/inotify.h> #include <sys/stat.h> #include <sys/stat.h> Loading @@ -31,6 +32,7 @@ #include <sys/klog.h> #include <sys/klog.h> #include <time.h> #include <time.h> #include <unistd.h> #include <unistd.h> #include <vector> #include <sys/prctl.h> #include <sys/prctl.h> #include <cutils/debugger.h> #include <cutils/debugger.h> Loading Loading @@ -477,8 +479,8 @@ int run_command(const char *title, int timeout_seconds, const char *command, ... /* forks a command and waits for it to finish */ /* forks a command and waits for it to finish */ int run_command_always(const char *title, int timeout_seconds, const char *args[]) { int run_command_always(const char *title, int timeout_seconds, const char *args[]) { const char *command = args[0]; const char *command = args[0]; uint64_t start = nanotime(); uint64_t start = nanotime(); pid_t pid = fork(); pid_t pid = fork(); Loading Loading @@ -538,6 +540,22 @@ int run_command_always(const char *title, int timeout_seconds, const char *args[ return status; return status; } } void send_broadcast(const std::string& action, const std::vector<std::string>& args) { if (args.size() > 1000) { fprintf(stderr, "send_broadcast: too many arguments (%d)\n", args.size()); return; } 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) { am_args[++am_index] = arg.c_str(); } // Always terminate with NULL. am_args[am_index + 1] = NULL; run_command_always(NULL, 5, am_args); } size_t num_props = 0; size_t num_props = 0; static char* props[2000]; static char* props[2000]; Loading