diff options
author | Poomarin Phloyphisut <poomarin@google.com> | 2023-08-22 15:32:43 +0000 |
---|---|---|
committer | Poomarin Phloyphisut <poomarin@google.com> | 2023-08-22 15:32:43 +0000 |
commit | aa503af3c8fbd0371d8a24fc28236881559f5115 (patch) | |
tree | 683429c2986ca9662b61d39b370669df7de942d1 | |
parent | 2d8cbba0ed618ded2fc6fe48e819a956a33e437f (diff) | |
download | pixel-aa503af3c8fbd0371d8a24fc28236881559f5115.tar.gz |
pixelstats: update log for VendorAudioHardwareStats to CCA 2.0
Eldar: eldar/381899786
Bug: 289857250
Test: Local Test
Change-Id: Idfa0fca0272c3932b338899261fbc816bbbed286
-rw-r--r-- | pixelstats/SysfsCollector.cpp | 104 | ||||
-rw-r--r-- | pixelstats/include/pixelstats/SysfsCollector.h | 2 | ||||
-rw-r--r-- | pixelstats/pixelatoms.proto | 27 |
3 files changed, 95 insertions, 38 deletions
diff --git a/pixelstats/SysfsCollector.cpp b/pixelstats/SysfsCollector.cpp index c7d44f7c..c7e3833b 100644 --- a/pixelstats/SysfsCollector.cpp +++ b/pixelstats/SysfsCollector.cpp @@ -122,7 +122,8 @@ SysfsCollector::SysfsCollector(const struct SysfsPaths &sysfs_paths) kAdaptedInfoCountPath(sysfs_paths.AdaptedInfoCountPath), kAdaptedInfoDurationPath(sysfs_paths.AdaptedInfoDurationPath), kPcmLatencyPath(sysfs_paths.PcmLatencyPath), - kPcmCountPath(sysfs_paths.PcmCountPath) {} + kPcmCountPath(sysfs_paths.PcmCountPath), + kTotalCallCountPath(sysfs_paths.TotalCallCountPath) {} bool SysfsCollector::ReadFileToInt(const std::string &path, int *val) { return ReadFileToInt(path.c_str(), val); @@ -1083,7 +1084,8 @@ void SysfsCollector::logBootStats(const std::shared_ptr<IStats> &stats_client) { */ void SysfsCollector::logVendorAudioHardwareStats(const std::shared_ptr<IStats> &stats_client) { std::string file_contents; - uint32_t milli_ams_rate, cca_active_rate, cca_enable_rate; + uint32_t milli_ams_rate, c1, c2, c3, c4; + uint32_t total_call_voice = 0, total_call_voip = 0; bool isAmsReady = false, isCCAReady = false; if (kAmsRatePath == nullptr) { @@ -1107,12 +1109,22 @@ void SysfsCollector::logVendorAudioHardwareStats(const std::shared_ptr<IStats> & if (!ReadFileToString(kCCARatePath, &file_contents)) { ALOGD("Unable to read cca_rate path %s", kCCARatePath); } else { - if (sscanf(file_contents.c_str(), "%u,%u", &cca_active_rate, &cca_enable_rate) != 2) { + if (sscanf(file_contents.c_str(), "%u %u %u %u", &c1, &c2, &c3, &c4) != 4) { ALOGD("Unable to parse cca rates %s", file_contents.c_str()); } else { isCCAReady = true; - ALOGD("cca_active_rate = %u, cca_enable_rate = %u", cca_active_rate, - cca_enable_rate); + } + } + } + + if (kTotalCallCountPath == nullptr) { + ALOGD("Total call count path not specified"); + } else { + if (!ReadFileToString(kTotalCallCountPath, &file_contents)) { + ALOGD("Unable to read total call path %s", kTotalCallCountPath); + } else { + if (sscanf(file_contents.c_str(), "%u %u", &total_call_voice, &total_call_voip) != 2) { + ALOGD("Unable to parse total call %s", file_contents.c_str()); } } } @@ -1122,35 +1134,73 @@ void SysfsCollector::logVendorAudioHardwareStats(const std::shared_ptr<IStats> & return; } - std::vector<VendorAtomValue> values(3); - VendorAtomValue tmp; + // Sending ams_rate, total_call, c1 and c2 + { + std::vector<VendorAtomValue> values(5); + VendorAtomValue tmp; - if (isAmsReady) { - tmp.set<VendorAtomValue::intValue>(milli_ams_rate); - values[VendorAudioHardwareStatsReported::kMilliRateOfAmsPerDayFieldNumber - - kVendorAtomOffset] = tmp; - } + if (isAmsReady) { + tmp.set<VendorAtomValue::intValue>(milli_ams_rate); + values[VendorAudioHardwareStatsReported::kMilliRateOfAmsPerDayFieldNumber - + kVendorAtomOffset] = tmp; + } - if (isCCAReady) { - tmp.set<VendorAtomValue::intValue>(cca_active_rate); - values[VendorAudioHardwareStatsReported::kRateOfCcaActivePerDayFieldNumber - - kVendorAtomOffset] = tmp; + tmp.set<VendorAtomValue::intValue>(1); + values[VendorAudioHardwareStatsReported::kSourceFieldNumber - kVendorAtomOffset] = tmp; + + if (isCCAReady) { + tmp.set<VendorAtomValue::intValue>(c1); + values[VendorAudioHardwareStatsReported::kCcaActiveCountPerDayFieldNumber - + kVendorAtomOffset] = tmp; + + tmp.set<VendorAtomValue::intValue>(c2); + values[VendorAudioHardwareStatsReported::kCcaEnableCountPerDayFieldNumber - + kVendorAtomOffset] = tmp; + } - tmp.set<VendorAtomValue::intValue>(cca_enable_rate); - values[VendorAudioHardwareStatsReported::kRateOfCcaEnablePerDayFieldNumber - + tmp.set<VendorAtomValue::intValue>(total_call_voice); + values[VendorAudioHardwareStatsReported::kTotalCallCountPerDayFieldNumber - kVendorAtomOffset] = tmp; + + // Send vendor atom to IStats HAL + VendorAtom event = {.reverseDomainName = "", + .atomId = PixelAtoms::Atom::kVendorAudioHardwareStatsReported, + .values = std::move(values)}; + const ndk::ScopedAStatus ret = stats_client->reportVendorAtom(event); + if (!ret.isOk()) + ALOGE("Unable to report VendorAudioHardwareStatsReported to Stats service"); } - // Send vendor atom to IStats HAL - VendorAtom event = {.reverseDomainName = "", - .atomId = PixelAtoms::Atom::kVendorAudioHardwareStatsReported, - .values = std::move(values)}; + // Sending total_call, c3 and c4 + { + std::vector<VendorAtomValue> values(5); + VendorAtomValue tmp; - const ndk::ScopedAStatus ret = stats_client->reportVendorAtom(event); - if (!ret.isOk()) - ALOGE("Unable to report VendorAudioHardwareStatsReported to Stats service"); - else - ALOGD("Reported VendorAudioHardwareStatsReported"); + tmp.set<VendorAtomValue::intValue>(0); + values[VendorAudioHardwareStatsReported::kSourceFieldNumber - kVendorAtomOffset] = tmp; + + if (isCCAReady) { + tmp.set<VendorAtomValue::intValue>(c3); + values[VendorAudioHardwareStatsReported::kCcaActiveCountPerDayFieldNumber - + kVendorAtomOffset] = tmp; + + tmp.set<VendorAtomValue::intValue>(c4); + values[VendorAudioHardwareStatsReported::kCcaEnableCountPerDayFieldNumber - + kVendorAtomOffset] = tmp; + } + + tmp.set<VendorAtomValue::intValue>(total_call_voip); + values[VendorAudioHardwareStatsReported::kTotalCallCountPerDayFieldNumber - + kVendorAtomOffset] = tmp; + + // Send vendor atom to IStats HAL + VendorAtom event = {.reverseDomainName = "", + .atomId = PixelAtoms::Atom::kVendorAudioHardwareStatsReported, + .values = std::move(values)}; + const ndk::ScopedAStatus ret = stats_client->reportVendorAtom(event); + if (!ret.isOk()) + ALOGE("Unable to report VendorAudioHardwareStatsReported to Stats service"); + } } /** diff --git a/pixelstats/include/pixelstats/SysfsCollector.h b/pixelstats/include/pixelstats/SysfsCollector.h index 20732f50..494acd71 100644 --- a/pixelstats/include/pixelstats/SysfsCollector.h +++ b/pixelstats/include/pixelstats/SysfsCollector.h @@ -86,6 +86,7 @@ class SysfsCollector { const char *const AdaptedInfoDurationPath; const char *const PcmLatencyPath; const char *const PcmCountPath; + const char *const TotalCallCountPath; }; SysfsCollector(const struct SysfsPaths &paths); @@ -184,6 +185,7 @@ class SysfsCollector { const char *const kAdaptedInfoDurationPath; const char *const kPcmLatencyPath; const char *const kPcmCountPath; + const char *const kTotalCallCountPath; BatteryEEPROMReporter battery_EEPROM_reporter_; MmMetricsReporter mm_metrics_reporter_; diff --git a/pixelstats/pixelatoms.proto b/pixelstats/pixelatoms.proto index a490482d..33b01606 100644 --- a/pixelstats/pixelatoms.proto +++ b/pixelstats/pixelatoms.proto @@ -1312,25 +1312,30 @@ message BlockStatsReported { */ message VendorAudioHardwareStatsReported { optional string reverse_domain_name = 1; - /* The percentage of calls in a day where auto-mic-switch triggered. - * It represented as a fixed-point integer with three decimal place. - * E.g.:12.345% is repsented by 12345. - */ - optional int32 milli_rate_of_ams_per_day = 2; - /* The percentage of calls in a day where CCA is active. * It represented as a fixed-point and rounded integer. * E.g.:12.345% is represented by 12. * CCA can only be applied under some radio bands. */ + optional int32 milli_rate_of_ams_per_day = 2; + + enum Source { + VOIP = 0; + VOICE = 1; + } - /* cca_active: UI enable & algorithm is active (C1) */ - optional int32 rate_of_cca_active_per_day = 3; + /* source: identify whether this atom is for voice or voip case. */ + optional Source source = 3; - /* cca_enable: UI enable & algorithm is inactive. (C2) */ - optional int32 rate_of_cca_enable_per_day = 4; -} + /* total_call_count_per_day: count total number of call per day. */ + optional int32 total_call_count_per_day = 4; + /* cca_active: UI enable & algorithm is active */ + optional int32 cca_active_count_per_day = 5; + + /* cca_enable: UI enable & algorithm is inactive. */ + optional int32 cca_enable_count_per_day = 6; +} /** * Logs the reported vendor audio PDM stats. |