BatteryMonitor: batteryStateOfHealth should be a property

Bug: 251427118
Test: m
Ignore-AOSP-First: will cherry-pick to aosp later
Change-Id: I21bcd160f51cf8818d0c3c8c54c615314808e586
Signed-off-by: AleX Pelosi <apelosi@google.com>
This commit is contained in:
AleX Pelosi 2023-02-17 01:39:21 +00:00 committed by Jack Wu
parent cfeffde01b
commit f4846e2d08

View file

@ -392,12 +392,13 @@ void BatteryMonitor::updateValues(void) {
mHealthInfo->batteryFullChargeDesignCapacityUah =
getIntField(mHealthdConfig->batteryFullChargeDesignCapacityUahPath);
if (!mHealthdConfig->batteryStateOfHealthPath.isEmpty())
mHealthInfo->batteryStateOfHealth = getIntField(mHealthdConfig->batteryStateOfHealthPath);
if (!mHealthdConfig->batteryHealthStatusPath.isEmpty())
mBatteryHealthStatus = getIntField(mHealthdConfig->batteryHealthStatusPath);
if (!mHealthdConfig->batteryStateOfHealthPath.isEmpty())
mHealthInfo->batteryHealthData->batteryStateOfHealth =
getIntField(mHealthdConfig->batteryStateOfHealthPath);
if (!mHealthdConfig->batteryManufacturingDatePath.isEmpty())
mHealthInfo->batteryHealthData->batteryManufacturingDateSeconds =
getIntField(mHealthdConfig->batteryManufacturingDatePath);
@ -591,6 +592,10 @@ int BatteryMonitor::getBatteryHealthData(int id) {
if (!mHealthdConfig->batteryFirstUsageDatePath.isEmpty())
return getIntField(mHealthdConfig->batteryFirstUsageDatePath);
}
if (id == BATTERY_PROP_STATE_OF_HEALTH) {
if (!mHealthdConfig->batteryStateOfHealthPath.isEmpty())
return getIntField(mHealthdConfig->batteryStateOfHealthPath);
}
return 0;
}
@ -669,6 +674,11 @@ status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) {
ret = OK;
break;
case BATTERY_PROP_STATE_OF_HEALTH:
val->valueInt64 = getBatteryHealthData(BATTERY_PROP_STATE_OF_HEALTH);
ret = OK;
break;
default:
break;
}