healthd: Only use battery values that seems legit
On some devices, there are other sysfs paths having a "capacity"
node than just the battery, which can return a weirdo value. We
make sure we only use legit battery levels (> 0%).
Change-Id: I3caf34e7fed4b89f953ec98c486b53b8786c8f74
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 688c7ff..7fd51a0 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -331,7 +331,7 @@
path.clear();
path.appendFormat("%s/%s/capacity", POWER_SUPPLY_SYSFS_PATH,
name);
- if (access(path, R_OK) == 0)
+ if (access(path, R_OK) == 0 && getIntField(path) > 0)
mHealthdConfig->batteryCapacityPath = path;
}