diff options
Diffstat (limited to 'services/jni')
-rw-r--r-- | services/jni/com_android_server_BatteryService.cpp | 12 | ||||
-rw-r--r-- | services/jni/com_android_server_input_InputManagerService.cpp | 17 |
2 files changed, 18 insertions, 11 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"); diff --git a/services/jni/com_android_server_input_InputManagerService.cpp b/services/jni/com_android_server_input_InputManagerService.cpp index 701b15a..495d4ab 100644 --- a/services/jni/com_android_server_input_InputManagerService.cpp +++ b/services/jni/com_android_server_input_InputManagerService.cpp @@ -63,7 +63,7 @@ static const float POINTER_SPEED_EXPONENT = 1.0f / 4; static struct { jmethodID notifyConfigurationChanged; jmethodID notifyInputDevicesChanged; - jmethodID notifyLidSwitchChanged; + jmethodID notifySwitch; jmethodID notifyInputChannelBroken; jmethodID notifyANR; jmethodID filterInputEvent; @@ -578,14 +578,9 @@ void NativeInputManager::notifySwitch(nsecs_t when, int32_t switchCode, JNIEnv* env = jniEnv(); - switch (switchCode) { - case SW_LID: - // When switch value is set indicates lid is closed. - env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyLidSwitchChanged, - when, switchValue == 0 /*lidOpen*/); - checkAndClearExceptionFromCallback(env, "notifyLidSwitchChanged"); - break; - } + env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifySwitch, + when, switchCode, switchValue); + checkAndClearExceptionFromCallback(env, "notifySwitch"); } void NativeInputManager::notifyConfigurationChanged(nsecs_t when) { @@ -1410,8 +1405,8 @@ int register_android_server_InputManager(JNIEnv* env) { GET_METHOD_ID(gServiceClassInfo.notifyInputDevicesChanged, clazz, "notifyInputDevicesChanged", "([Landroid/view/InputDevice;)V"); - GET_METHOD_ID(gServiceClassInfo.notifyLidSwitchChanged, clazz, - "notifyLidSwitchChanged", "(JZ)V"); + GET_METHOD_ID(gServiceClassInfo.notifySwitch, clazz, + "notifySwitch", "(JII)V"); GET_METHOD_ID(gServiceClassInfo.notifyInputChannelBroken, clazz, "notifyInputChannelBroken", "(Lcom/android/server/input/InputWindowHandle;)V"); |