Loading cmds/dumpstate/dumpstate.cpp +37 −4 Original line number Original line Diff line number Diff line Loading @@ -57,6 +57,9 @@ using android::base::StringPrintf; static char cmdline_buf[16384] = "(unknown)"; static char cmdline_buf[16384] = "(unknown)"; static const char *dump_traces_path = NULL; static const char *dump_traces_path = NULL; // Command-line arguments as string static std::string args; // TODO: variables below should be part of dumpstate object // TODO: variables below should be part of dumpstate object static unsigned long id; static unsigned long id; static char build_type[PROPERTY_VALUE_MAX]; static char build_type[PROPERTY_VALUE_MAX]; Loading @@ -69,6 +72,7 @@ int control_socket_fd = -1; * although it could be changed by the user using a system property */ * although it could be changed by the user using a system property */ static std::string suffix; static std::string suffix; static bool dry_run = false; static bool dry_run = false; static char extra_options[PROPERTY_VALUE_MAX]; #define PSTORE_LAST_KMSG "/sys/fs/pstore/console-ramoops" #define PSTORE_LAST_KMSG "/sys/fs/pstore/console-ramoops" #define ALT_PSTORE_LAST_KMSG "/sys/fs/pstore/console-ramoops-0" #define ALT_PSTORE_LAST_KMSG "/sys/fs/pstore/console-ramoops-0" Loading Loading @@ -104,6 +108,8 @@ std::string bugreport_dir; */ */ static std::string VERSION_DEFAULT = "1.0"; static std::string VERSION_DEFAULT = "1.0"; static constexpr char PROPERTY_EXTRA_OPTIONS[] = "dumpstate.options"; bool is_user_build() { bool is_user_build() { return 0 == strncmp(build_type, "user", PROPERTY_VALUE_MAX - 1); return 0 == strncmp(build_type, "user", PROPERTY_VALUE_MAX - 1); } } Loading Loading @@ -702,7 +708,8 @@ static void print_header(std::string version) { dumpFile(nullptr, "/proc/version"); dumpFile(nullptr, "/proc/version"); printf("Command line: %s\n", strtok(cmdline_buf, "\n")); printf("Command line: %s\n", strtok(cmdline_buf, "\n")); printf("Bugreport format version: %s\n", version.c_str()); printf("Bugreport format version: %s\n", version.c_str()); printf("Dumpstate info: id=%lu pid=%d dry_run=%d\n", id, getpid(), dry_run); printf("Dumpstate info: id=%lu pid=%d dry_run=%d args=%s extra_options=%s\n", id, getpid(), dry_run, args.c_str(), extra_options); printf("\n"); printf("\n"); } } Loading Loading @@ -1293,12 +1300,16 @@ int main(int argc, char *argv[]) { MYLOGI("Running on dry-run mode (to disable it, call 'setprop dumpstate.dry_run false')\n"); MYLOGI("Running on dry-run mode (to disable it, call 'setprop dumpstate.dry_run false')\n"); } } std::string args; // TODO: use helper function to convert argv into a string for (int i = 0; i < argc; i++) { for (int i = 0; i < argc; i++) { args += argv[i]; args += argv[i]; if (i < argc - 1) { args += " "; args += " "; } } MYLOGD("Dumpstate command line: %s\n", args.c_str()); } property_get(PROPERTY_EXTRA_OPTIONS, extra_options, ""); MYLOGI("Dumpstate args: %s (extra options: %s)\n", args.c_str(), extra_options); /* gets the sequential id */ /* gets the sequential id */ char last_id[PROPERTY_VALUE_MAX]; char last_id[PROPERTY_VALUE_MAX]; Loading Loading @@ -1347,6 +1358,28 @@ int main(int argc, char *argv[]) { } } } } if (strlen(extra_options) > 0) { // Framework uses a system property to override some command-line args. // Currently, it contains the type of the requested bugreport. if (strcmp(extra_options, "bugreportplus") == 0) { MYLOGD("Running as bugreportplus: add -P, remove -p\n"); do_update_progress = 1; do_fb = 0; } else if (strcmp(extra_options, "bugreportremote") == 0) { MYLOGD("Running as bugreportremote: add -q -R, remove -p\n"); do_vibrate = 0; is_remote_mode = 1; do_fb = 0; } else if (strcmp(extra_options, "bugreportwear") == 0) { MYLOGD("Running as bugreportwear: add -P\n"); do_update_progress = 1; } else { MYLOGE("Unknown extra option: %s\n", extra_options); } // Reset the property property_set(PROPERTY_EXTRA_OPTIONS, ""); } if ((do_zip_file || do_add_date || do_update_progress || do_broadcast) && !use_outfile) { if ((do_zip_file || do_add_date || do_update_progress || do_broadcast) && !use_outfile) { usage(); usage(); exit(1); exit(1); Loading cmds/dumpstate/dumpstate.rc +0 −29 Original line number Original line Diff line number Diff line Loading @@ -17,32 +17,3 @@ service dumpstatez /system/bin/dumpstate -S -d -z \ class main class main disabled disabled oneshot oneshot # bugreportplus is an enhanced version of bugreport that provides a better # user interface (like displaying progress and allowing user to enter details). # It's typically triggered by the power button or developer settings. service bugreportplus /system/bin/dumpstate -d -B -P -z \ -o /data/user_de/0/com.android.shell/files/bugreports/bugreport class main disabled oneshot # bugreportremote is an altered version of bugreport that is supposed to be # called not by human user of the device, but by DevicePolicyManagerService only when the # Device Owner explicitly requests it, and shared with the Device Policy Controller (DPC) app only # if the user consents # it will disable vibrations, screenshot taking and will not track progress or # allow user to enter any details service bugreportremote /system/bin/dumpstate -d -q -B -R -z \ -o /data/user_de/0/com.android.shell/files/bugreports/remote/bugreport class main disabled oneshot # bugreportwear is a wearable version of bugreport that displays progress and takes early # screenshot. service bugreportwear /system/bin/dumpstate -d -B -P -p -z \ -o /data/user_de/0/com.android.shell/files/bugreports/bugreport class main disabled oneshot Loading
cmds/dumpstate/dumpstate.cpp +37 −4 Original line number Original line Diff line number Diff line Loading @@ -57,6 +57,9 @@ using android::base::StringPrintf; static char cmdline_buf[16384] = "(unknown)"; static char cmdline_buf[16384] = "(unknown)"; static const char *dump_traces_path = NULL; static const char *dump_traces_path = NULL; // Command-line arguments as string static std::string args; // TODO: variables below should be part of dumpstate object // TODO: variables below should be part of dumpstate object static unsigned long id; static unsigned long id; static char build_type[PROPERTY_VALUE_MAX]; static char build_type[PROPERTY_VALUE_MAX]; Loading @@ -69,6 +72,7 @@ int control_socket_fd = -1; * although it could be changed by the user using a system property */ * although it could be changed by the user using a system property */ static std::string suffix; static std::string suffix; static bool dry_run = false; static bool dry_run = false; static char extra_options[PROPERTY_VALUE_MAX]; #define PSTORE_LAST_KMSG "/sys/fs/pstore/console-ramoops" #define PSTORE_LAST_KMSG "/sys/fs/pstore/console-ramoops" #define ALT_PSTORE_LAST_KMSG "/sys/fs/pstore/console-ramoops-0" #define ALT_PSTORE_LAST_KMSG "/sys/fs/pstore/console-ramoops-0" Loading Loading @@ -104,6 +108,8 @@ std::string bugreport_dir; */ */ static std::string VERSION_DEFAULT = "1.0"; static std::string VERSION_DEFAULT = "1.0"; static constexpr char PROPERTY_EXTRA_OPTIONS[] = "dumpstate.options"; bool is_user_build() { bool is_user_build() { return 0 == strncmp(build_type, "user", PROPERTY_VALUE_MAX - 1); return 0 == strncmp(build_type, "user", PROPERTY_VALUE_MAX - 1); } } Loading Loading @@ -702,7 +708,8 @@ static void print_header(std::string version) { dumpFile(nullptr, "/proc/version"); dumpFile(nullptr, "/proc/version"); printf("Command line: %s\n", strtok(cmdline_buf, "\n")); printf("Command line: %s\n", strtok(cmdline_buf, "\n")); printf("Bugreport format version: %s\n", version.c_str()); printf("Bugreport format version: %s\n", version.c_str()); printf("Dumpstate info: id=%lu pid=%d dry_run=%d\n", id, getpid(), dry_run); printf("Dumpstate info: id=%lu pid=%d dry_run=%d args=%s extra_options=%s\n", id, getpid(), dry_run, args.c_str(), extra_options); printf("\n"); printf("\n"); } } Loading Loading @@ -1293,12 +1300,16 @@ int main(int argc, char *argv[]) { MYLOGI("Running on dry-run mode (to disable it, call 'setprop dumpstate.dry_run false')\n"); MYLOGI("Running on dry-run mode (to disable it, call 'setprop dumpstate.dry_run false')\n"); } } std::string args; // TODO: use helper function to convert argv into a string for (int i = 0; i < argc; i++) { for (int i = 0; i < argc; i++) { args += argv[i]; args += argv[i]; if (i < argc - 1) { args += " "; args += " "; } } MYLOGD("Dumpstate command line: %s\n", args.c_str()); } property_get(PROPERTY_EXTRA_OPTIONS, extra_options, ""); MYLOGI("Dumpstate args: %s (extra options: %s)\n", args.c_str(), extra_options); /* gets the sequential id */ /* gets the sequential id */ char last_id[PROPERTY_VALUE_MAX]; char last_id[PROPERTY_VALUE_MAX]; Loading Loading @@ -1347,6 +1358,28 @@ int main(int argc, char *argv[]) { } } } } if (strlen(extra_options) > 0) { // Framework uses a system property to override some command-line args. // Currently, it contains the type of the requested bugreport. if (strcmp(extra_options, "bugreportplus") == 0) { MYLOGD("Running as bugreportplus: add -P, remove -p\n"); do_update_progress = 1; do_fb = 0; } else if (strcmp(extra_options, "bugreportremote") == 0) { MYLOGD("Running as bugreportremote: add -q -R, remove -p\n"); do_vibrate = 0; is_remote_mode = 1; do_fb = 0; } else if (strcmp(extra_options, "bugreportwear") == 0) { MYLOGD("Running as bugreportwear: add -P\n"); do_update_progress = 1; } else { MYLOGE("Unknown extra option: %s\n", extra_options); } // Reset the property property_set(PROPERTY_EXTRA_OPTIONS, ""); } if ((do_zip_file || do_add_date || do_update_progress || do_broadcast) && !use_outfile) { if ((do_zip_file || do_add_date || do_update_progress || do_broadcast) && !use_outfile) { usage(); usage(); exit(1); exit(1); Loading
cmds/dumpstate/dumpstate.rc +0 −29 Original line number Original line Diff line number Diff line Loading @@ -17,32 +17,3 @@ service dumpstatez /system/bin/dumpstate -S -d -z \ class main class main disabled disabled oneshot oneshot # bugreportplus is an enhanced version of bugreport that provides a better # user interface (like displaying progress and allowing user to enter details). # It's typically triggered by the power button or developer settings. service bugreportplus /system/bin/dumpstate -d -B -P -z \ -o /data/user_de/0/com.android.shell/files/bugreports/bugreport class main disabled oneshot # bugreportremote is an altered version of bugreport that is supposed to be # called not by human user of the device, but by DevicePolicyManagerService only when the # Device Owner explicitly requests it, and shared with the Device Policy Controller (DPC) app only # if the user consents # it will disable vibrations, screenshot taking and will not track progress or # allow user to enter any details service bugreportremote /system/bin/dumpstate -d -q -B -R -z \ -o /data/user_de/0/com.android.shell/files/bugreports/remote/bugreport class main disabled oneshot # bugreportwear is a wearable version of bugreport that displays progress and takes early # screenshot. service bugreportwear /system/bin/dumpstate -d -B -P -p -z \ -o /data/user_de/0/com.android.shell/files/bugreports/bugreport class main disabled oneshot