healthd: fall back to charger design voltage
Drivers may report a charger's maximum voltage as voltage_max_design
rather than as voltage_max, so try to read the charging voltage from the
_design entry in sysfs if the other one doesn't exist.
The kernel's documentation for VOLTAGE_MAX states that value should be
used if hardware is unable to determine the actual supply thresholds
(like a battery where the design voltage is unknown and hardware instead
reports the previously-observed maximum), in contrast with
VOLTAGE_MAX_DESIGN which is meant to be the intended maximum voltage.
However, the documentation is also written as if these values only apply
to batteries so what should actually happen for charger devices is
subject to interpretation.
In practice, charger drivers disagree about which to report: healthd
currently only reads VOLTAGE_MAX, but the existing upstream
cros-usbpd-charger driver reports VOLTAGE_MAX_DESIGN instead. This
change makes BatteryMonitor try to read VOLTAGE_MAX_DESIGN if
VOLTAGE_MAX is not set for any given charger, so the voltage of
cros-usbpd-charger devices is reported correctly.
Bug: 361670941
Test: on brya, `dumpsys android.hardware.health.IHealth/default` now
reports the current charger voltage, in voltage_max, rather
than always 5V.
Change-Id: I5cd4f3a729521c9ed58783601db04e176ff78e84
Loading
Please register or sign in to comment