Loading health/2.0/IHealthInfoCallback.hal +1 −3 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ package android.hardware.health@2.0; import @1.0::HealthInfo; /** * IHealthInfoCallback is the callback interface to * {@link IHealthInfoBus.registerCallback}. Loading @@ -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); }; health/2.0/default/Health.cpp +20 −2 Original line number Diff line number Diff line Loading @@ -155,10 +155,28 @@ Return<Result> Health::update() { return Result::SUCCESS; } void Health::notifyListeners(const HealthInfo& info) { void Health::notifyListeners(HealthInfo* healthInfo) { std::vector<StorageInfo> info; get_storage_info(info); std::vector<DiskStats> 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<int32_t>(prop.valueInt64); } healthInfo->batteryCurrentAverage = currentAvg; healthInfo->diskStats = stats; healthInfo->storageInfos = info; std::lock_guard<std::mutex> _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 { Loading health/2.0/default/include/health2/Health.h +1 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ namespace V2_0 { namespace implementation { using V1_0::BatteryStatus; using V1_0::HealthInfo; using ::android::hidl::base::V1_0::IBase; Loading @@ -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<Result> registerCallback(const sp<IHealthInfoCallback>& callback) override; Loading health/2.0/types.hal +1 −1 Original line number Diff line number Diff line Loading @@ -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. */ Loading health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ class HealthHidlTest : public ::testing::VtsHalHidlTargetTestBase { class Callback : public IHealthInfoCallback { public: Return<void> healthInfoChanged(const V1_0::HealthInfo&) override { Return<void> healthInfoChanged(const HealthInfo&) override { std::lock_guard<std::mutex> lock(mMutex); mInvoked = true; mInvokedNotify.notify_all(); Loading Loading
health/2.0/IHealthInfoCallback.hal +1 −3 Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ package android.hardware.health@2.0; import @1.0::HealthInfo; /** * IHealthInfoCallback is the callback interface to * {@link IHealthInfoBus.registerCallback}. Loading @@ -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); };
health/2.0/default/Health.cpp +20 −2 Original line number Diff line number Diff line Loading @@ -155,10 +155,28 @@ Return<Result> Health::update() { return Result::SUCCESS; } void Health::notifyListeners(const HealthInfo& info) { void Health::notifyListeners(HealthInfo* healthInfo) { std::vector<StorageInfo> info; get_storage_info(info); std::vector<DiskStats> 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<int32_t>(prop.valueInt64); } healthInfo->batteryCurrentAverage = currentAvg; healthInfo->diskStats = stats; healthInfo->storageInfos = info; std::lock_guard<std::mutex> _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 { Loading
health/2.0/default/include/health2/Health.h +1 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ namespace V2_0 { namespace implementation { using V1_0::BatteryStatus; using V1_0::HealthInfo; using ::android::hidl::base::V1_0::IBase; Loading @@ -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<Result> registerCallback(const sp<IHealthInfoCallback>& callback) override; Loading
health/2.0/types.hal +1 −1 Original line number Diff line number Diff line Loading @@ -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. */ Loading
health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ class HealthHidlTest : public ::testing::VtsHalHidlTargetTestBase { class Callback : public IHealthInfoCallback { public: Return<void> healthInfoChanged(const V1_0::HealthInfo&) override { Return<void> healthInfoChanged(const HealthInfo&) override { std::lock_guard<std::mutex> lock(mMutex); mInvoked = true; mInvokedNotify.notify_all(); Loading