Merge "Pixelstats: read other count instead of reset count" into sc-qpr1-dev
diff --git a/pixelstats/SysfsCollector.cpp b/pixelstats/SysfsCollector.cpp
index 520a564..f2fdeea 100644
--- a/pixelstats/SysfsCollector.cpp
+++ b/pixelstats/SysfsCollector.cpp
@@ -73,7 +73,6 @@
       kUFSLifetimeA(sysfs_paths.UFSLifetimeA),
       kUFSLifetimeB(sysfs_paths.UFSLifetimeB),
       kUFSLifetimeC(sysfs_paths.UFSLifetimeC),
-      kUFSHostResetPath(sysfs_paths.UFSHostResetPath),
       kF2fsStatsPath(sysfs_paths.F2fsStatsPath),
       kZramMmStatPath("/sys/block/zram0/mm_stat"),
       kZramBdStatPath("/sys/block/zram0/bd_stat"),
@@ -81,7 +80,8 @@
       kPowerMitigationStatsPath(sysfs_paths.MitigationPath),
       kSpeakerTemperaturePath(sysfs_paths.SpeakerTemperaturePath),
       kSpeakerExcursionPath(sysfs_paths.SpeakerExcursionPath),
-      kSpeakerHeartbeatPath(sysfs_paths.SpeakerHeartBeatPath) {}
+      kSpeakerHeartbeatPath(sysfs_paths.SpeakerHeartBeatPath),
+      kUFSErrStatsPath(sysfs_paths.UFSErrStatsPath) {}
 
 bool SysfsCollector::ReadFileToInt(const std::string &path, int *val) {
     return ReadFileToInt(path.c_str(), val);
@@ -467,16 +467,19 @@
 }
 
 void SysfsCollector::logUFSErrorStats(const std::shared_ptr<IStats> &stats_client) {
-    int host_reset_count;
+    int value, host_reset_count = 0;
 
-    if (kUFSHostResetPath == nullptr || strlen(kUFSHostResetPath) == 0) {
+    if (kUFSErrStatsPath.empty() || strlen(kUFSErrStatsPath.front().c_str()) == 0) {
         ALOGV("UFS host reset count specified");
         return;
     }
 
-    if (!ReadFileToInt(kUFSHostResetPath, &host_reset_count)) {
-        ALOGE("Unable to read host reset count");
-        return;
+    for (int i = 0; i < kUFSErrStatsPath.size(); i++) {
+        if (!ReadFileToInt(kUFSErrStatsPath[i], &value)) {
+            ALOGE("Unable to read host reset count");
+            return;
+        }
+        host_reset_count += value;
     }
 
     // Load values array
diff --git a/pixelstats/include/pixelstats/SysfsCollector.h b/pixelstats/include/pixelstats/SysfsCollector.h
index 2dcfea9..097a4c7 100644
--- a/pixelstats/include/pixelstats/SysfsCollector.h
+++ b/pixelstats/include/pixelstats/SysfsCollector.h
@@ -48,7 +48,6 @@
         const char *const UFSLifetimeA;
         const char *const UFSLifetimeB;
         const char *const UFSLifetimeC;
-        const char *const UFSHostResetPath;
         const char *const F2fsStatsPath;
         const char *const UserdataBlockProp;
         const char *const ZramMmStatPath;
@@ -58,6 +57,7 @@
         const char *const SpeakerTemperaturePath;
         const char *const SpeakerExcursionPath;
         const char *const SpeakerHeartBeatPath;
+        const std::vector<std::string> UFSErrStatsPath;
     };
 
     SysfsCollector(const struct SysfsPaths &paths);
@@ -106,7 +106,6 @@
     const char *const kUFSLifetimeA;
     const char *const kUFSLifetimeB;
     const char *const kUFSLifetimeC;
-    const char *const kUFSHostResetPath;
     const char *const kF2fsStatsPath;
     const char *const kZramMmStatPath;
     const char *const kZramBdStatPath;
@@ -115,6 +114,7 @@
     const char *const kSpeakerTemperaturePath;
     const char *const kSpeakerExcursionPath;
     const char *const kSpeakerHeartbeatPath;
+    const std::vector<std::string> kUFSErrStatsPath;
 
     BatteryEEPROMReporter battery_EEPROM_reporter_;
     MmMetricsReporter mm_metrics_reporter_;