Add support for transferring touch focus.
Prerequisite for drag and drop.
Change-Id: Iedbe93ed0f3e1c4083130fe66b4ba06d416afce0
diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp
index 6f52f24..e1e54fc 100644
--- a/services/jni/com_android_server_InputManager.cpp
+++ b/services/jni/com_android_server_InputManager.cpp
@@ -1286,6 +1286,25 @@
env->SetIntField(configObj, gConfigurationClassInfo.navigation, config.navigation);
}
+static jboolean android_server_InputManager_nativeTransferTouchFocus(JNIEnv* env,
+ jclass clazz, jobject fromChannelObj, jobject toChannelObj) {
+ if (checkInputManagerUnitialized(env)) {
+ return false;
+ }
+
+ sp<InputChannel> fromChannel =
+ android_view_InputChannel_getInputChannel(env, fromChannelObj);
+ sp<InputChannel> toChannel =
+ android_view_InputChannel_getInputChannel(env, toChannelObj);
+
+ if (fromChannel == NULL || toChannel == NULL) {
+ return false;
+ }
+
+ return gNativeInputManager->getInputManager()->getDispatcher()->
+ transferTouchFocus(fromChannel, toChannel);
+}
+
static jstring android_server_InputManager_nativeDump(JNIEnv* env, jclass clazz) {
if (checkInputManagerUnitialized(env)) {
return NULL;
@@ -1334,6 +1353,8 @@
(void*) android_server_InputManager_nativeGetInputDeviceIds },
{ "nativeGetInputConfiguration", "(Landroid/content/res/Configuration;)V",
(void*) android_server_InputManager_nativeGetInputConfiguration },
+ { "nativeTransferTouchFocus", "(Landroid/view/InputChannel;Landroid/view/InputChannel;)Z",
+ (void*) android_server_InputManager_nativeTransferTouchFocus },
{ "nativeDump", "()Ljava/lang/String;",
(void*) android_server_InputManager_nativeDump },
};