summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2010-07-28 14:25:05 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-07-28 14:25:05 -0700
commit9795a25da060f9a7df87da8ab43fb1086d4322a5 (patch)
tree98aec7df18a3721c94524d551b79e6d5420a20b8 /services
parent8190f485539c36803489dcf5f198d03ed87ae8f9 (diff)
parent6d0fec2de3601821f4f44eeb7d7deedebb2b7117 (diff)
downloadframeworks_base-9795a25da060f9a7df87da8ab43fb1086d4322a5.zip
frameworks_base-9795a25da060f9a7df87da8ab43fb1086d4322a5.tar.gz
frameworks_base-9795a25da060f9a7df87da8ab43fb1086d4322a5.tar.bz2
am 6d0fec2d: Refactor input reader to support new device types more easily.
Merge commit '6d0fec2de3601821f4f44eeb7d7deedebb2b7117' into gingerbread-plus-aosp * commit '6d0fec2de3601821f4f44eeb7d7deedebb2b7117': Refactor input reader to support new device types more easily.
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/InputManager.java121
-rw-r--r--services/java/com/android/server/WindowManagerService.java22
-rw-r--r--services/jni/com_android_server_InputManager.cpp144
3 files changed, 174 insertions, 113 deletions
diff --git a/services/java/com/android/server/InputManager.java b/services/java/com/android/server/InputManager.java
index b4f46ab..9a1d017 100644
--- a/services/java/com/android/server/InputManager.java
+++ b/services/java/com/android/server/InputManager.java
@@ -66,13 +66,14 @@ public class InputManager {
private static native void nativeSetDisplaySize(int displayId, int width, int height);
private static native void nativeSetDisplayOrientation(int displayId, int rotation);
- private static native int nativeGetScanCodeState(int deviceId, int deviceClasses,
+ private static native int nativeGetScanCodeState(int deviceId, int sourceMask,
int scanCode);
- private static native int nativeGetKeyCodeState(int deviceId, int deviceClasses,
+ private static native int nativeGetKeyCodeState(int deviceId, int sourceMask,
int keyCode);
- private static native int nativeGetSwitchState(int deviceId, int deviceClasses,
+ private static native int nativeGetSwitchState(int deviceId, int sourceMask,
int sw);
- private static native boolean nativeHasKeys(int[] keyCodes, boolean[] keyExists);
+ private static native boolean nativeHasKeys(int deviceId, int sourceMask,
+ int[] keyCodes, boolean[] keyExists);
private static native void nativeRegisterInputChannel(InputChannel inputChannel);
private static native void nativeUnregisterInputChannel(InputChannel inputChannel);
private static native int nativeInjectKeyEvent(KeyEvent event,
@@ -85,20 +86,28 @@ public class InputManager {
private static native void nativePreemptInputDispatch();
private static native String nativeDump();
- // Device class as defined by EventHub.
- private static final int CLASS_KEYBOARD = 0x00000001;
- private static final int CLASS_ALPHAKEY = 0x00000002;
- private static final int CLASS_TOUCHSCREEN = 0x00000004;
- private static final int CLASS_TRACKBALL = 0x00000008;
- private static final int CLASS_TOUCHSCREEN_MT = 0x00000010;
- private static final int CLASS_DPAD = 0x00000020;
-
// Input event injection constants defined in InputDispatcher.h.
static final int INPUT_EVENT_INJECTION_SUCCEEDED = 0;
static final int INPUT_EVENT_INJECTION_PERMISSION_DENIED = 1;
static final int INPUT_EVENT_INJECTION_FAILED = 2;
static final int INPUT_EVENT_INJECTION_TIMED_OUT = 3;
+ // Key states (may be returned by queries about the current state of a
+ // particular key code, scan code or switch).
+
+ /** The key state is unknown or the requested key itself is not supported. */
+ public static final int KEY_STATE_UNKNOWN = -1;
+
+ /** The key is up. /*/
+ public static final int KEY_STATE_UP = 0;
+
+ /** The key is down. */
+ public static final int KEY_STATE_DOWN = 1;
+
+ /** The key is down but is a virtual key press that is being emulated by the system. */
+ public static final int KEY_STATE_VIRTUAL = 2;
+
+
public InputManager(Context context, WindowManagerService windowManagerService) {
this.mContext = context;
this.mWindowManagerService = windowManagerService;
@@ -150,55 +159,67 @@ public class InputManager {
config.navigation = mNavigationConfig;
}
- public int getScancodeState(int code) {
- return nativeGetScanCodeState(0, -1, code);
- }
-
- public int getScancodeState(int deviceId, int code) {
- return nativeGetScanCodeState(deviceId, -1, code);
- }
-
- public int getTrackballScancodeState(int code) {
- return nativeGetScanCodeState(-1, CLASS_TRACKBALL, code);
- }
-
- public int getDPadScancodeState(int code) {
- return nativeGetScanCodeState(-1, CLASS_DPAD, code);
- }
-
- public int getKeycodeState(int code) {
- return nativeGetKeyCodeState(0, -1, code);
- }
-
- public int getKeycodeState(int deviceId, int code) {
- return nativeGetKeyCodeState(deviceId, -1, code);
- }
-
- public int getTrackballKeycodeState(int code) {
- return nativeGetKeyCodeState(-1, CLASS_TRACKBALL, code);
+ /**
+ * Gets the current state of a key or button by key code.
+ * @param deviceId The input device id, or -1 to consult all devices.
+ * @param sourceMask The input sources to consult, or {@link InputDevice#SOURCE_ANY} to
+ * consider all input sources. An input device is consulted if at least one of its
+ * non-class input source bits matches the specified source mask.
+ * @param keyCode The key code to check.
+ * @return The key state.
+ */
+ public int getKeyCodeState(int deviceId, int sourceMask, int keyCode) {
+ return nativeGetKeyCodeState(deviceId, sourceMask, keyCode);
}
- public int getDPadKeycodeState(int code) {
- return nativeGetKeyCodeState(-1, CLASS_DPAD, code);
- }
-
- public int getSwitchState(int sw) {
- return nativeGetSwitchState(-1, -1, sw);
+ /**
+ * Gets the current state of a key or button by scan code.
+ * @param deviceId The input device id, or -1 to consult all devices.
+ * @param sourceMask The input sources to consult, or {@link InputDevice#SOURCE_ANY} to
+ * consider all input sources. An input device is consulted if at least one of its
+ * non-class input source bits matches the specified source mask.
+ * @param scanCode The scan code to check.
+ * @return The key state.
+ */
+ public int getScanCodeState(int deviceId, int sourceMask, int scanCode) {
+ return nativeGetScanCodeState(deviceId, sourceMask, scanCode);
}
- public int getSwitchState(int deviceId, int sw) {
- return nativeGetSwitchState(deviceId, -1, sw);
+ /**
+ * Gets the current state of a switch by switch code.
+ * @param deviceId The input device id, or -1 to consult all devices.
+ * @param sourceMask The input sources to consult, or {@link InputDevice#SOURCE_ANY} to
+ * consider all input sources. An input device is consulted if at least one of its
+ * non-class input source bits matches the specified source mask.
+ * @param switchCode The switch code to check.
+ * @return The switch state.
+ */
+ public int getSwitchState(int deviceId, int sourceMask, int switchCode) {
+ return nativeGetSwitchState(deviceId, sourceMask, switchCode);
}
- public boolean hasKeys(int[] keyCodes, boolean[] keyExists) {
+ /**
+ * Determines whether the specified key codes are supported by a particular device.
+ * @param deviceId The input device id, or -1 to consult all devices.
+ * @param sourceMask The input sources to consult, or {@link InputDevice#SOURCE_ANY} to
+ * consider all input sources. An input device is consulted if at least one of its
+ * non-class input source bits matches the specified source mask.
+ * @param keyCodes The array of key codes to check.
+ * @param keyExists An array at least as large as keyCodes whose entries will be set
+ * to true or false based on the presence or absence of support for the corresponding
+ * key codes.
+ * @return True if the lookup was successful, false otherwise.
+ */
+ public boolean hasKeys(int deviceId, int sourceMask, int[] keyCodes, boolean[] keyExists) {
if (keyCodes == null) {
throw new IllegalArgumentException("keyCodes must not be null.");
}
- if (keyExists == null) {
- throw new IllegalArgumentException("keyExists must not be null.");
+ if (keyExists == null || keyExists.length < keyCodes.length) {
+ throw new IllegalArgumentException("keyExists must not be null and must be at "
+ + "least as large as keyCodes.");
}
- return nativeHasKeys(keyCodes, keyExists);
+ return nativeHasKeys(deviceId, sourceMask, keyCodes, keyExists);
}
public void registerInputChannel(InputChannel inputChannel) {
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 2e28afb..eb0f343 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -4307,7 +4307,7 @@ public class WindowManagerService extends IWindowManager.Stub
"getSwitchState()")) {
throw new SecurityException("Requires READ_INPUT_STATE permission");
}
- return mInputManager.getSwitchState(sw);
+ return mInputManager.getSwitchState(-1, InputDevice.SOURCE_ANY, sw);
}
public int getSwitchStateForDevice(int devid, int sw) {
@@ -4315,7 +4315,7 @@ public class WindowManagerService extends IWindowManager.Stub
"getSwitchStateForDevice()")) {
throw new SecurityException("Requires READ_INPUT_STATE permission");
}
- return mInputManager.getSwitchState(devid, sw);
+ return mInputManager.getSwitchState(devid, InputDevice.SOURCE_ANY, sw);
}
public int getScancodeState(int sw) {
@@ -4323,7 +4323,7 @@ public class WindowManagerService extends IWindowManager.Stub
"getScancodeState()")) {
throw new SecurityException("Requires READ_INPUT_STATE permission");
}
- return mInputManager.getScancodeState(sw);
+ return mInputManager.getScanCodeState(-1, InputDevice.SOURCE_ANY, sw);
}
public int getScancodeStateForDevice(int devid, int sw) {
@@ -4331,7 +4331,7 @@ public class WindowManagerService extends IWindowManager.Stub
"getScancodeStateForDevice()")) {
throw new SecurityException("Requires READ_INPUT_STATE permission");
}
- return mInputManager.getScancodeState(devid, sw);
+ return mInputManager.getScanCodeState(devid, InputDevice.SOURCE_ANY, sw);
}
public int getTrackballScancodeState(int sw) {
@@ -4339,7 +4339,7 @@ public class WindowManagerService extends IWindowManager.Stub
"getTrackballScancodeState()")) {
throw new SecurityException("Requires READ_INPUT_STATE permission");
}
- return mInputManager.getTrackballScancodeState(sw);
+ return mInputManager.getScanCodeState(-1, InputDevice.SOURCE_TRACKBALL, sw);
}
public int getDPadScancodeState(int sw) {
@@ -4347,7 +4347,7 @@ public class WindowManagerService extends IWindowManager.Stub
"getDPadScancodeState()")) {
throw new SecurityException("Requires READ_INPUT_STATE permission");
}
- return mInputManager.getDPadScancodeState(sw);
+ return mInputManager.getScanCodeState(-1, InputDevice.SOURCE_DPAD, sw);
}
public int getKeycodeState(int sw) {
@@ -4355,7 +4355,7 @@ public class WindowManagerService extends IWindowManager.Stub
"getKeycodeState()")) {
throw new SecurityException("Requires READ_INPUT_STATE permission");
}
- return mInputManager.getKeycodeState(sw);
+ return mInputManager.getKeyCodeState(-1, InputDevice.SOURCE_ANY, sw);
}
public int getKeycodeStateForDevice(int devid, int sw) {
@@ -4363,7 +4363,7 @@ public class WindowManagerService extends IWindowManager.Stub
"getKeycodeStateForDevice()")) {
throw new SecurityException("Requires READ_INPUT_STATE permission");
}
- return mInputManager.getKeycodeState(devid, sw);
+ return mInputManager.getKeyCodeState(devid, InputDevice.SOURCE_ANY, sw);
}
public int getTrackballKeycodeState(int sw) {
@@ -4371,7 +4371,7 @@ public class WindowManagerService extends IWindowManager.Stub
"getTrackballKeycodeState()")) {
throw new SecurityException("Requires READ_INPUT_STATE permission");
}
- return mInputManager.getTrackballKeycodeState(sw);
+ return mInputManager.getKeyCodeState(-1, InputDevice.SOURCE_TRACKBALL, sw);
}
public int getDPadKeycodeState(int sw) {
@@ -4379,11 +4379,11 @@ public class WindowManagerService extends IWindowManager.Stub
"getDPadKeycodeState()")) {
throw new SecurityException("Requires READ_INPUT_STATE permission");
}
- return mInputManager.getDPadKeycodeState(sw);
+ return mInputManager.getKeyCodeState(-1, InputDevice.SOURCE_DPAD, sw);
}
public boolean hasKeys(int[] keycodes, boolean[] keyExists) {
- return mInputManager.hasKeys(keycodes, keyExists);
+ return mInputManager.hasKeys(-1, InputDevice.SOURCE_ANY, keycodes, keyExists);
}
public void enableScreenAfterBoot() {
diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp
index 0992b33..a332376 100644
--- a/services/jni/com_android_server_InputManager.cpp
+++ b/services/jni/com_android_server_InputManager.cpp
@@ -219,11 +219,10 @@ public:
int32_t* width, int32_t* height, int32_t* orientation);
virtual void virtualKeyDownFeedback();
virtual int32_t interceptKey(nsecs_t when, int32_t deviceId,
- bool down, int32_t keyCode, int32_t scanCode, uint32_t policyFlags);
- virtual int32_t interceptTrackball(nsecs_t when, bool buttonChanged, bool buttonDown,
- bool rolled);
- virtual int32_t interceptTouch(nsecs_t when);
- virtual int32_t interceptSwitch(nsecs_t when, int32_t switchCode, int32_t switchValue);
+ bool down, int32_t keyCode, int32_t scanCode, uint32_t& policyFlags);
+ virtual int32_t interceptSwitch(nsecs_t when, int32_t switchCode, int32_t switchValue,
+ uint32_t& policyFlags);
+ virtual int32_t interceptGeneric(nsecs_t when, uint32_t& policyFlags);
virtual bool filterTouchEvents();
virtual bool filterJumpyTouchEvents();
virtual void getVirtualKeyDefinitions(const String8& deviceName,
@@ -343,6 +342,7 @@ private:
InputApplication* mFocusedApplication;
InputApplication mFocusedApplicationStorage; // preallocated storage for mFocusedApplication
+ void dumpDeviceInfo(String8& dump);
void dumpDispatchStateLd(String8& dump);
void logDispatchStateLd();
@@ -409,12 +409,16 @@ NativeInputManager::~NativeInputManager() {
String8 NativeInputManager::dump() {
String8 dump;
- dump.append("Native Input Dispatcher State:\n");
-
{ // acquire lock
AutoMutex _l(mDisplayLock);
+ dump.append("Native Input Dispatcher State:\n");
dumpDispatchStateLd(dump);
+ dump.append("\n");
} // release lock
+
+ dump.append("Input Devices:\n");
+ dumpDeviceInfo(dump);
+
return dump;
}
@@ -566,9 +570,15 @@ bool NativeInputManager::getDisplayInfo(int32_t displayId,
AutoMutex _l(mDisplayLock);
if (mDisplayWidth > 0) {
- *width = mDisplayWidth;
- *height = mDisplayHeight;
- *orientation = mDisplayOrientation;
+ if (width) {
+ *width = mDisplayWidth;
+ }
+ if (height) {
+ *height = mDisplayHeight;
+ }
+ if (orientation) {
+ *orientation = mDisplayOrientation;
+ }
result = true;
}
}
@@ -595,7 +605,7 @@ void NativeInputManager::virtualKeyDownFeedback() {
}
int32_t NativeInputManager::interceptKey(nsecs_t when,
- int32_t deviceId, bool down, int32_t keyCode, int32_t scanCode, uint32_t policyFlags) {
+ int32_t deviceId, bool down, int32_t keyCode, int32_t scanCode, uint32_t& policyFlags) {
#if DEBUG_INPUT_READER_POLICY
LOGD("interceptKey - when=%lld, deviceId=%d, down=%d, keyCode=%d, scanCode=%d, "
"policyFlags=0x%x",
@@ -626,12 +636,12 @@ int32_t NativeInputManager::interceptKey(nsecs_t when,
int32_t actions = InputReaderPolicyInterface::ACTION_NONE;
if (! isScreenOn) {
// Key presses and releases wake the device.
- actions |= InputReaderPolicyInterface::ACTION_WOKE_HERE;
+ policyFlags |= POLICY_FLAG_WOKE_HERE;
}
if (! isScreenBright) {
// Key presses and releases brighten the screen if dimmed.
- actions |= InputReaderPolicyInterface::ACTION_BRIGHT_HERE;
+ policyFlags |= POLICY_FLAG_BRIGHT_HERE;
}
if (wmActions & WM_ACTION_GO_TO_SLEEP) {
@@ -658,42 +668,20 @@ int32_t NativeInputManager::interceptKey(nsecs_t when,
return actions;
}
-int32_t NativeInputManager::interceptTouch(nsecs_t when) {
+int32_t NativeInputManager::interceptGeneric(nsecs_t when, uint32_t& policyFlags) {
#if DEBUG_INPUT_READER_POLICY
- LOGD("interceptTouch - when=%lld", when);
+ LOGD("interceptGeneric - when=%lld, policyFlags=0x%x", when, policyFlags);
#endif
int32_t actions = InputReaderPolicyInterface::ACTION_NONE;
if (isScreenOn()) {
- // Only dispatch touch events when the device is awake.
+ // Only dispatch events when the device is awake.
// Do not wake the device.
actions |= InputReaderPolicyInterface::ACTION_DISPATCH;
if (! isScreenBright()) {
// Brighten the screen if dimmed.
- actions |= InputReaderPolicyInterface::ACTION_BRIGHT_HERE;
- }
- }
-
- return actions;
-}
-
-int32_t NativeInputManager::interceptTrackball(nsecs_t when,
- bool buttonChanged, bool buttonDown, bool rolled) {
-#if DEBUG_INPUT_READER_POLICY
- LOGD("interceptTrackball - when=%lld, buttonChanged=%d, buttonDown=%d, rolled=%d",
- when, buttonChanged, buttonDown, rolled);
-#endif
-
- int32_t actions = InputReaderPolicyInterface::ACTION_NONE;
- if (isScreenOn()) {
- // Only dispatch trackball events when the device is awake.
- // Do not wake the device.
- actions |= InputReaderPolicyInterface::ACTION_DISPATCH;
-
- if (! isScreenBright()) {
- // Brighten the screen if dimmed.
- actions |= InputReaderPolicyInterface::ACTION_BRIGHT_HERE;
+ policyFlags |= POLICY_FLAG_BRIGHT_HERE;
}
}
@@ -701,10 +689,10 @@ int32_t NativeInputManager::interceptTrackball(nsecs_t when,
}
int32_t NativeInputManager::interceptSwitch(nsecs_t when, int32_t switchCode,
- int32_t switchValue) {
+ int32_t switchValue, uint32_t& policyFlags) {
#if DEBUG_INPUT_READER_POLICY
- LOGD("interceptSwitch - when=%lld, switchCode=%d, switchValue=%d",
- when, switchCode, switchValue);
+ LOGD("interceptSwitch - when=%lld, switchCode=%d, switchValue=%d, policyFlags=0x%x",
+ when, switchCode, switchValue, policyFlags);
#endif
JNIEnv* env = jniEnv();
@@ -1718,6 +1706,56 @@ void NativeInputManager::pokeUserActivity(nsecs_t eventTime, int32_t eventType)
android_server_PowerManagerService_userActivity(eventTime, eventType);
}
+static void dumpMotionRange(String8& dump,
+ const char* name, const InputDeviceInfo::MotionRange* range) {
+ if (range) {
+ dump.appendFormat(" %s = { min: %0.3f, max: %0.3f, flat: %0.3f, fuzz: %0.3f }\n",
+ name, range->min, range->max, range->flat, range->fuzz);
+ }
+}
+
+#define DUMP_MOTION_RANGE(range) \
+ dumpMotionRange(dump, #range, deviceInfo.getMotionRange(AINPUT_MOTION_RANGE_##range));
+
+void NativeInputManager::dumpDeviceInfo(String8& dump) {
+ Vector<int32_t> deviceIds;
+ mInputManager->getInputDeviceIds(deviceIds);
+
+ InputDeviceInfo deviceInfo;
+ for (size_t i = 0; i < deviceIds.size(); i++) {
+ int32_t deviceId = deviceIds[i];
+
+ status_t result = mInputManager->getInputDeviceInfo(deviceId, & deviceInfo);
+ if (result == NAME_NOT_FOUND) {
+ continue;
+ } else if (result != OK) {
+ dump.appendFormat(" ** Unexpected error %d getting information about input devices.\n",
+ result);
+ continue;
+ }
+
+ dump.appendFormat(" Device %d: '%s'\n",
+ deviceInfo.getId(), deviceInfo.getName().string());
+ dump.appendFormat(" sources = 0x%08x\n",
+ deviceInfo.getSources());
+ dump.appendFormat(" keyboardType = %d\n",
+ deviceInfo.getKeyboardType());
+
+ dump.append(" motion ranges:\n");
+ DUMP_MOTION_RANGE(X);
+ DUMP_MOTION_RANGE(Y);
+ DUMP_MOTION_RANGE(PRESSURE);
+ DUMP_MOTION_RANGE(SIZE);
+ DUMP_MOTION_RANGE(TOUCH_MAJOR);
+ DUMP_MOTION_RANGE(TOUCH_MINOR);
+ DUMP_MOTION_RANGE(TOOL_MAJOR);
+ DUMP_MOTION_RANGE(TOOL_MINOR);
+ DUMP_MOTION_RANGE(ORIENTATION);
+ }
+}
+
+#undef DUMP_MOTION_RANGE
+
void NativeInputManager::logDispatchStateLd() {
String8 dump;
dumpDispatchStateLd(dump);
@@ -1899,36 +1937,37 @@ static void android_server_InputManager_nativeSetDisplayOrientation(JNIEnv* env,
}
static jint android_server_InputManager_nativeGetScanCodeState(JNIEnv* env, jclass clazz,
- jint deviceId, jint deviceClasses, jint scanCode) {
+ jint deviceId, jint sourceMask, jint scanCode) {
if (checkInputManagerUnitialized(env)) {
return AKEY_STATE_UNKNOWN;
}
return gNativeInputManager->getInputManager()->getScanCodeState(
- deviceId, deviceClasses, scanCode);
+ deviceId, uint32_t(sourceMask), scanCode);
}
static jint android_server_InputManager_nativeGetKeyCodeState(JNIEnv* env, jclass clazz,
- jint deviceId, jint deviceClasses, jint keyCode) {
+ jint deviceId, jint sourceMask, jint keyCode) {
if (checkInputManagerUnitialized(env)) {
return AKEY_STATE_UNKNOWN;
}
return gNativeInputManager->getInputManager()->getKeyCodeState(
- deviceId, deviceClasses, keyCode);
+ deviceId, uint32_t(sourceMask), keyCode);
}
static jint android_server_InputManager_nativeGetSwitchState(JNIEnv* env, jclass clazz,
- jint deviceId, jint deviceClasses, jint sw) {
+ jint deviceId, jint sourceMask, jint sw) {
if (checkInputManagerUnitialized(env)) {
return AKEY_STATE_UNKNOWN;
}
- return gNativeInputManager->getInputManager()->getSwitchState(deviceId, deviceClasses, sw);
+ return gNativeInputManager->getInputManager()->getSwitchState(
+ deviceId, uint32_t(sourceMask), sw);
}
static jboolean android_server_InputManager_nativeHasKeys(JNIEnv* env, jclass clazz,
- jintArray keyCodes, jbooleanArray outFlags) {
+ jint deviceId, jint sourceMask, jintArray keyCodes, jbooleanArray outFlags) {
if (checkInputManagerUnitialized(env)) {
return JNI_FALSE;
}
@@ -1937,8 +1976,9 @@ static jboolean android_server_InputManager_nativeHasKeys(JNIEnv* env, jclass cl
uint8_t* flags = env->GetBooleanArrayElements(outFlags, NULL);
jsize numCodes = env->GetArrayLength(keyCodes);
jboolean result;
- if (numCodes == env->GetArrayLength(outFlags)) {
- result = gNativeInputManager->getInputManager()->hasKeys(numCodes, codes, flags);
+ if (numCodes == env->GetArrayLength(keyCodes)) {
+ result = gNativeInputManager->getInputManager()->hasKeys(
+ deviceId, uint32_t(sourceMask), numCodes, codes, flags);
} else {
result = JNI_FALSE;
}
@@ -2102,7 +2142,7 @@ static JNINativeMethod gInputManagerMethods[] = {
(void*) android_server_InputManager_nativeGetKeyCodeState },
{ "nativeGetSwitchState", "(III)I",
(void*) android_server_InputManager_nativeGetSwitchState },
- { "nativeHasKeys", "([I[Z)Z",
+ { "nativeHasKeys", "(II[I[Z)Z",
(void*) android_server_InputManager_nativeHasKeys },
{ "nativeRegisterInputChannel", "(Landroid/view/InputChannel;)V",
(void*) android_server_InputManager_nativeRegisterInputChannel },