Add log source filtering in statsd to filter out spams.
+ Add log source whitelist in StatsdConfig
+ Some changes in UidMap API. Listener needs to be wp instead of sp.
+ Update dogfood app config to have log source
+ Increase the stats service thread pool size to 10 (9+1).
TODO: add unit tests(b/70805664). This unit test takes some time to write.
Test: statsd_test & manual
Change-Id: I129b1cc13db5114db7417580962bd7cc4438519d
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp
index 4dd2539..dab3880 100644
--- a/cmds/statsd/src/StatsService.cpp
+++ b/cmds/statsd/src/StatsService.cpp
@@ -201,7 +201,7 @@
}
if (!args[0].compare(String8("print-uid-map"))) {
- return cmd_print_uid_map(out);
+ return cmd_print_uid_map(out, args);
}
if (!args[0].compare(String8("dump-report"))) {
@@ -248,9 +248,10 @@
fprintf(out, " # adb shell start\n");
fprintf(out, "\n");
fprintf(out, "\n");
- fprintf(out, "usage: adb shell cmd stats print-uid-map \n");
+ fprintf(out, "usage: adb shell cmd stats print-uid-map [PKG]\n");
fprintf(out, "\n");
fprintf(out, " Prints the UID, app name, version mapping.\n");
+ fprintf(out, " PKG Optional package name to print the uids of the package\n");
fprintf(out, "\n");
fprintf(out, "\n");
fprintf(out, "usage: adb shell cmd stats pull-source [int] \n");
@@ -497,8 +498,19 @@
return NO_ERROR;
}
-status_t StatsService::cmd_print_uid_map(FILE* out) {
- mUidMap->printUidMap(out);
+status_t StatsService::cmd_print_uid_map(FILE* out, const Vector<String8>& args) {
+ if (args.size() > 1) {
+ string pkg;
+ pkg.assign(args[1].c_str(), args[1].size());
+ auto uids = mUidMap->getAppUid(pkg);
+ fprintf(out, "%s -> [ ", pkg.c_str());
+ for (const auto& uid : uids) {
+ fprintf(out, "%d ", uid);
+ }
+ fprintf(out, "]\n");
+ } else {
+ mUidMap->printUidMap(out);
+ }
return NO_ERROR;
}