diff options
author | 2010-08-06 14:11:55 -0700 | |
---|---|---|
committer | 2010-08-06 14:58:34 -0700 | |
commit | bfb071df71af73c4d6804349d1453627db6b4661 (patch) | |
tree | f87492bba39608d895eac9d33695f170e29850ec | |
parent | 230182701c5d1dac7c092152a0c41841f5e444b7 (diff) |
Add support for playing a sound before/after dumpstate.
-rw-r--r-- | cmds/dumpstate/dumpstate.c | 21 | ||||
-rw-r--r-- | cmds/dumpstate/dumpstate.h | 3 | ||||
-rw-r--r-- | cmds/dumpstate/utils.c | 4 |
3 files changed, 22 insertions, 6 deletions
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index 1fde437a28fe..02c9cbc79059 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -167,8 +167,11 @@ static void dumpstate() { } static void usage() { - fprintf(stderr, "usage: dumpstate [-d] [-o file] [-s] [-z]\n" + fprintf(stderr, "usage: dumpstate [-b file] [-d] [-e file] [-o file] [-s] " + "[-z]\n" + " -b: play sound file instead of vibrate, at beginning of job\n" " -d: append date to filename (requires -o)\n" + " -e: play sound file instead of vibrate, at end of job\n" " -o: write to file (instead of stdout)\n" " -s: write output to control socket (for init)\n" " -z: gzip output (requires -o)\n"); @@ -178,6 +181,8 @@ int main(int argc, char *argv[]) { int do_add_date = 0; int do_compress = 0; char* use_outfile = 0; + char* begin_sound = 0; + char* end_sound = 0; int use_socket = 0; LOGI("begin\n"); @@ -194,9 +199,11 @@ int main(int argc, char *argv[]) { dump_traces_path = dump_vm_traces(); int c; - while ((c = getopt(argc, argv, "dho:svz")) != -1) { + while ((c = getopt(argc, argv, "b:de:ho:svz")) != -1) { switch (c) { + case 'b': begin_sound = optarg; break; case 'd': do_add_date = 1; break; + case 'e': end_sound = optarg; break; case 'o': use_outfile = optarg; break; case 's': use_socket = 1; break; case 'v': break; // compatibility no-op @@ -244,16 +251,18 @@ int main(int argc, char *argv[]) { gzip_pid = redirect_to_file(stdout, tmp_path, do_compress); } - /* bzzzzzz */ - if (vibrator) { + if (begin_sound) { + play_sound(begin_sound); + } else if (vibrator) { fputs("150", vibrator); fflush(vibrator); } dumpstate(); - /* bzzz bzzz bzzz */ - if (vibrator) { + if (end_sound) { + play_sound(end_sound); + } else if (vibrator) { int i; for (i = 0; i < 3; i++) { fputs("75\n", vibrator); diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h index 682eafdbab67..83b1d11c38ab 100644 --- a/cmds/dumpstate/dumpstate.h +++ b/cmds/dumpstate/dumpstate.h @@ -44,4 +44,7 @@ void for_each_pid(void (*func)(int, const char *), const char *header); /* Displays a blocked processes in-kernel wait channel */ void show_wchan(int pid, const char *name); +/* Play a sound via Stagefright */ +void play_sound(const char* path); + #endif /* _DUMPSTATE_H_ */ diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c index c7a78ccecef8..f92acbbbf332 100644 --- a/cmds/dumpstate/utils.c +++ b/cmds/dumpstate/utils.c @@ -429,3 +429,7 @@ const char *dump_vm_traces() { rename(anr_traces_path, traces_path); return dump_traces_path; } + +void play_sound(const char* path) { + run_command(NULL, 5, "/system/bin/stagefright", "-o", "-a", path, NULL); +} |