Loading healthd/Health.cpp +3 −12 Original line number Diff line number Diff line Loading @@ -120,7 +120,7 @@ Return<Result> Health::update() { } // Retrieve all information and call healthd_mode_ops->battery_update, which calls // updateAndNotify. // notifyListeners. bool chargerOnline = battery_monitor_->update(); // adjust uevent / wakealarm periods Loading @@ -129,19 +129,10 @@ Return<Result> Health::update() { return Result::SUCCESS; } void Health::updateAndNotify(HealthInfo* info) { // update 2.0 specific fields struct BatteryProperty prop; if (battery_monitor_->getProperty(BATTERY_PROP_CURRENT_AVG, &prop) == OK) info->batteryCurrentAverage = static_cast<int32_t>(prop.valueInt64); if (battery_monitor_->getProperty(BATTERY_PROP_CAPACITY, &prop) == OK) info->batteryCapacity = static_cast<int32_t>(prop.valueInt64); if (battery_monitor_->getProperty(BATTERY_PROP_ENERGY_COUNTER, &prop) == OK) info->energyCounter = prop.valueInt64; void Health::notifyListeners(const HealthInfo& 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(info); if (!ret.isOk() && ret.isDeadObject()) { it = callbacks_.erase(it); } else { Loading healthd/HealthService.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -28,8 +28,8 @@ using android::hardware::IPCThreadState; using android::hardware::configureRpcThreadpool; using android::hardware::health::V1_0::HealthInfo; using android::hardware::health::V1_0::hal_conversion::convertToHealthInfo; using android::hardware::health::V2_0::HealthInfo; using android::hardware::health::V2_0::IHealth; using android::hardware::health::V2_0::implementation::Health; Loading Loading @@ -89,9 +89,9 @@ void healthd_mode_service_2_0_battery_update(struct android::BatteryProperties* // Implementation-defined update logic goes here. An implementation // can make modifications to prop before broadcasting it to all callbacks. HealthInfo info{}; convertToHealthInfo(prop, info.legacy); static_cast<Health*>(gHealth.get())->updateAndNotify(&info); HealthInfo info; convertToHealthInfo(prop, info); static_cast<Health*>(gHealth.get())->notifyListeners(info); } static struct healthd_mode_ops healthd_mode_service_2_0_ops = { Loading healthd/include/health2/Health.h +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ namespace V2_0 { namespace implementation { using V1_0::BatteryStatus; using V1_0::HealthInfo; using ::android::hidl::base::V1_0::IBase; Loading @@ -24,7 +25,7 @@ struct Health : public IHealth, hidl_death_recipient { Health(struct healthd_config* c); // TODO(b/62229583): clean up and hide these functions. void updateAndNotify(HealthInfo* info); void notifyListeners(const HealthInfo& info); // Methods from IHealth follow. Return<Result> registerCallback(const sp<IHealthInfoCallback>& callback) override; Loading storaged/include/storaged.h +1 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ public: void init_health_service(); virtual ::android::hardware::Return<void> healthInfoChanged( const ::android::hardware::health::V2_0::HealthInfo& info); const ::android::hardware::health::V1_0::HealthInfo& info); void serviceDied(uint64_t cookie, const wp<::android::hidl::base::V1_0::IBase>& who); void report_storage_info(); Loading storaged/storaged.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ const uint32_t storaged_t::crc_init = 0x5108A4ED; /* STORAGED */ using android::hardware::health::V1_0::BatteryStatus; using android::hardware::health::V1_0::toString; using android::hardware::health::V2_0::HealthInfo; using android::hardware::health::V1_0::HealthInfo; using android::hardware::health::V2_0::IHealth; using android::hardware::health::V2_0::Result; using android::hardware::interfacesEqual; Loading @@ -86,7 +86,7 @@ inline charger_stat_t is_charger_on(BatteryStatus prop) { } Return<void> storaged_t::healthInfoChanged(const HealthInfo& props) { mUidm.set_charger_state(is_charger_on(props.legacy.batteryStatus)); mUidm.set_charger_state(is_charger_on(props.batteryStatus)); return android::hardware::Void(); } Loading Loading
healthd/Health.cpp +3 −12 Original line number Diff line number Diff line Loading @@ -120,7 +120,7 @@ Return<Result> Health::update() { } // Retrieve all information and call healthd_mode_ops->battery_update, which calls // updateAndNotify. // notifyListeners. bool chargerOnline = battery_monitor_->update(); // adjust uevent / wakealarm periods Loading @@ -129,19 +129,10 @@ Return<Result> Health::update() { return Result::SUCCESS; } void Health::updateAndNotify(HealthInfo* info) { // update 2.0 specific fields struct BatteryProperty prop; if (battery_monitor_->getProperty(BATTERY_PROP_CURRENT_AVG, &prop) == OK) info->batteryCurrentAverage = static_cast<int32_t>(prop.valueInt64); if (battery_monitor_->getProperty(BATTERY_PROP_CAPACITY, &prop) == OK) info->batteryCapacity = static_cast<int32_t>(prop.valueInt64); if (battery_monitor_->getProperty(BATTERY_PROP_ENERGY_COUNTER, &prop) == OK) info->energyCounter = prop.valueInt64; void Health::notifyListeners(const HealthInfo& 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(info); if (!ret.isOk() && ret.isDeadObject()) { it = callbacks_.erase(it); } else { Loading
healthd/HealthService.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -28,8 +28,8 @@ using android::hardware::IPCThreadState; using android::hardware::configureRpcThreadpool; using android::hardware::health::V1_0::HealthInfo; using android::hardware::health::V1_0::hal_conversion::convertToHealthInfo; using android::hardware::health::V2_0::HealthInfo; using android::hardware::health::V2_0::IHealth; using android::hardware::health::V2_0::implementation::Health; Loading Loading @@ -89,9 +89,9 @@ void healthd_mode_service_2_0_battery_update(struct android::BatteryProperties* // Implementation-defined update logic goes here. An implementation // can make modifications to prop before broadcasting it to all callbacks. HealthInfo info{}; convertToHealthInfo(prop, info.legacy); static_cast<Health*>(gHealth.get())->updateAndNotify(&info); HealthInfo info; convertToHealthInfo(prop, info); static_cast<Health*>(gHealth.get())->notifyListeners(info); } static struct healthd_mode_ops healthd_mode_service_2_0_ops = { Loading
healthd/include/health2/Health.h +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ namespace V2_0 { namespace implementation { using V1_0::BatteryStatus; using V1_0::HealthInfo; using ::android::hidl::base::V1_0::IBase; Loading @@ -24,7 +25,7 @@ struct Health : public IHealth, hidl_death_recipient { Health(struct healthd_config* c); // TODO(b/62229583): clean up and hide these functions. void updateAndNotify(HealthInfo* info); void notifyListeners(const HealthInfo& info); // Methods from IHealth follow. Return<Result> registerCallback(const sp<IHealthInfoCallback>& callback) override; Loading
storaged/include/storaged.h +1 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ public: void init_health_service(); virtual ::android::hardware::Return<void> healthInfoChanged( const ::android::hardware::health::V2_0::HealthInfo& info); const ::android::hardware::health::V1_0::HealthInfo& info); void serviceDied(uint64_t cookie, const wp<::android::hidl::base::V1_0::IBase>& who); void report_storage_info(); Loading
storaged/storaged.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ const uint32_t storaged_t::crc_init = 0x5108A4ED; /* STORAGED */ using android::hardware::health::V1_0::BatteryStatus; using android::hardware::health::V1_0::toString; using android::hardware::health::V2_0::HealthInfo; using android::hardware::health::V1_0::HealthInfo; using android::hardware::health::V2_0::IHealth; using android::hardware::health::V2_0::Result; using android::hardware::interfacesEqual; Loading @@ -86,7 +86,7 @@ inline charger_stat_t is_charger_on(BatteryStatus prop) { } Return<void> storaged_t::healthInfoChanged(const HealthInfo& props) { mUidm.set_charger_state(is_charger_on(props.legacy.batteryStatus)); mUidm.set_charger_state(is_charger_on(props.batteryStatus)); return android::hardware::Void(); } Loading