diff options
author | Brian Muramatsu <btmura@google.com> | 2012-08-14 15:21:02 -0700 |
---|---|---|
committer | Brian Muramatsu <btmura@google.com> | 2012-08-20 10:04:12 -0700 |
commit | 37a37f445cbcd64376af153dd79ea2a123d9405d (patch) | |
tree | 7b2ae5f75d4c6bff056472da64752473e1d211f9 /services/jni | |
parent | 82d53ce283b7c275624d66e9bf20cfe2614af5c4 (diff) | |
download | frameworks_base-37a37f445cbcd64376af153dd79ea2a123d9405d.zip frameworks_base-37a37f445cbcd64376af153dd79ea2a123d9405d.tar.gz frameworks_base-37a37f445cbcd64376af153dd79ea2a123d9405d.tar.bz2 |
add wireless charger support
bug: 6879638
- add new enum value BATTERY_PLUGGED_WIRELESS
- check for sys online file with contents "Wireless"
Change-Id: I22dc3c40f50573c98643e7b5cbcb237d0216530d
Diffstat (limited to 'services/jni')
-rw-r--r-- | services/jni/com_android_server_BatteryService.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/services/jni/com_android_server_BatteryService.cpp b/services/jni/com_android_server_BatteryService.cpp index ca6f206..8ebc6ea 100644 --- a/services/jni/com_android_server_BatteryService.cpp +++ b/services/jni/com_android_server_BatteryService.cpp @@ -42,6 +42,7 @@ struct FieldIds { // members jfieldID mAcOnline; jfieldID mUsbOnline; + jfieldID mWirelessOnline; jfieldID mBatteryStatus; jfieldID mBatteryHealth; jfieldID mBatteryPresent; @@ -71,6 +72,7 @@ static BatteryManagerConstants gConstants; struct PowerSupplyPaths { char* acOnlinePath; char* usbOnlinePath; + char* wirelessOnlinePath; char* batteryStatusPath; char* batteryHealthPath; char* batteryPresentPath; @@ -198,6 +200,7 @@ static void android_server_BatteryService_update(JNIEnv* env, jobject obj) { setBooleanField(env, obj, gPaths.acOnlinePath, gFieldIds.mAcOnline); setBooleanField(env, obj, gPaths.usbOnlinePath, gFieldIds.mUsbOnline); + setBooleanField(env, obj, gPaths.wirelessOnlinePath, gFieldIds.mWirelessOnline); setBooleanField(env, obj, gPaths.batteryPresentPath, gFieldIds.mBatteryPresent); setIntField(env, obj, gPaths.batteryCapacityPath, gFieldIds.mBatteryLevel); @@ -260,6 +263,11 @@ int register_android_server_BatteryService(JNIEnv* env) if (access(path, R_OK) == 0) gPaths.usbOnlinePath = strdup(path); } + else if (strcmp(buf, "Wireless") == 0) { + snprintf(path, sizeof(path), "%s/%s/online", POWER_SUPPLY_PATH, name); + if (access(path, R_OK) == 0) + gPaths.wirelessOnlinePath = strdup(path); + } else if (strcmp(buf, "Battery") == 0) { snprintf(path, sizeof(path), "%s/%s/status", POWER_SUPPLY_PATH, name); if (access(path, R_OK) == 0) @@ -307,6 +315,8 @@ int register_android_server_BatteryService(JNIEnv* env) ALOGE("acOnlinePath not found"); if (!gPaths.usbOnlinePath) ALOGE("usbOnlinePath not found"); + if (!gPaths.wirelessOnlinePath) + ALOGE("wirelessOnlinePath not found"); if (!gPaths.batteryStatusPath) ALOGE("batteryStatusPath not found"); if (!gPaths.batteryHealthPath) @@ -331,6 +341,7 @@ int register_android_server_BatteryService(JNIEnv* env) gFieldIds.mAcOnline = env->GetFieldID(clazz, "mAcOnline", "Z"); gFieldIds.mUsbOnline = env->GetFieldID(clazz, "mUsbOnline", "Z"); + gFieldIds.mWirelessOnline = env->GetFieldID(clazz, "mWirelessOnline", "Z"); gFieldIds.mBatteryStatus = env->GetFieldID(clazz, "mBatteryStatus", "I"); gFieldIds.mBatteryHealth = env->GetFieldID(clazz, "mBatteryHealth", "I"); gFieldIds.mBatteryPresent = env->GetFieldID(clazz, "mBatteryPresent", "Z"); @@ -341,6 +352,7 @@ int register_android_server_BatteryService(JNIEnv* env) LOG_FATAL_IF(gFieldIds.mAcOnline == NULL, "Unable to find BatteryService.AC_ONLINE_PATH"); LOG_FATAL_IF(gFieldIds.mUsbOnline == NULL, "Unable to find BatteryService.USB_ONLINE_PATH"); + LOG_FATAL_IF(gFieldIds.mWirelessOnline == NULL, "Unable to find BatteryService.WIRELESS_ONLINE_PATH"); LOG_FATAL_IF(gFieldIds.mBatteryStatus == NULL, "Unable to find BatteryService.BATTERY_STATUS_PATH"); LOG_FATAL_IF(gFieldIds.mBatteryHealth == NULL, "Unable to find BatteryService.BATTERY_HEALTH_PATH"); LOG_FATAL_IF(gFieldIds.mBatteryPresent == NULL, "Unable to find BatteryService.BATTERY_PRESENT_PATH"); |