Merge "BatteryMonitor: batteryStateOfHealth should be a property"

This commit is contained in:
Jack Wu 2023-02-23 06:45:16 +00:00 committed by Gerrit Code Review
commit bae352bddb

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;
}