From cbbf24f15dadd8c14efc702da23e9b66af9912c7 Mon Sep 17 00:00:00 2001 From: Jack Wu Date: Sat, 18 Feb 2023 12:34:19 +0800 Subject: [PATCH] health: get batteryStateOfHealth from healthd Bug: 251427118 Test: m android.hardware.health-update-api Change-Id: I556570782b0a9698fd3530be86f8ede33b11afe2 Signed-off-by: Jack Wu --- health/aidl/default/Health.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/health/aidl/default/Health.cpp b/health/aidl/default/Health.cpp index 15a3dbcb5a..f401643cde 100644 --- a/health/aidl/default/Health.cpp +++ b/health/aidl/default/Health.cpp @@ -148,6 +148,11 @@ ndk::ScopedAStatus Health::getBatteryHealthData(BatteryHealthData* out) { !res.isOk()) { LOG(WARNING) << "Cannot get First_usage_date: " << res.getDescription(); } + if (auto res = GetProperty(&battery_monitor_, ::android::BATTERY_PROP_STATE_OF_HEALTH, + 0, &out->batteryStateOfHealth); + !res.isOk()) { + LOG(WARNING) << "Cannot get Battery_state_of_health: " << res.getDescription(); + } return ndk::ScopedAStatus::ok(); }