summaryrefslogtreecommitdiff
path: root/cmds/dumpstate/utils.cpp
diff options
context:
space:
mode:
author Felipe Leme <felipeal@google.com> 2015-12-04 22:24:33 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2015-12-04 22:24:33 +0000
commit114269b46ce7b9b24627d9368873aa97e4e45e5a (patch)
tree8cd4fd16bdaff475ebc86125ae56fc230895a48c /cmds/dumpstate/utils.cpp
parent789795f98b080ac24e61aea0ba3ca328c6e9bbea (diff)
parentad5f6c475934ac6a658a203069a9f055540946e7 (diff)
Merge "Minor improvements in the bugreport progress workflow:"
Diffstat (limited to 'cmds/dumpstate/utils.cpp')
-rw-r--r--cmds/dumpstate/utils.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp
index 8683155199..a7637d83e7 100644
--- a/cmds/dumpstate/utils.cpp
+++ b/cmds/dumpstate/utils.cpp
@@ -553,7 +553,7 @@ int run_command_always(const char *title, int timeout_seconds, const char *args[
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());
+ fprintf(stderr, "send_broadcast: too many arguments (%d)\n", (int) args.size());
return;
}
const char *am_args[1024] = { "/system/bin/am", "broadcast", "--user", "0",
@@ -841,6 +841,7 @@ void dump_route_tables() {
/* overall progress */
int progress = 0;
int do_update_progress = 0; // Set by dumpstate.cpp
+int weight_total = WEIGHT_TOTAL;
// TODO: make this function thread safe if sections are generated in parallel.
void update_progress(int delta) {
@@ -850,12 +851,27 @@ void update_progress(int delta) {
char key[PROPERTY_KEY_MAX];
char value[PROPERTY_VALUE_MAX];
+
+ // adjusts max on the fly
+ if (progress > weight_total) {
+ int new_total = weight_total * 1.2;
+ fprintf(stderr, "Adjusting total weight from %d to %d\n", weight_total, new_total);
+ weight_total = new_total;
+ sprintf(key, "dumpstate.%d.max", getpid());
+ sprintf(value, "%d", weight_total);
+ int status = property_set(key, value);
+ if (status) {
+ ALOGW("Could not update max weight by setting system property %s to %s: %d\n",
+ key, value, status);
+ }
+ }
+
sprintf(key, "dumpstate.%d.progress", getpid());
sprintf(value, "%d", progress);
// stderr is ignored on normal invocations, but useful when calling /system/bin/dumpstate
// directly for debuggging.
- fprintf(stderr, "Setting progress (%s): %s/%d\n", key, value, WEIGHT_TOTAL);
+ fprintf(stderr, "Setting progress (%s): %s/%d\n", key, value, weight_total);
int status = property_set(key, value);
if (status) {