diff options
author | Roger Fang <rogerfang@google.com> | 2022-08-23 15:32:18 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2022-08-23 15:32:18 +0000 |
commit | b000d69db34d528eacfb01d812262b2527b3c61e (patch) | |
tree | bfe7576bee9b2527d602e79df346c423da1db7fa | |
parent | 97d79467e79ccd3f069f074f85e042b78da0850b (diff) | |
parent | c8dda04d1c017e6803b69261679b1c7bcd55e5a5 (diff) |
Merge "Pixelstats: support ams_rate sysfs" into tm-qpr-dev
-rw-r--r-- | pixelstats/SysfsCollector.cpp | 47 | ||||
-rw-r--r-- | pixelstats/include/pixelstats/SysfsCollector.h | 3 | ||||
-rw-r--r-- | pixelstats/pixelatoms.proto | 12 |
3 files changed, 59 insertions, 3 deletions
diff --git a/pixelstats/SysfsCollector.cpp b/pixelstats/SysfsCollector.cpp index 6c661ff..3f3da67 100644 --- a/pixelstats/SysfsCollector.cpp +++ b/pixelstats/SysfsCollector.cpp @@ -43,14 +43,15 @@ using android::base::ReadFileToString; using android::base::StartsWith; using android::base::WriteStringToFile; using android::hardware::google::pixel::PixelAtoms::BatteryCapacity; -using android::hardware::google::pixel::PixelAtoms::BootStatsInfo; using android::hardware::google::pixel::PixelAtoms::BlockStatsReported; +using android::hardware::google::pixel::PixelAtoms::BootStatsInfo; using android::hardware::google::pixel::PixelAtoms::F2fsCompressionInfo; using android::hardware::google::pixel::PixelAtoms::F2fsGcSegmentInfo; -using android::hardware::google::pixel::PixelAtoms::F2fsStatsInfo; using android::hardware::google::pixel::PixelAtoms::F2fsSmartIdleMaintEnabledStateChanged; +using android::hardware::google::pixel::PixelAtoms::F2fsStatsInfo; using android::hardware::google::pixel::PixelAtoms::StorageUfsHealth; using android::hardware::google::pixel::PixelAtoms::StorageUfsResetCount; +using android::hardware::google::pixel::PixelAtoms::VendorAudioHardwareStatsReported; using android::hardware::google::pixel::PixelAtoms::VendorChargeCycles; using android::hardware::google::pixel::PixelAtoms::VendorHardwareFailed; using android::hardware::google::pixel::PixelAtoms::VendorSlowIo; @@ -84,7 +85,8 @@ SysfsCollector::SysfsCollector(const struct SysfsPaths &sysfs_paths) kSpeakerExcursionPath(sysfs_paths.SpeakerExcursionPath), kSpeakerHeartbeatPath(sysfs_paths.SpeakerHeartBeatPath), kUFSErrStatsPath(sysfs_paths.UFSErrStatsPath), - kBlockStatsLength(sysfs_paths.BlockStatsLength) {} + kBlockStatsLength(sysfs_paths.BlockStatsLength), + kAmsRatePath(sysfs_paths.AmsRatePath) {} bool SysfsCollector::ReadFileToInt(const std::string &path, int *val) { return ReadFileToInt(path.c_str(), val); @@ -969,6 +971,44 @@ void SysfsCollector::logBootStats(const std::shared_ptr<IStats> &stats_client) { } } +/** + * Report the AMS rate. + */ +void SysfsCollector::logVendorAudioHardwareStats(const std::shared_ptr<IStats> &stats_client) { + std::string file_contents; + if (kAmsRatePath == nullptr) { + ALOGD("Audio AMS_Rate path not specified"); + return; + } + + uint32_t milli_ams_rate; + if (!ReadFileToString(kAmsRatePath, &file_contents)) { + ALOGE("Unable to read ams_rate path %s", kAmsRatePath); + return; + } + + if (sscanf(file_contents.c_str(), "%u", &milli_ams_rate) != 1) { + ALOGE("Unable to parse ams_rate %s", file_contents.c_str()); + return; + } + + ALOGD("milli_ams_rate = %s", file_contents.c_str()); + + std::vector<VendorAtomValue> values(1); + VendorAtomValue tmp; + tmp.set<VendorAtomValue::intValue>(milli_ams_rate); + values[0] = 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"); +} + void SysfsCollector::logPerDay() { const std::shared_ptr<IStats> stats_client = getStatsService(); if (!stats_client) { @@ -998,6 +1038,7 @@ void SysfsCollector::logPerDay() { logSpeakerHealthStats(stats_client); mm_metrics_reporter_.logCmaStatus(stats_client); mm_metrics_reporter_.logPixelMmMetricsPerDay(stats_client); + logVendorAudioHardwareStats(stats_client); } void SysfsCollector::logPerHour() { diff --git a/pixelstats/include/pixelstats/SysfsCollector.h b/pixelstats/include/pixelstats/SysfsCollector.h index 0a772ce..f846d49 100644 --- a/pixelstats/include/pixelstats/SysfsCollector.h +++ b/pixelstats/include/pixelstats/SysfsCollector.h @@ -61,6 +61,7 @@ class SysfsCollector { const char *const SpeakerHeartBeatPath; const std::vector<std::string> UFSErrStatsPath; const int BlockStatsLength; + const char *const AmsRatePath; }; SysfsCollector(const struct SysfsPaths &paths); @@ -97,6 +98,7 @@ class SysfsCollector { void reportZramMmStat(const std::shared_ptr<IStats> &stats_client); void reportZramBdStat(const std::shared_ptr<IStats> &stats_client); int getReclaimedSegments(const std::string &mode); + void logVendorAudioHardwareStats(const std::shared_ptr<IStats> &stats_client); const char *const kSlowioReadCntPath; const char *const kSlowioWriteCntPath; @@ -122,6 +124,7 @@ class SysfsCollector { const char *const kSpeakerHeartbeatPath; const std::vector<std::string> kUFSErrStatsPath; const int kBlockStatsLength; + const char *const kAmsRatePath; BatteryEEPROMReporter battery_EEPROM_reporter_; MmMetricsReporter mm_metrics_reporter_; diff --git a/pixelstats/pixelatoms.proto b/pixelstats/pixelatoms.proto index be08192..9459711 100644 --- a/pixelstats/pixelatoms.proto +++ b/pixelstats/pixelatoms.proto @@ -81,6 +81,7 @@ message Atom { BatteryHealthUsage battery_health_usage = 105038; F2fsSmartIdleMaintEnabledStateChanged f2fs_smart_idle_maint_enabled_state_changed = 105039; BlockStatsReported block_stats_reported = 105040; + VendorAudioHardwareStatsReported vendor_audio_hardware_stats_reported = 105041; } // AOSP atom ID range ends at 109999 } @@ -1147,3 +1148,14 @@ message BlockStatsReported { /* total wait time for write requests */ optional int64 write_ticks = 7; } + +/** + * Logs the reported vendor audio hardware stats. + */ +message VendorAudioHardwareStatsReported { + /* 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 = 1; +} |