diff options
| author | 2017-11-30 23:11:49 +0000 | |
|---|---|---|
| committer | 2017-11-30 23:11:49 +0000 | |
| commit | 4f0bb193bd2c8ca88d46a8ce4aa27cb7debb34c9 (patch) | |
| tree | c24addcba1874241a258c170f9f046209d844c7d | |
| parent | 5235e10b70019af8248391f6c3cc7036c1e3658a (diff) | |
| parent | b236c86b81a1e58fce6fe576dd336764138899d0 (diff) | |
Merge "allow dump_report command to output proto binary in addition to text"
| -rw-r--r-- | cmds/statsd/src/StatsService.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp index 7eca5aa21201..9259793df2ac 100644 --- a/cmds/statsd/src/StatsService.cpp +++ b/cmds/statsd/src/StatsService.cpp @@ -284,12 +284,13 @@ void StatsService::print_cmd_help(FILE* out) { fprintf(out, "\n *Note: If both UID and NAME are omitted then all configs will\n"); fprintf(out, "\n be removed from memory and disk!\n"); fprintf(out, "\n"); - fprintf(out, "usage: adb shell cmd stats dump-report [UID] NAME\n"); + fprintf(out, "usage: adb shell cmd stats dump-report [UID] NAME [--proto]\n"); fprintf(out, " Dump all metric data for a configuration.\n"); fprintf(out, " UID The uid of the configuration. It is only possible to pass\n"); fprintf(out, " the UID parameter on eng builds. If UID is omitted the\n"); fprintf(out, " calling uid is used.\n"); fprintf(out, " NAME The name of the configuration\n"); + fprintf(out, " --proto Print proto binary.\n"); fprintf(out, "\n"); fprintf(out, "\n"); fprintf(out, "usage: adb shell cmd stats send-broadcast [UID] NAME\n"); @@ -427,10 +428,15 @@ status_t StatsService::cmd_config(FILE* in, FILE* out, FILE* err, Vector<String8 status_t StatsService::cmd_dump_report(FILE* out, FILE* err, const Vector<String8>& args) { if (mProcessor != nullptr) { - const int argCount = args.size(); + int argCount = args.size(); bool good = false; + bool proto = false; int uid; string name; + if (!std::strcmp("--proto", args[argCount-1].c_str())) { + proto = true; + argCount -= 1; + } if (argCount == 2) { // Automatically pick the UID uid = IPCThreadState::self()->getCallingUid(); @@ -460,8 +466,14 @@ status_t StatsService::cmd_dump_report(FILE* out, FILE* err, const Vector<String vector<uint8_t> data; mProcessor->onDumpReport(ConfigKey(uid, name), &data); // TODO: print the returned StatsLogReport to file instead of printing to logcat. - fprintf(out, "Dump report for Config [%d,%s]\n", uid, name.c_str()); - fprintf(out, "See the StatsLogReport in logcat...\n"); + if (proto) { + for (size_t i = 0; i < data.size(); i ++) { + fprintf(out, "%c", data[i]); + } + } else { + fprintf(out, "Dump report for Config [%d,%s]\n", uid, name.c_str()); + fprintf(out, "See the StatsLogReport in logcat...\n"); + } return android::OK; } else { // If arg parsing failed, print the help text and return an error. |