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

Commit 7c48ce83 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

SyncPointerCapture (4/n): Receive capture events in InputEventReceiver

Since a capture event was added to the InputChannel, this CL lets
InputEventReceiver receive the capture events sent by the publisher.

Bug: 141749603
Test: build, crosshatch boots
Change-Id: I608f3cf86d96e4d2b00b28f88fa2b7aa6e83b6dc
parent f7e5db73
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -143,6 +143,20 @@ public abstract class InputEventReceiver {
    public void onFocusEvent(boolean hasFocus, boolean inTouchMode) {
    }

    /**
     * Called when a Pointer Capture event is received.
     *
     * @param pointerCaptureEnabled if true, the window associated with this input channel has just
     *                              received Pointer Capture
     *                              if false, the window associated with this input channel has just
     *                              lost Pointer Capture
     * @see View#requestPointerCapture()
     * @see View#releasePointerCapture()
     */
    // Called from native code.
    public void onPointerCaptureEvent(boolean pointerCaptureEnabled) {
    }

    /**
     * Called when a batched input event is pending.
     *
+17 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ static struct {

    jmethodID dispatchInputEvent;
    jmethodID onFocusEvent;
    jmethodID onPointerCaptureEvent;
    jmethodID onBatchedInputEventPending;
} gInputEventReceiverClassInfo;

@@ -345,6 +346,19 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
                finishInputEvent(seq, true /* handled */);
                continue;
            }
            case AINPUT_EVENT_TYPE_CAPTURE: {
                const CaptureEvent* captureEvent = static_cast<CaptureEvent*>(inputEvent);
                if (kDebugDispatchCycle) {
                    ALOGD("channel '%s' ~ Received capture event: pointerCaptureEnabled=%s",
                          getInputChannelName().c_str(),
                          toString(captureEvent->getPointerCaptureEnabled()));
                }
                env->CallVoidMethod(receiverObj.get(),
                                    gInputEventReceiverClassInfo.onPointerCaptureEvent,
                                    jboolean(captureEvent->getPointerCaptureEnabled()));
                finishInputEvent(seq, true /* handled */);
                continue;
            }

            default:
                assert(false); // InputConsumer should prevent this from ever happening
@@ -489,6 +503,9 @@ int register_android_view_InputEventReceiver(JNIEnv* env) {
            "dispatchInputEvent", "(ILandroid/view/InputEvent;)V");
    gInputEventReceiverClassInfo.onFocusEvent =
            GetMethodIDOrDie(env, gInputEventReceiverClassInfo.clazz, "onFocusEvent", "(ZZ)V");
    gInputEventReceiverClassInfo.onPointerCaptureEvent =
            GetMethodIDOrDie(env, gInputEventReceiverClassInfo.clazz, "onPointerCaptureEvent",
                             "(Z)V");
    gInputEventReceiverClassInfo.onBatchedInputEventPending =
            GetMethodIDOrDie(env, gInputEventReceiverClassInfo.clazz, "onBatchedInputEventPending",
                             "(I)V");