Skip to content

Commit 5338428

Browse files
author
Jeff Brown
committed
Plumb the switch code into Dalvik.
Bug: 6548391 Change-Id: If0e918669ba27ca0e6561930d4abc427c34de42d
1 parent 008b176 commit 5338428

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

services/java/com/android/server/input/InputManagerService.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,8 +1218,12 @@ private void notifyInputDevicesChanged(InputDevice[] inputDevices) {
12181218
}
12191219

12201220
// Native callback.
1221-
private void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) {
1222-
mCallbacks.notifyLidSwitchChanged(whenNanos, lidOpen);
1221+
private void notifySwitch(long whenNanos, int switchCode, int switchValue) {
1222+
switch (switchCode) {
1223+
case SW_LID:
1224+
mCallbacks.notifyLidSwitchChanged(whenNanos, switchValue == 0);
1225+
break;
1226+
}
12231227
}
12241228

12251229
// Native callback.

services/jni/com_android_server_input_InputManagerService.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static const float POINTER_SPEED_EXPONENT = 1.0f / 4;
6363
static struct {
6464
jmethodID notifyConfigurationChanged;
6565
jmethodID notifyInputDevicesChanged;
66-
jmethodID notifyLidSwitchChanged;
66+
jmethodID notifySwitch;
6767
jmethodID notifyInputChannelBroken;
6868
jmethodID notifyANR;
6969
jmethodID filterInputEvent;
@@ -578,14 +578,9 @@ void NativeInputManager::notifySwitch(nsecs_t when, int32_t switchCode,
578578

579579
JNIEnv* env = jniEnv();
580580

581-
switch (switchCode) {
582-
case SW_LID:
583-
// When switch value is set indicates lid is closed.
584-
env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyLidSwitchChanged,
585-
when, switchValue == 0 /*lidOpen*/);
586-
checkAndClearExceptionFromCallback(env, "notifyLidSwitchChanged");
587-
break;
588-
}
581+
env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifySwitch,
582+
when, switchCode, switchValue);
583+
checkAndClearExceptionFromCallback(env, "notifySwitch");
589584
}
590585

591586
void NativeInputManager::notifyConfigurationChanged(nsecs_t when) {
@@ -1410,8 +1405,8 @@ int register_android_server_InputManager(JNIEnv* env) {
14101405
GET_METHOD_ID(gServiceClassInfo.notifyInputDevicesChanged, clazz,
14111406
"notifyInputDevicesChanged", "([Landroid/view/InputDevice;)V");
14121407

1413-
GET_METHOD_ID(gServiceClassInfo.notifyLidSwitchChanged, clazz,
1414-
"notifyLidSwitchChanged", "(JZ)V");
1408+
GET_METHOD_ID(gServiceClassInfo.notifySwitch, clazz,
1409+
"notifySwitch", "(JII)V");
14151410

14161411
GET_METHOD_ID(gServiceClassInfo.notifyInputChannelBroken, clazz,
14171412
"notifyInputChannelBroken", "(Lcom/android/server/input/InputWindowHandle;)V");

0 commit comments

Comments
 (0)