From 35cb0838f65408b998f960f07b28e66666cd6364 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Mon, 7 Oct 2019 13:58:29 -0700 Subject: [PATCH] healthd: partially fill in health 2.1 HAL fields - batteryCurrentAverage - batteryCapacityLevel - batteryChargeTimeToFullNowSeconds - batteryFullCapacityUah Some of the fields are left 0 / UNKNOWN and will be implemented in b/142260281. Bug: 142260281 Test: lshal debug health 2.1 HAL shows these values Change-Id: I8e462d612b39c16cfb3ae1b63b3e293153585c28 --- healthd/BatteryMonitor.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index cdc2e5d28..9e168e9e5 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -54,6 +54,7 @@ using HealthInfo_2_0 = android::hardware::health::V2_0::HealthInfo; using HealthInfo_2_1 = android::hardware::health::V2_1::HealthInfo; using android::hardware::health::V1_0::BatteryHealth; using android::hardware::health::V1_0::BatteryStatus; +using android::hardware::health::V2_1::BatteryCapacityLevel; namespace android { @@ -223,6 +224,15 @@ void BatteryMonitor::updateValues(void) { if (!mHealthdConfig->batteryChargeCounterPath.isEmpty()) props.batteryChargeCounter = getIntField(mHealthdConfig->batteryChargeCounterPath); + if (!mHealthdConfig->batteryCurrentAvgPath.isEmpty()) + mHealthInfo->legacy.batteryCurrentAverage = + getIntField(mHealthdConfig->batteryCurrentAvgPath); + + // TODO(b/142260281): Retrieve these values correctly. + mHealthInfo->batteryCapacityLevel = BatteryCapacityLevel::UNKNOWN; + mHealthInfo->batteryChargeTimeToFullNowSeconds = 0; + mHealthInfo->batteryFullCapacityUah = props.batteryFullCharge; + props.batteryTemperature = mBatteryFixedTemperature ? mBatteryFixedTemperature : getIntField(mHealthdConfig->batteryTemperaturePath);