Loading storaged/include/storaged_info.h +20 −3 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <chrono> #include <android/hardware/health/2.0/IHealth.h> #include <utils/Mutex.h> #include "storaged.h" Loading Loading @@ -66,8 +67,10 @@ protected: } void publish(); storage_info_t* s_info; public: static storage_info_t* get_storage_info(); static storage_info_t* get_storage_info( const sp<android::hardware::health::V2_0::IHealth>& healthService); virtual ~storage_info_t() {}; virtual void report() {}; void load_perf_history_proto(const IOPerfHistory& perf_history); Loading Loading @@ -98,4 +101,18 @@ public: virtual void report(); }; class health_storage_info_t : public storage_info_t { private: using IHealth = hardware::health::V2_0::IHealth; using StorageInfo = hardware::health::V2_0::StorageInfo; sp<IHealth> mHealth; void set_values_from_hal_storage_info(const StorageInfo& halInfo); public: health_storage_info_t(const sp<IHealth>& service) : mHealth(service){}; virtual ~health_storage_info_t() {} virtual void report(); }; #endif /* _STORAGED_INFO_H_ */ storaged/storaged.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ Return<void> storaged_t::healthInfoChanged(const HealthInfo& props) { void storaged_t::init() { init_health_service(); mDsm = std::make_unique<disk_stats_monitor>(health); storage_info.reset(storage_info_t::get_storage_info(health)); } void storaged_t::init_health_service() { Loading Loading @@ -157,8 +158,6 @@ storaged_t::storaged_t(void) { property_get_int32("ro.storaged.flush_proto.interval", DEFAULT_PERIODIC_CHORES_INTERVAL_FLUSH_PROTO); storage_info.reset(storage_info_t::get_storage_info()); mStarttime = time(NULL); mTimer = 0; } Loading storaged/storaged_info.cpp +30 −2 Original line number Diff line number Diff line Loading @@ -36,6 +36,10 @@ using namespace chrono; using namespace android::base; using namespace storaged_proto; using android::hardware::health::V2_0::IHealth; using android::hardware::health::V2_0::Result; using android::hardware::health::V2_0::StorageInfo; const string emmc_info_t::emmc_sysfs = "/sys/bus/mmc/devices/mmc0:0001/"; const string emmc_info_t::emmc_debugfs = "/d/mmc0/mmc0:0001/ext_csd"; const char* emmc_info_t::emmc_ver_str[9] = { Loading @@ -54,8 +58,10 @@ bool FileExists(const std::string& filename) } // namespace storage_info_t* storage_info_t::get_storage_info() { storage_info_t* storage_info_t::get_storage_info(const sp<IHealth>& healthService) { if (healthService != nullptr) { return new health_storage_info_t(healthService); } if (FileExists(emmc_info_t::emmc_sysfs) || FileExists(emmc_info_t::emmc_debugfs)) { return new emmc_info_t; Loading Loading @@ -351,3 +357,25 @@ void ufs_info_t::report() publish(); } void health_storage_info_t::report() { auto ret = mHealth->getStorageInfo([this](auto result, const auto& halInfos) { if (result != Result::SUCCESS || halInfos.size() == 0) { LOG_TO(SYSTEM, DEBUG) << "getStorageInfo failed with result " << toString(result) << " and size " << halInfos.size(); return; } set_values_from_hal_storage_info(halInfos[0]); publish(); }); if (!ret.isOk()) { LOG_TO(SYSTEM, DEBUG) << "getStorageInfo failed with " << ret.description(); } } void health_storage_info_t::set_values_from_hal_storage_info(const StorageInfo& halInfo) { eol = halInfo.eol; lifetime_a = halInfo.lifetimeA; lifetime_b = halInfo.lifetimeB; version = halInfo.version; } Loading
storaged/include/storaged_info.h +20 −3 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <chrono> #include <android/hardware/health/2.0/IHealth.h> #include <utils/Mutex.h> #include "storaged.h" Loading Loading @@ -66,8 +67,10 @@ protected: } void publish(); storage_info_t* s_info; public: static storage_info_t* get_storage_info(); static storage_info_t* get_storage_info( const sp<android::hardware::health::V2_0::IHealth>& healthService); virtual ~storage_info_t() {}; virtual void report() {}; void load_perf_history_proto(const IOPerfHistory& perf_history); Loading Loading @@ -98,4 +101,18 @@ public: virtual void report(); }; class health_storage_info_t : public storage_info_t { private: using IHealth = hardware::health::V2_0::IHealth; using StorageInfo = hardware::health::V2_0::StorageInfo; sp<IHealth> mHealth; void set_values_from_hal_storage_info(const StorageInfo& halInfo); public: health_storage_info_t(const sp<IHealth>& service) : mHealth(service){}; virtual ~health_storage_info_t() {} virtual void report(); }; #endif /* _STORAGED_INFO_H_ */
storaged/storaged.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ Return<void> storaged_t::healthInfoChanged(const HealthInfo& props) { void storaged_t::init() { init_health_service(); mDsm = std::make_unique<disk_stats_monitor>(health); storage_info.reset(storage_info_t::get_storage_info(health)); } void storaged_t::init_health_service() { Loading Loading @@ -157,8 +158,6 @@ storaged_t::storaged_t(void) { property_get_int32("ro.storaged.flush_proto.interval", DEFAULT_PERIODIC_CHORES_INTERVAL_FLUSH_PROTO); storage_info.reset(storage_info_t::get_storage_info()); mStarttime = time(NULL); mTimer = 0; } Loading
storaged/storaged_info.cpp +30 −2 Original line number Diff line number Diff line Loading @@ -36,6 +36,10 @@ using namespace chrono; using namespace android::base; using namespace storaged_proto; using android::hardware::health::V2_0::IHealth; using android::hardware::health::V2_0::Result; using android::hardware::health::V2_0::StorageInfo; const string emmc_info_t::emmc_sysfs = "/sys/bus/mmc/devices/mmc0:0001/"; const string emmc_info_t::emmc_debugfs = "/d/mmc0/mmc0:0001/ext_csd"; const char* emmc_info_t::emmc_ver_str[9] = { Loading @@ -54,8 +58,10 @@ bool FileExists(const std::string& filename) } // namespace storage_info_t* storage_info_t::get_storage_info() { storage_info_t* storage_info_t::get_storage_info(const sp<IHealth>& healthService) { if (healthService != nullptr) { return new health_storage_info_t(healthService); } if (FileExists(emmc_info_t::emmc_sysfs) || FileExists(emmc_info_t::emmc_debugfs)) { return new emmc_info_t; Loading Loading @@ -351,3 +357,25 @@ void ufs_info_t::report() publish(); } void health_storage_info_t::report() { auto ret = mHealth->getStorageInfo([this](auto result, const auto& halInfos) { if (result != Result::SUCCESS || halInfos.size() == 0) { LOG_TO(SYSTEM, DEBUG) << "getStorageInfo failed with result " << toString(result) << " and size " << halInfos.size(); return; } set_values_from_hal_storage_info(halInfos[0]); publish(); }); if (!ret.isOk()) { LOG_TO(SYSTEM, DEBUG) << "getStorageInfo failed with " << ret.description(); } } void health_storage_info_t::set_values_from_hal_storage_info(const StorageInfo& halInfo) { eol = halInfo.eol; lifetime_a = halInfo.lifetimeA; lifetime_b = halInfo.lifetimeB; version = halInfo.version; }