summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYao Chen <yaochen@google.com>2018-06-07 21:10:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-06-07 21:10:16 +0000
commit38b92986dfc42fe8a81365e5c51498d2959865f9 (patch)
treeed061c354d61ae55019c2aad21d17c9d8b8e2da4
parente752b75dadbae20ab28d6e75e342707288e09fd3 (diff)
parentcf3829a69685b6e976c0e747467859190342a0eb (diff)
downloadbase-38b92986dfc42fe8a81365e5c51498d2959865f9.tar.gz
Merge "Disable statsd and make StatsLog no-op if ro.statsd.enable=false" into pi-dev
-rw-r--r--cmds/statsd/statsd.rc3
-rw-r--r--tools/stats_log_api_gen/Android.bp1
-rw-r--r--tools/stats_log_api_gen/main.cpp12
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 638549d395b3..140653a490e1 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");
}
@@ -1193,4 +1203,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
+}