Add transferTouch api

The new api will be similar to "transferTouchFocus" and
"pilferPointers".

In the new api, we will be transferring touch, wherever it might be,
to the specified window. This will be used in the case where the app
is fullscreen, and the user swipes down to check notifications.

Currently, the behaviour is like this: user swipes once to show the
status bar, and then swipes again to show the notification shade.

The desired experience is for user to swipe once to show the
notification shade.

This new api will allow the StatusBar to transfer touch to the
notification shade, so that it can continue to get expanded.

Bug: 177997773
Test: atest inputflinger_tests
Change-Id: If38d395669104d6aebb68f97e830fa80393b50d5
This commit is contained in:
Siarhei Vishniakou
2021-03-13 02:01:11 +00:00
parent 4f2e331f25
commit 571704424b
3 changed files with 35 additions and 2 deletions

View File

@@ -313,6 +313,7 @@ public class InputManagerService extends IInputManager.Stub
private static native void nativeSetFocusedDisplay(long ptr, int displayId);
private static native boolean nativeTransferTouchFocus(long ptr,
IBinder fromChannelToken, IBinder toChannelToken, boolean isDragDrop);
private static native boolean nativeTransferTouch(long ptr, IBinder destChannelToken);
private static native void nativeSetPointerSpeed(long ptr, int speed);
private static native void nativeSetShowTouches(long ptr, boolean enabled);
private static native void nativeSetInteractive(long ptr, boolean interactive);
@@ -675,6 +676,19 @@ public class InputManagerService extends IInputManager.Stub
return nativeHasKeys(mPtr, deviceId, sourceMask, keyCodes, keyExists);
}
/**
* Transfer the current touch gesture to the provided window.
*
* @param destChannelToken The token of the window or input channel that should receive the
* gesture
* @return True if the transfer succeeded, false if there was no active touch gesture happening
*/
public boolean transferTouch(IBinder destChannelToken) {
// TODO(b/162194035): Replace this with a SPY window
Objects.requireNonNull(destChannelToken, "destChannelToken must not be null.");
return nativeTransferTouch(mPtr, destChannelToken);
}
/**
* Creates an input channel that will receive all input from the input dispatcher.
* @param inputChannelName The input channel name.

View File

@@ -2682,6 +2682,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
}
}
/**
* Move the touch gesture from the currently touched window on this display to this window.
*/
public boolean transferTouch() {
return mWmService.mInputManager.transferTouch(mInputChannelToken);
}
void disposeInputChannel() {
if (mDeadWindowEventReceiver != null) {
mDeadWindowEventReceiver.dispose();

View File

@@ -1834,8 +1834,19 @@ static jboolean nativeTransferTouchFocus(JNIEnv* env, jclass /* clazz */, jlong
}
}
static void nativeSetPointerSpeed(JNIEnv* /* env */,
jclass /* clazz */, jlong ptr, jint speed) {
static jboolean nativeTransferTouch(JNIEnv* env, jclass /* clazz */, jlong ptr,
jobject destChannelTokenObj) {
sp<IBinder> destChannelToken = ibinderForJavaObject(env, destChannelTokenObj);
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
if (im->getInputManager()->getDispatcher()->transferTouch(destChannelToken)) {
return JNI_TRUE;
} else {
return JNI_FALSE;
}
}
static void nativeSetPointerSpeed(JNIEnv* /* env */, jclass /* clazz */, jlong ptr, jint speed) {
NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
im->setPointerSpeed(speed);
@@ -2308,6 +2319,7 @@ static const JNINativeMethod gInputManagerMethods[] = {
{"nativeSetSystemUiLightsOut", "(JZ)V", (void*)nativeSetSystemUiLightsOut},
{"nativeTransferTouchFocus", "(JLandroid/os/IBinder;Landroid/os/IBinder;Z)Z",
(void*)nativeTransferTouchFocus},
{"nativeTransferTouch", "(JLandroid/os/IBinder;)Z", (void*)nativeTransferTouch},
{"nativeSetPointerSpeed", "(JI)V", (void*)nativeSetPointerSpeed},
{"nativeSetShowTouches", "(JZ)V", (void*)nativeSetShowTouches},
{"nativeSetInteractive", "(JZ)V", (void*)nativeSetInteractive},