diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index 8590a115c..48af70ea7 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -340,6 +340,17 @@ bool BatteryMonitor::update(void) { props.chargerWirelessOnline; } +int BatteryMonitor::getChargeStatus() { + int result = BATTERY_STATUS_UNKNOWN; + if (!mHealthdConfig->batteryStatusPath.isEmpty()) { + char buf[128]; + if (readFromFile(mHealthdConfig->batteryStatusPath, buf, sizeof(buf)) > 0) { + result = getBatteryStatus(buf); + } + } + return result; +} + status_t BatteryMonitor::getProperty(int id, struct BatteryProperty *val) { status_t ret = BAD_VALUE; diff --git a/healthd/include/healthd/BatteryMonitor.h b/healthd/include/healthd/BatteryMonitor.h index 31c4e0920..440f2e44c 100644 --- a/healthd/include/healthd/BatteryMonitor.h +++ b/healthd/include/healthd/BatteryMonitor.h @@ -40,6 +40,7 @@ class BatteryMonitor { BatteryMonitor(); void init(struct healthd_config *hc); bool update(void); + int getChargeStatus(); status_t getProperty(int id, struct BatteryProperty *val); void dumpState(int fd);