From 1d9dfc5dcf459e85cffcb762ffdb9b9a4abbfd67 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Thu, 16 Jul 2009 11:11:18 -0400 Subject: EventHub: Add support for excluding devices from being opened by as a keyboard. This will be used to avoid unnecessarily listening to data from sensors that function as event devices. Signed-off-by: Mike Lockwood --- services/jni/com_android_server_KeyInputQueue.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'services/jni') diff --git a/services/jni/com_android_server_KeyInputQueue.cpp b/services/jni/com_android_server_KeyInputQueue.cpp index afca1f7..f27596c 100644 --- a/services/jni/com_android_server_KeyInputQueue.cpp +++ b/services/jni/com_android_server_KeyInputQueue.cpp @@ -110,6 +110,23 @@ android_server_KeyInputQueue_getDeviceName(JNIEnv* env, jobject clazz, return NULL; } +static void +android_server_KeyInputQueue_addExcludedDevice(JNIEnv* env, jobject clazz, + jstring deviceName) +{ + gLock.lock(); + sp hub = gHub; + if (hub == NULL) { + hub = new EventHub; + gHub = hub; + } + gLock.unlock(); + + const char* nameStr = env->GetStringUTFChars(deviceName, NULL); + gHub->addExcludedDevice(nameStr); + env->ReleaseStringUTFChars(deviceName, nameStr); +} + static jboolean android_server_KeyInputQueue_getAbsoluteInfo(JNIEnv* env, jobject clazz, jint deviceId, jint axis, @@ -255,6 +272,8 @@ static JNINativeMethod gInputMethods[] = { (void*) android_server_KeyInputQueue_getDeviceClasses }, { "getDeviceName", "(I)Ljava/lang/String;", (void*) android_server_KeyInputQueue_getDeviceName }, + { "addExcludedDevice", "(Ljava/lang/String;)V", + (void*) android_server_KeyInputQueue_addExcludedDevice }, { "getAbsoluteInfo", "(IILcom/android/server/InputDevice$AbsoluteInfo;)Z", (void*) android_server_KeyInputQueue_getAbsoluteInfo }, { "getSwitchState", "(I)I", -- cgit v1.1