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

Commit 44a26197 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "TouchEvent (2/n): Receiving touch mode events in InputEventReceiver"

parents 573e1525 fb5287c0
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -170,6 +170,16 @@ public abstract class InputEventReceiver {
    public void onDragEvent(boolean isExiting, float x, float y) {
    }

    /**
     * Called when the display for the window associated with the input channel has entered or
     * exited touch mode.
     *
     * @param isInTouchMode {@code true} if the display showing the window associated with the
     *                                  input channel entered touch mode.
     */
    public void onTouchModeChanged(boolean isInTouchMode) {
    }

    /**
     * Called when a batched input event is pending.
     *
+13 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ static struct {
    jmethodID onPointerCaptureEvent;
    jmethodID onDragEvent;
    jmethodID onBatchedInputEventPending;
    jmethodID onTouchModeChanged;
} gInputEventReceiverClassInfo;

// Add prefix to the beginning of each line in 'str'
@@ -424,6 +425,18 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
                finishInputEvent(seq, true /* handled */);
                continue;
            }
            case AINPUT_EVENT_TYPE_TOUCH_MODE: {
                const TouchModeEvent* touchModeEvent = static_cast<TouchModeEvent*>(inputEvent);
                if (kDebugDispatchCycle) {
                    ALOGD("channel '%s' ~ Received touch mode event: isInTouchMode=%s",
                          getInputChannelName().c_str(), toString(touchModeEvent->isInTouchMode()));
                }
                env->CallVoidMethod(receiverObj.get(),
                                    gInputEventReceiverClassInfo.onTouchModeChanged,
                                    jboolean(touchModeEvent->isInTouchMode()));
                finishInputEvent(seq, true /* handled */);
                continue;
            }

            default:
                assert(false); // InputConsumer should prevent this from ever happening