Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47d4002d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add transferTouch api" into sc-dev am: c70b38a9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13856964

Change-Id: Ia0025a1fa1a99c407eb9d8b8bb572030b6e49a09
parents 44b96576 c70b38a9
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -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.
+7 −0
Original line number Diff line number Diff line
@@ -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();
+14 −2
Original line number Diff line number Diff line
@@ -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},