Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a11cbf36 authored by Yao Chen's avatar Yao Chen Committed by android-build-merger
Browse files

Merge "Disable statsd and make StatsLog no-op if ro.statsd.enable=false" into pi-dev am: 38b92986

am: 39c8fe12

Change-Id: Ie27a0d43da9fa0eb0c751cafa3f04220a5f8f18a
parents 1a8ca4a1 39c8fe12
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ cc_library_shared {
    shared_libs: [
        "liblog",
        "libutils",
        "libcutils",
    ],
    static_libs: ["libstatssocket"],
}
+11 −1
Original line number Diff line number Diff line
@@ -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");
    }