diff options
| author | 2018-06-07 15:50:46 -0700 | |
|---|---|---|
| committer | 2018-06-07 15:50:46 -0700 | |
| commit | a11cbf368b03fbf245cb19c09f41d432288fe10c (patch) | |
| tree | 2d1f16c63537538482f827612e333afa98be5470 | |
| parent | 1a8ca4a1a42c3e97daba2ff882fc81a87f47141e (diff) | |
| parent | 39c8fe12e49b4a6033385c54ba1fef862326b79b (diff) | |
Merge "Disable statsd and make StatsLog no-op if ro.statsd.enable=false" into pi-dev am: 38b92986df
am: 39c8fe12e4
Change-Id: Ie27a0d43da9fa0eb0c751cafa3f04220a5f8f18a
| -rw-r--r-- | cmds/statsd/statsd.rc | 3 | ||||
| -rw-r--r-- | tools/stats_log_api_gen/Android.bp | 1 | ||||
| -rw-r--r-- | tools/stats_log_api_gen/main.cpp | 12 |
3 files changed, 15 insertions, 1 deletions
diff --git a/cmds/statsd/statsd.rc b/cmds/statsd/statsd.rc index f3492920940d..cbf2a8d5383d 100644 --- a/cmds/statsd/statsd.rc +++ b/cmds/statsd/statsd.rc @@ -19,6 +19,9 @@ service statsd /system/bin/statsd group statsd log writepid /dev/cpuset/system-background/tasks +on property:ro.statsd.enable=false + stop statsd + on post-fs-data # Create directory for statsd mkdir /data/misc/stats-data/ 0770 statsd system diff --git a/tools/stats_log_api_gen/Android.bp b/tools/stats_log_api_gen/Android.bp index 280afadebc0f..703a67b791be 100644 --- a/tools/stats_log_api_gen/Android.bp +++ b/tools/stats_log_api_gen/Android.bp @@ -106,6 +106,7 @@ cc_library_shared { shared_libs: [ "liblog", "libutils", + "libcutils", ], static_libs: ["libstatssocket"], } diff --git a/tools/stats_log_api_gen/main.cpp b/tools/stats_log_api_gen/main.cpp index 1f13cc274efa..e519909aa026 100644 --- a/tools/stats_log_api_gen/main.cpp +++ b/tools/stats_log_api_gen/main.cpp @@ -104,6 +104,7 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms, fprintf(out, "#include <mutex>\n"); fprintf(out, "#include <chrono>\n"); fprintf(out, "#include <thread>\n"); + fprintf(out, "#include <cutils/properties.h>\n"); fprintf(out, "#include <stats_event_list.h>\n"); fprintf(out, "#include <log/log.h>\n"); fprintf(out, "#include <statslog.h>\n"); @@ -114,6 +115,7 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms, fprintf(out, "namespace util {\n"); fprintf(out, "// the single event tag id for all stats logs\n"); fprintf(out, "const static int kStatsEventTag = 1937006964;\n"); + fprintf(out, "const static bool kStatsdEnabled = property_get_bool(\"ro.statsd.enable\", true);\n"); std::set<string> kTruncatingAtomNames = {"mobile_radio_power_state_changed", "audio_state_changed", @@ -242,6 +244,7 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms, fprintf(out, "{\n"); argIndex = 1; + fprintf(out, " if (kStatsdEnabled) {\n"); fprintf(out, " stats_event_list event(kStatsEventTag);\n"); fprintf(out, " event << android::elapsedRealtimeNano();\n\n"); fprintf(out, " event << code;\n\n"); @@ -286,6 +289,9 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms, } fprintf(out, " return event.write(LOG_ID_STATS);\n"); + fprintf(out, " } else {\n"); + fprintf(out, " return 1;\n"); + fprintf(out, " }\n"); fprintf(out, "}\n"); fprintf(out, "\n"); } @@ -375,6 +381,7 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms, fprintf(out, "{\n"); argIndex = 1; + fprintf(out, " if (kStatsdEnabled) {\n"); fprintf(out, " stats_event_list event(kStatsEventTag);\n"); fprintf(out, " event << android::elapsedRealtimeNano();\n\n"); fprintf(out, " event << code;\n\n"); @@ -398,6 +405,9 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms, } fprintf(out, " return event.write(LOG_ID_STATS);\n"); + fprintf(out, " } else {\n"); + fprintf(out, " return 1;\n"); + fprintf(out, " }\n"); fprintf(out, "}\n"); fprintf(out, "\n"); } @@ -1261,4 +1271,4 @@ main(int argc, char const*const* argv) GOOGLE_PROTOBUF_VERIFY_VERSION; return android::stats_log_api_gen::run(argc, argv); -}
\ No newline at end of file +} |