From 1908ec79f0aab512c640b48b086ba4ff9a901a8f Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Fri, 7 Mar 2025 15:57:28 -0800 Subject: Allow EmbeddedWindowController to transfer entire gesture This is needed to maintain some of the previous behaviour that was removed when splitting code was cleaned up. Since this is part of the current API, we should maintain the behaviour advertised by WindowManager::transferTouchGesture, until it's deprecated. Bug: 397979572 Test: TEST=inputflinger_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST Flag: com.android.input.flags.allow_transfer_of_entire_gesture Change-Id: Ifb9335041b7881d72f4b57a59b9aea281e28370f --- .../java/com/android/server/input/InputManagerInternal.java | 7 ++++++- .../java/com/android/server/input/InputManagerService.java | 11 ++++++----- .../com/android/server/input/NativeInputManagerService.java | 4 ++-- .../android/server/inputmethod/InputMethodManagerService.java | 3 ++- .../java/com/android/server/wm/EmbeddedWindowController.java | 5 +++-- .../core/jni/com_android_server_input_InputManagerService.cpp | 7 ++++--- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/services/core/java/com/android/server/input/InputManagerInternal.java b/services/core/java/com/android/server/input/InputManagerInternal.java index 1ace41cba364..2660db4afc5b 100644 --- a/services/core/java/com/android/server/input/InputManagerInternal.java +++ b/services/core/java/com/android/server/input/InputManagerInternal.java @@ -104,11 +104,16 @@ public abstract class InputManagerInternal { * @param fromChannelToken The channel token of a window that has an active touch gesture. * @param toChannelToken The channel token of the window that should receive the gesture in * place of the first. + * @param transferEntireGesture Whether the entire gesture (including subsequent POINTER_DOWN + * events) should be transferred. This should always be set to + * 'false' unless you have the permission from the input team to + * set it to true. This behaviour will be removed in future + * versions. * @return True if the transfer was successful. False if the specified windows don't exist, or * if the source window is not actively receiving a touch gesture at the time of the request. */ public abstract boolean transferTouchGesture(@NonNull IBinder fromChannelToken, - @NonNull IBinder toChannelToken); + @NonNull IBinder toChannelToken, boolean transferEntireGesture); /** * Gets the current position of the mouse cursor. diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java index 6af55300d0b3..f2ededaa2a9c 100644 --- a/services/core/java/com/android/server/input/InputManagerService.java +++ b/services/core/java/com/android/server/input/InputManagerService.java @@ -1370,7 +1370,7 @@ public class InputManagerService extends IInputManager.Stub public boolean startDragAndDrop(@NonNull IBinder fromChannelToken, @NonNull IBinder dragAndDropChannelToken) { return mNative.transferTouchGesture(fromChannelToken, dragAndDropChannelToken, - true /* isDragDrop */); + true /* isDragDrop */, false /* transferEntireGesture */); } /** @@ -1394,11 +1394,11 @@ public class InputManagerService extends IInputManager.Stub * if the source window is not actively receiving a touch gesture at the time of the request. */ public boolean transferTouchGesture(@NonNull IBinder fromChannelToken, - @NonNull IBinder toChannelToken) { + @NonNull IBinder toChannelToken, boolean transferEntireGesture) { Objects.requireNonNull(fromChannelToken); Objects.requireNonNull(toChannelToken); return mNative.transferTouchGesture(fromChannelToken, toChannelToken, - false /* isDragDrop */); + false /* isDragDrop */, transferEntireGesture); } @Override // Binder call @@ -3703,8 +3703,9 @@ public class InputManagerService extends IInputManager.Stub @Override public boolean transferTouchGesture(@NonNull IBinder fromChannelToken, - @NonNull IBinder toChannelToken) { - return InputManagerService.this.transferTouchGesture(fromChannelToken, toChannelToken); + @NonNull IBinder toChannelToken, boolean transferEntireGesture) { + return InputManagerService.this.transferTouchGesture( + fromChannelToken, toChannelToken, transferEntireGesture); } @Override diff --git a/services/core/java/com/android/server/input/NativeInputManagerService.java b/services/core/java/com/android/server/input/NativeInputManagerService.java index 32409d39db3b..ccf1a2c90876 100644 --- a/services/core/java/com/android/server/input/NativeInputManagerService.java +++ b/services/core/java/com/android/server/input/NativeInputManagerService.java @@ -116,7 +116,7 @@ interface NativeInputManagerService { void setMinTimeBetweenUserActivityPokes(long millis); boolean transferTouchGesture(IBinder fromChannelToken, IBinder toChannelToken, - boolean isDragDrop); + boolean isDragDrop, boolean transferEntireGesture); /** * Transfer the current touch gesture to the window identified by 'destChannelToken' positioned @@ -420,7 +420,7 @@ interface NativeInputManagerService { @Override public native boolean transferTouchGesture(IBinder fromChannelToken, IBinder toChannelToken, - boolean isDragDrop); + boolean isDragDrop, boolean transferEntireGesture); @Override @Deprecated diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 2066dbc87a0d..7ff41e309c55 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -5800,7 +5800,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl. return false; } } - return mInputManagerInternal.transferTouchGesture(sourceInputToken, curHostInputToken); + return mInputManagerInternal.transferTouchGesture( + sourceInputToken, curHostInputToken, /* transferEntireGesture */ false); } @Override diff --git a/services/core/java/com/android/server/wm/EmbeddedWindowController.java b/services/core/java/com/android/server/wm/EmbeddedWindowController.java index 64ae21dc69de..1bf65d1e3536 100644 --- a/services/core/java/com/android/server/wm/EmbeddedWindowController.java +++ b/services/core/java/com/android/server/wm/EmbeddedWindowController.java @@ -209,7 +209,8 @@ class EmbeddedWindowController { "Transfer request must originate from owner of transferFromToken"); } final boolean didTransfer = mInputManagerService.transferTouchGesture( - ew.getInputChannelToken(), transferToHostWindowState.mInputChannelToken); + ew.getInputChannelToken(), transferToHostWindowState.mInputChannelToken, + /* transferEntireGesture */ true); if (didTransfer) { ew.mGestureToEmbedded = false; } @@ -228,7 +229,7 @@ class EmbeddedWindowController { } final boolean didTransfer = mInputManagerService.transferTouchGesture( hostWindowState.mInputChannelToken, - ew.getInputChannelToken()); + ew.getInputChannelToken(), /* transferEntireGesture */ true); if (didTransfer) { ew.mGestureToEmbedded = true; mAtmService.mBackNavigationController.onEmbeddedWindowGestureTransferred( diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp index 017284cded8e..e29511564cea 100644 --- a/services/core/jni/com_android_server_input_InputManagerService.cpp +++ b/services/core/jni/com_android_server_input_InputManagerService.cpp @@ -2548,7 +2548,7 @@ static void nativeSetSystemUiLightsOut(JNIEnv* env, jobject nativeImplObj, jbool static jboolean nativeTransferTouchGesture(JNIEnv* env, jobject nativeImplObj, jobject fromChannelTokenObj, jobject toChannelTokenObj, - jboolean isDragDrop) { + jboolean isDragDrop, jboolean transferEntireGesture) { if (fromChannelTokenObj == nullptr || toChannelTokenObj == nullptr) { return JNI_FALSE; } @@ -2558,7 +2558,8 @@ static jboolean nativeTransferTouchGesture(JNIEnv* env, jobject nativeImplObj, NativeInputManager* im = getNativeInputManager(env, nativeImplObj); if (im->getInputManager()->getDispatcher().transferTouchGesture(fromChannelToken, - toChannelToken, isDragDrop)) { + toChannelToken, isDragDrop, + transferEntireGesture)) { return JNI_TRUE; } else { return JNI_FALSE; @@ -3344,7 +3345,7 @@ static const JNINativeMethod gInputManagerMethods[] = { {"requestPointerCapture", "(Landroid/os/IBinder;Z)V", (void*)nativeRequestPointerCapture}, {"setInputDispatchMode", "(ZZ)V", (void*)nativeSetInputDispatchMode}, {"setSystemUiLightsOut", "(Z)V", (void*)nativeSetSystemUiLightsOut}, - {"transferTouchGesture", "(Landroid/os/IBinder;Landroid/os/IBinder;Z)Z", + {"transferTouchGesture", "(Landroid/os/IBinder;Landroid/os/IBinder;ZZ)Z", (void*)nativeTransferTouchGesture}, {"transferTouch", "(Landroid/os/IBinder;I)Z", (void*)nativeTransferTouchOnDisplay}, {"getMousePointerSpeed", "()I", (void*)nativeGetMousePointerSpeed}, -- cgit v1.2.3-59-g8ed1b