Loading health/2.0/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ hidl_interface { types: [ "Result", "DiskStats", "HealthInfo", "StorageAttribute", "StorageInfo", ], Loading health/2.0/IHealth.hal +11 −0 Original line number Diff line number Diff line Loading @@ -160,4 +160,15 @@ interface IHealth { * The mapping is index 0->sda, 1->sdb and so on. */ getDiskStats() generates (Result result, vec<DiskStats> value); /** * Get Health Information. * * @return result SUCCESS if successful, * NOT_SUPPORTED if this API is not supported, * UNKNOWN for other errors. * @return value Health information, to be ignored if result is not * SUCCESS. */ getHealthInfo() generates (Result result, @2.0::HealthInfo value); }; health/2.0/IHealthInfoCallback.hal +1 −1 Original line number Diff line number Diff line Loading @@ -28,5 +28,5 @@ interface IHealthInfoCallback { * registered callbacks after health info changes. * @param info the updated HealthInfo */ oneway healthInfoChanged(HealthInfo info); oneway healthInfoChanged(@1.0::HealthInfo info); }; health/2.0/default/Health.cpp +34 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <health2/Health.h> #include <hal_conversion.h> #include <hidl/HidlTransportSupport.h> extern void healthd_battery_update_internal(bool); Loading Loading @@ -199,6 +200,39 @@ Return<void> Health::getDiskStats(getDiskStats_cb _hidl_cb) { return Void(); } Return<void> Health::getHealthInfo(getHealthInfo_cb _hidl_cb) { using android::hardware::health::V1_0::hal_conversion::convertToHealthInfo; update(); struct android::BatteryProperties p = getBatteryProperties(battery_monitor_.get()); V1_0::HealthInfo batteryInfo; convertToHealthInfo(&p, batteryInfo); 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); } V2_0::HealthInfo healthInfo = {}; healthInfo.legacy = std::move(batteryInfo); healthInfo.batteryCurrentAverage = currentAvg; healthInfo.diskStats = stats; healthInfo.storageInfos = info; _hidl_cb(Result::SUCCESS, healthInfo); return Void(); } void Health::serviceDied(uint64_t /* cookie */, const wp<IBase>& who) { (void)unregisterCallbackInternal(who.promote()); } Loading health/2.0/default/include/health2/Health.h +1 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ struct Health : public IHealth, hidl_death_recipient { Return<void> getChargeStatus(getChargeStatus_cb _hidl_cb) override; Return<void> getStorageInfo(getStorageInfo_cb _hidl_cb) override; Return<void> getDiskStats(getDiskStats_cb _hidl_cb) override; Return<void> getHealthInfo(getHealthInfo_cb _hidl_cb) override; // Methods from ::android::hidl::base::V1_0::IBase follow. Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) override; Loading Loading
health/2.0/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ hidl_interface { types: [ "Result", "DiskStats", "HealthInfo", "StorageAttribute", "StorageInfo", ], Loading
health/2.0/IHealth.hal +11 −0 Original line number Diff line number Diff line Loading @@ -160,4 +160,15 @@ interface IHealth { * The mapping is index 0->sda, 1->sdb and so on. */ getDiskStats() generates (Result result, vec<DiskStats> value); /** * Get Health Information. * * @return result SUCCESS if successful, * NOT_SUPPORTED if this API is not supported, * UNKNOWN for other errors. * @return value Health information, to be ignored if result is not * SUCCESS. */ getHealthInfo() generates (Result result, @2.0::HealthInfo value); };
health/2.0/IHealthInfoCallback.hal +1 −1 Original line number Diff line number Diff line Loading @@ -28,5 +28,5 @@ interface IHealthInfoCallback { * registered callbacks after health info changes. * @param info the updated HealthInfo */ oneway healthInfoChanged(HealthInfo info); oneway healthInfoChanged(@1.0::HealthInfo info); };
health/2.0/default/Health.cpp +34 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <health2/Health.h> #include <hal_conversion.h> #include <hidl/HidlTransportSupport.h> extern void healthd_battery_update_internal(bool); Loading Loading @@ -199,6 +200,39 @@ Return<void> Health::getDiskStats(getDiskStats_cb _hidl_cb) { return Void(); } Return<void> Health::getHealthInfo(getHealthInfo_cb _hidl_cb) { using android::hardware::health::V1_0::hal_conversion::convertToHealthInfo; update(); struct android::BatteryProperties p = getBatteryProperties(battery_monitor_.get()); V1_0::HealthInfo batteryInfo; convertToHealthInfo(&p, batteryInfo); 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); } V2_0::HealthInfo healthInfo = {}; healthInfo.legacy = std::move(batteryInfo); healthInfo.batteryCurrentAverage = currentAvg; healthInfo.diskStats = stats; healthInfo.storageInfos = info; _hidl_cb(Result::SUCCESS, healthInfo); return Void(); } void Health::serviceDied(uint64_t /* cookie */, const wp<IBase>& who) { (void)unregisterCallbackInternal(who.promote()); } Loading
health/2.0/default/include/health2/Health.h +1 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ struct Health : public IHealth, hidl_death_recipient { Return<void> getChargeStatus(getChargeStatus_cb _hidl_cb) override; Return<void> getStorageInfo(getStorageInfo_cb _hidl_cb) override; Return<void> getDiskStats(getDiskStats_cb _hidl_cb) override; Return<void> getHealthInfo(getHealthInfo_cb _hidl_cb) override; // Methods from ::android::hidl::base::V1_0::IBase follow. Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) override; Loading