statsd: implement Speech DSP stat report
Bug: 122719904
Test: manual stats_client test and check the statsd logs
Change-Id: I3dac9f31f59e6f10393c97c6bd9ca0d0ccb11e23
Signed-off-by: Carter Hsu <carterhsu@google.com>
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp
index 820da55..4434e07 100644
--- a/cmds/statsd/src/StatsService.cpp
+++ b/cmds/statsd/src/StatsService.cpp
@@ -1097,6 +1097,14 @@
return hardware::Void();
}
+hardware::Return<void> StatsService::reportSpeechDspStat(
+ const SpeechDspStat& speechDspStat) {
+ LogEvent event(getWallClockSec() * NS_PER_SEC, getElapsedRealtimeNs(), speechDspStat);
+ mProcessor->OnLogEvent(&event);
+
+ return hardware::Void();
+}
+
void StatsService::binderDied(const wp <IBinder>& who) {
ALOGW("statscompanion service died");
StatsdStats::getInstance().noteSystemServerRestart(getWallClockSec());
diff --git a/cmds/statsd/src/StatsService.h b/cmds/statsd/src/StatsService.h
index e9b3d4f..04b5a11 100644
--- a/cmds/statsd/src/StatsService.h
+++ b/cmds/statsd/src/StatsService.h
@@ -205,6 +205,12 @@
virtual Return<void> reportUsbPortOverheatEvent(
const UsbPortOverheatEvent& usbPortOverheatEvent) override;
+ /**
+ * Binder call to get Speech DSP state atom.
+ */
+ virtual Return<void> reportSpeechDspStat(
+ const SpeechDspStat& speechDspStat) override;
+
/** IBinder::DeathRecipient */
virtual void binderDied(const wp<IBinder>& who) override;
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 60b2e25..5a6c08d 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -206,6 +206,7 @@
BroadcastDispatchLatencyReported broadcast_dispatch_latency_reported = 142;
AttentionManagerServiceResultReported attention_manager_service_result_reported = 143;
AdbConnectionChanged adb_connection_changed = 144;
+ SpeechDspStatReported speech_dsp_stat_reported = 145;
}
// Pulled events will start at field 10000.
@@ -4521,3 +4522,18 @@
// True if the 'always allow' option was selected for this system.
optional bool always_allow = 4;
}
+
+/*
+ * Logs the reported speech DSP status.
+ *
+ * Logged from:
+ * Vendor audio implementation.
+ */
+message SpeechDspStatReported {
+ // The total Speech DSP uptime in milliseconds.
+ optional int32 total_uptime_millis = 1;
+ // The total Speech DSP downtime in milliseconds.
+ optional int32 total_downtime_millis = 2;
+ optional int32 total_crash_count = 3;
+ optional int32 total_recover_count = 4;
+}
diff --git a/cmds/statsd/src/logd/LogEvent.cpp b/cmds/statsd/src/logd/LogEvent.cpp
index 78a75c5..192ce19 100644
--- a/cmds/statsd/src/logd/LogEvent.cpp
+++ b/cmds/statsd/src/logd/LogEvent.cpp
@@ -267,6 +267,22 @@
}
LogEvent::LogEvent(int64_t wallClockTimestampNs, int64_t elapsedTimestampNs,
+ const SpeechDspStat& speechDspStat) {
+ mLogdTimestampNs = wallClockTimestampNs;
+ mElapsedTimestampNs = elapsedTimestampNs;
+ mTagId = android::util::SPEECH_DSP_STAT_REPORTED;
+
+ mValues.push_back(FieldValue(Field(mTagId, getSimpleField(1)),
+ Value(speechDspStat.totalUptimeMillis)));
+ mValues.push_back(FieldValue(Field(mTagId, getSimpleField(2)),
+ Value(speechDspStat.totalDowntimeMillis)));
+ mValues.push_back(FieldValue(Field(mTagId, getSimpleField(3)),
+ Value(speechDspStat.totalCrashCount)));
+ mValues.push_back(FieldValue(Field(mTagId, getSimpleField(4)),
+ Value(speechDspStat.totalRecoverCount)));
+}
+
+LogEvent::LogEvent(int64_t wallClockTimestampNs, int64_t elapsedTimestampNs,
const BatteryCausedShutdown& batteryCausedShutdown) {
mLogdTimestampNs = wallClockTimestampNs;
mElapsedTimestampNs = elapsedTimestampNs;
diff --git a/cmds/statsd/src/logd/LogEvent.h b/cmds/statsd/src/logd/LogEvent.h
index 3f47b7e..7199d6e 100644
--- a/cmds/statsd/src/logd/LogEvent.h
+++ b/cmds/statsd/src/logd/LogEvent.h
@@ -121,6 +121,9 @@
explicit LogEvent(int64_t wallClockTimestampNs, int64_t elapsedTimestampNs,
const UsbPortOverheatEvent& usbPortOverheatEvent);
+ explicit LogEvent(int64_t wallClockTimestampNs, int64_t elapsedTimestampNs,
+ const SpeechDspStat& speechDspStat);
+
~LogEvent();
/**