diff --git a/health/2.0/IHealthInfoCallback.hal b/health/2.0/IHealthInfoCallback.hal index 737ea72da5..15352ee4b1 100644 --- a/health/2.0/IHealthInfoCallback.hal +++ b/health/2.0/IHealthInfoCallback.hal @@ -16,8 +16,6 @@ package android.hardware.health@2.0; -import @1.0::HealthInfo; - /** * IHealthInfoCallback is the callback interface to * {@link IHealthInfoBus.registerCallback}. @@ -28,5 +26,5 @@ interface IHealthInfoCallback { * registered callbacks after health info changes. * @param info the updated HealthInfo */ - oneway healthInfoChanged(@1.0::HealthInfo info); + oneway healthInfoChanged(HealthInfo info); }; diff --git a/health/2.0/default/Health.cpp b/health/2.0/default/Health.cpp index b1227a3b2d..7a3e650408 100644 --- a/health/2.0/default/Health.cpp +++ b/health/2.0/default/Health.cpp @@ -155,10 +155,28 @@ Return Health::update() { return Result::SUCCESS; } -void Health::notifyListeners(const HealthInfo& info) { +void Health::notifyListeners(HealthInfo* healthInfo) { + std::vector info; + get_storage_info(info); + + std::vector stats; + get_disk_stats(stats); + + int32_t currentAvg = 0; + + struct BatteryProperty prop; + status_t ret = battery_monitor_->getProperty(BATTERY_PROP_CURRENT_AVG, &prop); + if (ret == OK) { + currentAvg = static_cast(prop.valueInt64); + } + + healthInfo->batteryCurrentAverage = currentAvg; + healthInfo->diskStats = stats; + healthInfo->storageInfos = info; + std::lock_guard _lock(callbacks_lock_); for (auto it = callbacks_.begin(); it != callbacks_.end();) { - auto ret = (*it)->healthInfoChanged(info); + auto ret = (*it)->healthInfoChanged(*healthInfo); if (!ret.isOk() && ret.isDeadObject()) { it = callbacks_.erase(it); } else { diff --git a/health/2.0/default/include/health2/Health.h b/health/2.0/default/include/health2/Health.h index fc867893d7..134cdc6e69 100644 --- a/health/2.0/default/include/health2/Health.h +++ b/health/2.0/default/include/health2/Health.h @@ -22,7 +22,6 @@ namespace V2_0 { namespace implementation { using V1_0::BatteryStatus; -using V1_0::HealthInfo; using ::android::hidl::base::V1_0::IBase; @@ -38,7 +37,7 @@ struct Health : public IHealth, hidl_death_recipient { Health(struct healthd_config* c); // TODO(b/62229583): clean up and hide these functions after update() logic is simplified. - void notifyListeners(const HealthInfo& info); + void notifyListeners(HealthInfo* info); // Methods from IHealth follow. Return registerCallback(const sp& callback) override; diff --git a/health/2.0/types.hal b/health/2.0/types.hal index c74076e545..fe33c88af7 100644 --- a/health/2.0/types.hal +++ b/health/2.0/types.hal @@ -141,7 +141,7 @@ struct HealthInfo { /** * Average battery current in uA. Will be 0 if unsupported. */ - int64_t batteryCurrentAverage; + int32_t batteryCurrentAverage; /** * Disk Statistics. Will be an empty vector if unsupported. */ diff --git a/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp b/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp index 85dab44c6f..972bc7f6db 100644 --- a/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp +++ b/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp @@ -68,7 +68,7 @@ class HealthHidlTest : public ::testing::VtsHalHidlTargetTestBase { class Callback : public IHealthInfoCallback { public: - Return healthInfoChanged(const V1_0::HealthInfo&) override { + Return healthInfoChanged(const HealthInfo&) override { std::lock_guard lock(mMutex); mInvoked = true; mInvokedNotify.notify_all();