From 72d52954af098600818d9afdc15ccdad289ba473 Mon Sep 17 00:00:00 2001 From: myfluxi Date: Wed, 17 Dec 2014 19:15:19 +0100 Subject: healthd: Detect power supply type for all charger devices Power supply type is not determined via the device name, hence iterate over all available devices in the subsystem node and read the type from device file. shell@hammerhead:/ $ ls /sys/class/power_supply ac batt_therm battery touch usb wireless <4>[ 3184.867782] healthd: touch: Unknown power supply type <4>[ 3184.868039] healthd: batt_therm: Unknown power supply type <6>[ 3184.880506] healthd: battery l=89 v=4181 t=25.5 h=2 st=2 c=-288 chg=u <4>[ 3184.890362] healthd: touch: Unknown power supply type <4>[ 3184.890549] healthd: batt_therm: Unknown power supply type <6>[ 3184.899419] healthd: battery l=89 v=4181 t=25.5 h=2 st=2 c=-59 chg=u <4>[ 3184.908756] healthd: touch: Unknown power supply type <4>[ 3184.908984] healthd: batt_therm: Unknown power supply type <6>[ 3184.919672] healthd: battery l=89 v=4181 t=25.6 h=2 st=2 c=-25 chg=u Change-Id: I863bfab95193899460237b51997e0418eeb4ee2c --- healthd/BatteryMonitor.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp index b0e9a4d..c336c0a 100644 --- a/healthd/BatteryMonitor.cpp +++ b/healthd/BatteryMonitor.cpp @@ -231,9 +231,9 @@ bool BatteryMonitor::update(void) { path.clear(); path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH, name); switch(readPowerSupplyType(path)) { - case ANDROID_POWER_SUPPLY_TYPE_AC: - case ANDROID_POWER_SUPPLY_TYPE_USB: - case ANDROID_POWER_SUPPLY_TYPE_WIRELESS: + case ANDROID_POWER_SUPPLY_TYPE_BATTERY: + break; + default: path.clear(); path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH, name); if (access(path.string(), R_OK) == 0) { @@ -261,10 +261,6 @@ bool BatteryMonitor::update(void) { } } break; - case ANDROID_POWER_SUPPLY_TYPE_BATTERY: - break; - default: - break; } //switch } //while closedir(dir); -- cgit v1.1