Loading cmds/statsd/src/StatsLogProcessor.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,9 @@ const int FIELD_ID_STRINGS = 9; #define STATS_DATA_DIR "/data/misc/stats-data" // Cool down period for writing data to disk to avoid overwriting files. #define WRITE_DATA_COOL_DOWN_SEC 5 StatsLogProcessor::StatsLogProcessor(const sp<UidMap>& uidMap, const sp<AlarmMonitor>& anomalyAlarmMonitor, const sp<AlarmMonitor>& periodicAlarmMonitor, Loading Loading @@ -526,6 +529,16 @@ void StatsLogProcessor::WriteDataToDiskLocked(const ConfigKey& key, void StatsLogProcessor::WriteDataToDiskLocked(const DumpReportReason dumpReportReason) { const int64_t timeNs = getElapsedRealtimeNs(); // Do not write to disk if we already have in the last few seconds. // This is to avoid overwriting files that would have the same name if we // write twice in the same second. if (static_cast<unsigned long long> (timeNs) < mLastWriteTimeNs + WRITE_DATA_COOL_DOWN_SEC * NS_PER_SEC) { ALOGI("Statsd skipping writing data to disk. Already wrote data in last %d seconds", WRITE_DATA_COOL_DOWN_SEC); return; } mLastWriteTimeNs = timeNs; for (auto& pair : mMetricsManagers) { WriteDataToDiskLocked(pair.first, timeNs, dumpReportReason); } Loading cmds/statsd/src/StatsLogProcessor.h +5 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,8 @@ enum DumpReportReason { GET_DATA_CALLED = 4, ADB_DUMP = 5, CONFIG_RESET = 6, STATSCOMPANION_DIED = 7 STATSCOMPANION_DIED = 7, TERMINATION_SIGNAL_RECEIVED = 8 }; class StatsLogProcessor : public ConfigListener { Loading Loading @@ -183,6 +184,9 @@ private: long mLastPullerCacheClearTimeSec = 0; // Last time we wrote data to disk. int64_t mLastWriteTimeNs = 0; #ifdef VERY_VERBOSE_PRINTING bool mPrintAllLogs = false; #endif Loading cmds/statsd/src/StatsService.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -881,6 +881,13 @@ void StatsService::Startup() { mConfigManager->Startup(); } void StatsService::Terminate() { ALOGI("StatsService::Terminating"); if (mProcessor != nullptr) { mProcessor->WriteDataToDisk(TERMINATION_SIGNAL_RECEIVED); } } void StatsService::OnLogEvent(LogEvent* event, bool reconnectionStarts) { mProcessor->OnLogEvent(event, reconnectionStarts); } Loading cmds/statsd/src/StatsService.h +5 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,11 @@ public: */ void Startup(); /** * Called when terminiation signal received. */ void Terminate(); /** * Called by LogReader when there's a log event to process. */ Loading cmds/statsd/src/atoms.proto +21 −0 Original line number Diff line number Diff line Loading @@ -131,6 +131,7 @@ message Atom { PhoneServiceStateChanged phone_service_state_changed = 94; PhoneStateChanged phone_state_changed = 95; LowMemReported low_mem_reported = 81; ThermalThrottlingStateChanged thermal_throttling = 86; NetworkDnsEventReported network_dns_event_reported = 116; DataStallEvent data_stall_event = 121; BluetoothLinkLayerConnectionEvent bluetooth_link_layer_connection_event = 125; Loading Loading @@ -238,6 +239,26 @@ message AttributionNode { * ***************************************************************************** */ /** * Logs when the Thermal service HAL notifies the throttling start/stop events. * * Logged from: * frameworks/base/services/core/java/com/android/server/stats/StatsCompanionService.java */ message ThermalThrottlingStateChanged { optional android.os.TemperatureTypeEnum sensor_type = 1; enum State { UNKNOWN = 0; START = 1; STOP = 2; } optional State state = 2; optional float temperature = 3; } /** * Logs when the screen state changes. * Loading Loading
cmds/statsd/src/StatsLogProcessor.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,9 @@ const int FIELD_ID_STRINGS = 9; #define STATS_DATA_DIR "/data/misc/stats-data" // Cool down period for writing data to disk to avoid overwriting files. #define WRITE_DATA_COOL_DOWN_SEC 5 StatsLogProcessor::StatsLogProcessor(const sp<UidMap>& uidMap, const sp<AlarmMonitor>& anomalyAlarmMonitor, const sp<AlarmMonitor>& periodicAlarmMonitor, Loading Loading @@ -526,6 +529,16 @@ void StatsLogProcessor::WriteDataToDiskLocked(const ConfigKey& key, void StatsLogProcessor::WriteDataToDiskLocked(const DumpReportReason dumpReportReason) { const int64_t timeNs = getElapsedRealtimeNs(); // Do not write to disk if we already have in the last few seconds. // This is to avoid overwriting files that would have the same name if we // write twice in the same second. if (static_cast<unsigned long long> (timeNs) < mLastWriteTimeNs + WRITE_DATA_COOL_DOWN_SEC * NS_PER_SEC) { ALOGI("Statsd skipping writing data to disk. Already wrote data in last %d seconds", WRITE_DATA_COOL_DOWN_SEC); return; } mLastWriteTimeNs = timeNs; for (auto& pair : mMetricsManagers) { WriteDataToDiskLocked(pair.first, timeNs, dumpReportReason); } Loading
cmds/statsd/src/StatsLogProcessor.h +5 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,8 @@ enum DumpReportReason { GET_DATA_CALLED = 4, ADB_DUMP = 5, CONFIG_RESET = 6, STATSCOMPANION_DIED = 7 STATSCOMPANION_DIED = 7, TERMINATION_SIGNAL_RECEIVED = 8 }; class StatsLogProcessor : public ConfigListener { Loading Loading @@ -183,6 +184,9 @@ private: long mLastPullerCacheClearTimeSec = 0; // Last time we wrote data to disk. int64_t mLastWriteTimeNs = 0; #ifdef VERY_VERBOSE_PRINTING bool mPrintAllLogs = false; #endif Loading
cmds/statsd/src/StatsService.cpp +7 −0 Original line number Diff line number Diff line Loading @@ -881,6 +881,13 @@ void StatsService::Startup() { mConfigManager->Startup(); } void StatsService::Terminate() { ALOGI("StatsService::Terminating"); if (mProcessor != nullptr) { mProcessor->WriteDataToDisk(TERMINATION_SIGNAL_RECEIVED); } } void StatsService::OnLogEvent(LogEvent* event, bool reconnectionStarts) { mProcessor->OnLogEvent(event, reconnectionStarts); } Loading
cmds/statsd/src/StatsService.h +5 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,11 @@ public: */ void Startup(); /** * Called when terminiation signal received. */ void Terminate(); /** * Called by LogReader when there's a log event to process. */ Loading
cmds/statsd/src/atoms.proto +21 −0 Original line number Diff line number Diff line Loading @@ -131,6 +131,7 @@ message Atom { PhoneServiceStateChanged phone_service_state_changed = 94; PhoneStateChanged phone_state_changed = 95; LowMemReported low_mem_reported = 81; ThermalThrottlingStateChanged thermal_throttling = 86; NetworkDnsEventReported network_dns_event_reported = 116; DataStallEvent data_stall_event = 121; BluetoothLinkLayerConnectionEvent bluetooth_link_layer_connection_event = 125; Loading Loading @@ -238,6 +239,26 @@ message AttributionNode { * ***************************************************************************** */ /** * Logs when the Thermal service HAL notifies the throttling start/stop events. * * Logged from: * frameworks/base/services/core/java/com/android/server/stats/StatsCompanionService.java */ message ThermalThrottlingStateChanged { optional android.os.TemperatureTypeEnum sensor_type = 1; enum State { UNKNOWN = 0; START = 1; STOP = 2; } optional State state = 2; optional float temperature = 3; } /** * Logs when the screen state changes. * Loading