healthd: Read charge_counter from qpnp-bms if missing in battery
On msm8974, battery information is exposed by the kernel drivers
qpnp-charger and qpnp-bms, which create separate sysfs nodes. qpnp-bms
is reported as "Unknown" power supply type, so healthd will not check it
for battery-related information.
Add extra logic to support reading charge_counter from bms if it is
missing in the battery sysfs node.
Issue: FP2P-405
Test: run cts -m CtsStatsdHostTestCases -t android.cts.statsd.atom.HostAtomTests#testRemainingBatteryCapacity
Change-Id: Ia1545a0aa625634626ba64c89d48b1d5fd026733
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 80c5afe..82c46ec 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -576,6 +576,20 @@
POWER_SUPPLY_SYSFS_PATH, name);
if (access(path, R_OK) == 0)
mHealthdConfig->batteryChargeCounterPath = path;
+ else if (strcmp(name, "battery") == 0) {
+ // On Qualcomm chipsets, the value might come from the
+ // "QPNP PMIC Battery Management System driver", which
+ // creates sysfs entries separate from the "battery"
+ // node.
+ path.clear();
+ path.appendFormat("%s/bms/charge_counter",
+ POWER_SUPPLY_SYSFS_PATH);
+ if (access(path, R_OK) == 0) {
+ KLOG_INFO(LOG_TAG, "Reading charge_counter from "
+ "bms instead of the battery driver.");
+ mHealthdConfig->batteryChargeCounterPath = path;
+ }
+ }
}
if (mHealthdConfig->batteryTemperaturePath.isEmpty()) {