summaryrefslogtreecommitdiffstats
path: root/healthd
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2015-10-12 09:52:27 -1000
committerSteve Kondik <steve@cyngn.com>2015-10-12 09:52:27 -1000
commit69c7a768b161f97785c2e71a2caff3803d4a2be7 (patch)
treec4c7e7988a4ee507579ed906229b411d70504c5a /healthd
parent0fcbde444948c6851d08a2c4de0a44d555f112f5 (diff)
parent6013e8d811510fe5fd87938e69c7918d6728105c (diff)
downloadsystem_core-69c7a768b161f97785c2e71a2caff3803d4a2be7.zip
system_core-69c7a768b161f97785c2e71a2caff3803d4a2be7.tar.gz
system_core-69c7a768b161f97785c2e71a2caff3803d4a2be7.tar.bz2
Merge branch 'LA.BF64.1.2.2_rb4.1' of git://codeaurora.org/platform/system/core into caf-merge
Diffstat (limited to 'healthd')
-rw-r--r--healthd/BatteryMonitor.cpp81
1 files changed, 56 insertions, 25 deletions
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 7ea8250..b0e9a4d 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -134,7 +134,10 @@ BatteryMonitor::PowerSupplyType BatteryMonitor::readPowerSupplyType(const String
{ "USB_DCP", ANDROID_POWER_SUPPLY_TYPE_AC },
{ "USB_CDP", ANDROID_POWER_SUPPLY_TYPE_AC },
{ "USB_ACA", ANDROID_POWER_SUPPLY_TYPE_AC },
+ { "USB_HVDCP", ANDROID_POWER_SUPPLY_TYPE_AC },
+ { "USB_HVDCP_3", ANDROID_POWER_SUPPLY_TYPE_AC },
{ "Wireless", ANDROID_POWER_SUPPLY_TYPE_WIRELESS },
+ { "Wipower", ANDROID_POWER_SUPPLY_TYPE_WIRELESS },
{ NULL, 0 },
};
@@ -209,35 +212,63 @@ bool BatteryMonitor::update(void) {
if (readFromFile(mHealthdConfig->batteryTechnologyPath, buf, SIZE) > 0)
props.batteryTechnology = String8(buf);
- unsigned int i;
+ // reinitialize the mChargerNames vector everytime there is an update
+ String8 path;
+ DIR* dir = opendir(POWER_SUPPLY_SYSFS_PATH);
+ if (dir == NULL) {
+ KLOG_ERROR(LOG_TAG, "Could not open %s\n", POWER_SUPPLY_SYSFS_PATH);
+ } else {
+ struct dirent* entry;
+ // reconstruct the charger strings
+ mChargerNames.clear();
+ while ((entry = readdir(dir))) {
+ const char* name = entry->d_name;
- for (i = 0; i < mChargerNames.size(); i++) {
- String8 path;
- path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH,
- mChargerNames[i].string());
+ if (!strcmp(name, ".") || !strcmp(name, ".."))
+ continue;
- if (readFromFile(path, buf, SIZE) > 0) {
- if (buf[0] != '0') {
+ // Look for "type" file in each subdirectory
+ 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:
path.clear();
- path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH,
- mChargerNames[i].string());
- switch(readPowerSupplyType(path)) {
- case ANDROID_POWER_SUPPLY_TYPE_AC:
- props.chargerAcOnline = true;
- break;
- case ANDROID_POWER_SUPPLY_TYPE_USB:
- props.chargerUsbOnline = true;
- break;
- case ANDROID_POWER_SUPPLY_TYPE_WIRELESS:
- props.chargerWirelessOnline = true;
- break;
- default:
- KLOG_WARNING(LOG_TAG, "%s: Unknown power supply type\n",
- mChargerNames[i].string());
+ path.appendFormat("%s/%s/online", POWER_SUPPLY_SYSFS_PATH, name);
+ if (access(path.string(), R_OK) == 0) {
+ mChargerNames.add(String8(name));
+ if (readFromFile(path, buf, SIZE) > 0) {
+ if (buf[0] != '0') {
+ path.clear();
+ path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH,
+ name);
+ switch(readPowerSupplyType(path)) {
+ case ANDROID_POWER_SUPPLY_TYPE_AC:
+ props.chargerAcOnline = true;
+ break;
+ case ANDROID_POWER_SUPPLY_TYPE_USB:
+ props.chargerUsbOnline = true;
+ break;
+ case ANDROID_POWER_SUPPLY_TYPE_WIRELESS:
+ props.chargerWirelessOnline = true;
+ break;
+ default:
+ KLOG_WARNING(LOG_TAG, "%s: Unknown power supply type\n",
+ name);
+ }
+ }
+ }
}
- }
- }
- }
+ break;
+ case ANDROID_POWER_SUPPLY_TYPE_BATTERY:
+ break;
+ default:
+ break;
+ } //switch
+ } //while
+ closedir(dir);
+ }//else
logthis = !healthd_board_battery_update(&props);