diff options
author | Roger Fang <rogerfang@google.com> | 2022-11-02 15:00:28 +0800 |
---|---|---|
committer | Roger Fang <rogerfang@google.com> | 2022-11-02 15:30:19 +0800 |
commit | e539aa7d023168521a8e0d42801b06ba07cffdbc (patch) | |
tree | c63cd9663eb655ce081d8e4b22ef36913a23a67f | |
parent | 64284745bb8d31195e1861ce0e1b18fba3603ed9 (diff) |
Pixelstats: support cca_rate sysfs
Add cca rates of VendorAudioHardwareStatsReported
Atest cmd:
atest PixelAtomsTest:com.google.pixelatoms.PixelAtomsTest#testVendorPushedAtomsHasReverseDomainName
Bug: 249225148
Test: check log in logcat & ATEST manually
Change-Id: Ic2572439c889cab499cfb5477de7503723e9f083
Signed-off-by: Roger Fang <rogerfang@google.com>
-rw-r--r-- | pixelstats/SysfsCollector.cpp | 66 | ||||
-rw-r--r-- | pixelstats/include/pixelstats/SysfsCollector.h | 2 | ||||
-rw-r--r-- | pixelstats/pixelatoms.proto | 12 |
3 files changed, 65 insertions, 15 deletions
diff --git a/pixelstats/SysfsCollector.cpp b/pixelstats/SysfsCollector.cpp index 391c8b1..c2453cb 100644 --- a/pixelstats/SysfsCollector.cpp +++ b/pixelstats/SysfsCollector.cpp @@ -88,7 +88,8 @@ SysfsCollector::SysfsCollector(const struct SysfsPaths &sysfs_paths) kUFSErrStatsPath(sysfs_paths.UFSErrStatsPath), kBlockStatsLength(sysfs_paths.BlockStatsLength), kAmsRatePath(sysfs_paths.AmsRatePath), - kThermalStatsPaths(sysfs_paths.ThermalStatsPaths) {} + kThermalStatsPaths(sysfs_paths.ThermalStatsPaths), + kCCARatePath(sysfs_paths.CCARatePath) {} bool SysfsCollector::ReadFileToInt(const std::string &path, int *val) { return ReadFileToInt(path.c_str(), val); @@ -978,32 +979,67 @@ void SysfsCollector::logBootStats(const std::shared_ptr<IStats> &stats_client) { } /** - * Report the AMS rate. + * Report the AMS & CCA rate. */ 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; + bool isAmsReady = false, isCCAReady = false; + if (kAmsRatePath == nullptr) { - ALOGD("Audio AMS_Rate path not specified"); - return; + ALOGD("Audio AMS Rate path not specified"); + } else { + if (!ReadFileToString(kAmsRatePath, &file_contents)) { + ALOGD("Unable to read ams_rate path %s", kAmsRatePath); + } else { + if (sscanf(file_contents.c_str(), "%u", &milli_ams_rate) != 1) { + ALOGD("Unable to parse ams_rate %s", file_contents.c_str()); + } else { + isAmsReady = true; + ALOGD("milli_ams_rate = %u", milli_ams_rate); + } + } } - uint32_t milli_ams_rate; - if (!ReadFileToString(kAmsRatePath, &file_contents)) { - ALOGE("Unable to read ams_rate path %s", kAmsRatePath); - return; + if (kCCARatePath == nullptr) { + ALOGD("Audio CCA Rate path not specified"); + } else { + 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) { + 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 (sscanf(file_contents.c_str(), "%u", &milli_ams_rate) != 1) { - ALOGE("Unable to parse ams_rate %s", file_contents.c_str()); + if (!(isAmsReady || isCCAReady)) { + ALOGD("no ams or cca data to report"); return; } - ALOGD("milli_ams_rate = %s", file_contents.c_str()); - - std::vector<VendorAtomValue> values(1); + std::vector<VendorAtomValue> values(3); VendorAtomValue tmp; - tmp.set<VendorAtomValue::intValue>(milli_ams_rate); - values[0] = 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>(cca_enable_rate); + values[VendorAudioHardwareStatsReported::kRateOfCcaEnablePerDayFieldNumber - + kVendorAtomOffset] = tmp; + } // Send vendor atom to IStats HAL VendorAtom event = {.reverseDomainName = "", diff --git a/pixelstats/include/pixelstats/SysfsCollector.h b/pixelstats/include/pixelstats/SysfsCollector.h index 75b1a09..f487dda 100644 --- a/pixelstats/include/pixelstats/SysfsCollector.h +++ b/pixelstats/include/pixelstats/SysfsCollector.h @@ -64,6 +64,7 @@ class SysfsCollector { const int BlockStatsLength; const char *const AmsRatePath; const std::vector<std::string> ThermalStatsPaths; + const char *const CCARatePath; }; SysfsCollector(const struct SysfsPaths &paths); @@ -130,6 +131,7 @@ class SysfsCollector { const int kBlockStatsLength; const char *const kAmsRatePath; const std::vector<std::string> kThermalStatsPaths; + const char *const kCCARatePath; BatteryEEPROMReporter battery_EEPROM_reporter_; MmMetricsReporter mm_metrics_reporter_; diff --git a/pixelstats/pixelatoms.proto b/pixelstats/pixelatoms.proto index 2300526..e4d98bf 100644 --- a/pixelstats/pixelatoms.proto +++ b/pixelstats/pixelatoms.proto @@ -1268,4 +1268,16 @@ message VendorAudioHardwareStatsReported { * 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. + */ + + /* cca_active: UI enable & algorithm is active (C1) */ + optional int32 rate_of_cca_active_per_day = 3; + + /* cca_enable: UI enable & algorithm is inactive. (C2) */ + optional int32 rate_of_cca_enable_per_day = 4; } |