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

Commit ae478d3e authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Add MotionClassification to NotifyMotionArgs

This classification will be set in the InputClassifier stage and will
get passed on to MotionEvent. It will be consumed in user-facing API
MotionEvent.getClassification() that will provide an IntDef
classification.

The ultimate user will be GestureDetector, View, and other similar APIs
that provide information about long press. The goal is to provide means
for accelerating the long-press gesture.

Bug: 62940136
Test: Integration tested in upper layers on MotionEvent.
Change-Id: I66e062c21c6a860a3abb16e265e37b18ebef1bcb
parent 49e59220
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2691,7 +2691,7 @@ void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) {
            event.initialize(args->deviceId, args->source, args->displayId,
                    args->action, args->actionButton,
                    args->flags, args->edgeFlags, args->metaState, args->buttonState,
                    MotionClassification::NONE, 0, 0, args->xPrecision, args->yPrecision,
                    args->classification, 0, 0, args->xPrecision, args->yPrecision,
                    args->downTime, args->eventTime,
                    args->pointerCount, args->pointerProperties, args->pointerCoords);

+4 −4
Original line number Diff line number Diff line
@@ -71,8 +71,8 @@ void NotifyKeyArgs::notify(const sp<InputListenerInterface>& listener) const {
NotifyMotionArgs::NotifyMotionArgs(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId,
        uint32_t source, int32_t displayId, uint32_t policyFlags,
        int32_t action, int32_t actionButton, int32_t flags, int32_t metaState,
        int32_t buttonState, int32_t edgeFlags, uint32_t deviceTimestamp,
        uint32_t pointerCount,
        int32_t buttonState, MotionClassification classification,
        int32_t edgeFlags, uint32_t deviceTimestamp, uint32_t pointerCount,
        const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
        float xPrecision, float yPrecision, nsecs_t downTime,
        const std::vector<TouchVideoFrame>& videoFrames) :
@@ -80,7 +80,7 @@ NotifyMotionArgs::NotifyMotionArgs(uint32_t sequenceNum, nsecs_t eventTime, int3
        displayId(displayId), policyFlags(policyFlags),
        action(action), actionButton(actionButton),
        flags(flags), metaState(metaState), buttonState(buttonState),
        edgeFlags(edgeFlags), deviceTimestamp(deviceTimestamp),
        classification(classification), edgeFlags(edgeFlags), deviceTimestamp(deviceTimestamp),
        pointerCount(pointerCount),
        xPrecision(xPrecision), yPrecision(yPrecision), downTime(downTime),
        videoFrames(videoFrames) {
@@ -95,7 +95,7 @@ NotifyMotionArgs::NotifyMotionArgs(const NotifyMotionArgs& other) :
        source(other.source), displayId(other.displayId), policyFlags(other.policyFlags),
        action(other.action), actionButton(other.actionButton), flags(other.flags),
        metaState(other.metaState), buttonState(other.buttonState),
        edgeFlags(other.edgeFlags),
        classification(other.classification), edgeFlags(other.edgeFlags),
        deviceTimestamp(other.deviceTimestamp), pointerCount(other.pointerCount),
        xPrecision(other.xPrecision), yPrecision(other.yPrecision), downTime(other.downTime),
        videoFrames(other.videoFrames) {
+30 −26
Original line number Diff line number Diff line
@@ -2834,7 +2834,8 @@ void CursorInputMapper::sync(nsecs_t when) {
                NotifyMotionArgs releaseArgs(mContext->getNextSequenceNum(), when, getDeviceId(),
                        mSource, displayId, policyFlags,
                        AMOTION_EVENT_ACTION_BUTTON_RELEASE, actionButton, 0,
                        metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
                        metaState, buttonState,
                        MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
                        /* deviceTimestamp */ 0, 1, &pointerProperties, &pointerCoords,
                        mXPrecision, mYPrecision, downTime, /* videoFrames */ {});
                getListener()->notifyMotion(&releaseArgs);
@@ -2843,7 +2844,7 @@ void CursorInputMapper::sync(nsecs_t when) {

        NotifyMotionArgs args(mContext->getNextSequenceNum(), when, getDeviceId(), mSource,
                displayId, policyFlags, motionEventAction, 0, 0, metaState, currentButtonState,
                AMOTION_EVENT_EDGE_FLAG_NONE,
                MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
                /* deviceTimestamp */ 0, 1, &pointerProperties, &pointerCoords,
                mXPrecision, mYPrecision, downTime, /* videoFrames */ {});
        getListener()->notifyMotion(&args);
@@ -2855,7 +2856,8 @@ void CursorInputMapper::sync(nsecs_t when) {
                buttonState |= actionButton;
                NotifyMotionArgs pressArgs(mContext->getNextSequenceNum(), when, getDeviceId(),
                        mSource, displayId, policyFlags, AMOTION_EVENT_ACTION_BUTTON_PRESS,
                        actionButton, 0, metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
                        actionButton, 0, metaState, buttonState,
                        MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
                        /* deviceTimestamp */ 0, 1, &pointerProperties, &pointerCoords,
                        mXPrecision, mYPrecision, downTime, /* videoFrames */ {});
                getListener()->notifyMotion(&pressArgs);
@@ -2869,7 +2871,8 @@ void CursorInputMapper::sync(nsecs_t when) {
                && (mSource == AINPUT_SOURCE_MOUSE)) {
            NotifyMotionArgs hoverArgs(mContext->getNextSequenceNum(), when, getDeviceId(),
                    mSource, displayId, policyFlags, AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0,
                    metaState, currentButtonState, AMOTION_EVENT_EDGE_FLAG_NONE,
                    metaState, currentButtonState,
                    MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
                    /* deviceTimestamp */ 0, 1, &pointerProperties, &pointerCoords,
                    mXPrecision, mYPrecision, downTime, /* videoFrames */ {});
            getListener()->notifyMotion(&hoverArgs);
@@ -2883,7 +2886,7 @@ void CursorInputMapper::sync(nsecs_t when) {
            NotifyMotionArgs scrollArgs(mContext->getNextSequenceNum(), when, getDeviceId(),
                    mSource, displayId, policyFlags,
                    AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, currentButtonState,
                    AMOTION_EVENT_EDGE_FLAG_NONE,
                    MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
                    /* deviceTimestamp */ 0, 1, &pointerProperties, &pointerCoords,
                    mXPrecision, mYPrecision, downTime, /* videoFrames */ {});
            getListener()->notifyMotion(&scrollArgs);
@@ -3014,8 +3017,8 @@ void RotaryEncoderInputMapper::sync(nsecs_t when) {

        NotifyMotionArgs scrollArgs(mContext->getNextSequenceNum(), when, getDeviceId(),
                mSource, displayId, policyFlags,
                AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, 0,
                AMOTION_EVENT_EDGE_FLAG_NONE,
                AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, /* buttonState */ 0,
                MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
                /* deviceTimestamp */ 0, 1, &pointerProperties, &pointerCoords,
                0, 0, 0, /* videoFrames */ {});
        getListener()->notifyMotion(&scrollArgs);
@@ -5413,7 +5416,7 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag
        NotifyMotionArgs args(mContext->getNextSequenceNum(), when, getDeviceId(),
                mSource, displayId, policyFlags,
                AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0,
                metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
                metaState, buttonState, MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
                /* deviceTimestamp */ 0, 1, &pointerProperties, &pointerCoords,
                0, 0, mPointerGesture.downTime, /* videoFrames */ {});
        getListener()->notifyMotion(&args);
@@ -6338,8 +6341,8 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
        // Send up.
        NotifyMotionArgs args(mContext->getNextSequenceNum(), when, getDeviceId(),
                mSource, displayId, policyFlags,
                AMOTION_EVENT_ACTION_UP, 0, 0, metaState, mLastRawState.buttonState, 0,
                /* deviceTimestamp */ 0,
                AMOTION_EVENT_ACTION_UP, 0, 0, metaState, mLastRawState.buttonState,
                MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, /* deviceTimestamp */ 0,
                1, &mPointerSimple.lastProperties, &mPointerSimple.lastCoords,
                mOrientedXPrecision, mOrientedYPrecision,
                mPointerSimple.downTime, /* videoFrames */ {});
@@ -6352,8 +6355,8 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
        // Send hover exit.
        NotifyMotionArgs args(mContext->getNextSequenceNum(), when, getDeviceId(),
                mSource, displayId, policyFlags,
                AMOTION_EVENT_ACTION_HOVER_EXIT, 0, 0, metaState, mLastRawState.buttonState, 0,
                /* deviceTimestamp */ 0,
                AMOTION_EVENT_ACTION_HOVER_EXIT, 0, 0, metaState, mLastRawState.buttonState,
                MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, /* deviceTimestamp */ 0,
                1, &mPointerSimple.lastProperties, &mPointerSimple.lastCoords,
                mOrientedXPrecision, mOrientedYPrecision,
                mPointerSimple.downTime, /* videoFrames */ {});
@@ -6368,7 +6371,8 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
            // Send down.
            NotifyMotionArgs args(mContext->getNextSequenceNum(), when, getDeviceId(),
                    mSource, displayId, policyFlags,
                    AMOTION_EVENT_ACTION_DOWN, 0, 0, metaState, mCurrentRawState.buttonState, 0,
                    AMOTION_EVENT_ACTION_DOWN, 0, 0, metaState, mCurrentRawState.buttonState,
                    MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE,
                    /* deviceTimestamp */ 0,
                    1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
                    mOrientedXPrecision, mOrientedYPrecision,
@@ -6379,8 +6383,8 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
        // Send move.
        NotifyMotionArgs args(mContext->getNextSequenceNum(), when, getDeviceId(),
                mSource, displayId, policyFlags,
                AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, mCurrentRawState.buttonState, 0,
                /* deviceTimestamp */ 0,
                AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, mCurrentRawState.buttonState,
                MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, /* deviceTimestamp */ 0,
                1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
                mOrientedXPrecision, mOrientedYPrecision,
                mPointerSimple.downTime, /* videoFrames */ {});
@@ -6395,8 +6399,8 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
            NotifyMotionArgs args(mContext->getNextSequenceNum(), when, getDeviceId(),
                    mSource, displayId, policyFlags,
                    AMOTION_EVENT_ACTION_HOVER_ENTER, 0, 0, metaState,
                    mCurrentRawState.buttonState, 0,
                    /* deviceTimestamp */ 0,
                    mCurrentRawState.buttonState, MotionClassification::NONE,
                    AMOTION_EVENT_EDGE_FLAG_NONE, /* deviceTimestamp */ 0,
                    1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
                    mOrientedXPrecision, mOrientedYPrecision,
                    mPointerSimple.downTime, /* videoFrames */ {});
@@ -6407,8 +6411,8 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
        NotifyMotionArgs args(mContext->getNextSequenceNum(), when, getDeviceId(),
                mSource, displayId, policyFlags,
                AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0, metaState,
                mCurrentRawState.buttonState, 0,
                /* deviceTimestamp */ 0,
                mCurrentRawState.buttonState, MotionClassification::NONE,
                AMOTION_EVENT_EDGE_FLAG_NONE, /* deviceTimestamp */ 0,
                1, &mPointerSimple.currentProperties, &mPointerSimple.currentCoords,
                mOrientedXPrecision, mOrientedYPrecision,
                mPointerSimple.downTime, /* videoFrames */ {});
@@ -6429,8 +6433,8 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,

        NotifyMotionArgs args(mContext->getNextSequenceNum(), when, getDeviceId(),
                mSource, displayId, policyFlags,
                AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, mCurrentRawState.buttonState, 0,
                /* deviceTimestamp */ 0,
                AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, mCurrentRawState.buttonState,
                MotionClassification::NONE, AMOTION_EVENT_EDGE_FLAG_NONE, /* deviceTimestamp */ 0,
                1, &mPointerSimple.currentProperties, &pointerCoords,
                mOrientedXPrecision, mOrientedYPrecision,
                mPointerSimple.downTime, /* videoFrames */ {});
@@ -6497,8 +6501,8 @@ void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32
    std::vector<TouchVideoFrame> frames = mDevice->getEventHub()->getVideoFrames(deviceId);
    NotifyMotionArgs args(mContext->getNextSequenceNum(), when, deviceId,
            source, displayId, policyFlags,
            action, actionButton, flags, metaState, buttonState, edgeFlags,
            deviceTimestamp, pointerCount, pointerProperties, pointerCoords,
            action, actionButton, flags, metaState, buttonState, MotionClassification::NONE,
            edgeFlags, deviceTimestamp, pointerCount, pointerProperties, pointerCoords,
            xPrecision, yPrecision, downTime, std::move(frames));
    getListener()->notifyMotion(&args);
}
@@ -7422,9 +7426,9 @@ void JoystickInputMapper::sync(nsecs_t when, bool force) {

    NotifyMotionArgs args(mContext->getNextSequenceNum(), when, getDeviceId(),
            AINPUT_SOURCE_JOYSTICK, ADISPLAY_ID_NONE, policyFlags,
            AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
            /* deviceTimestamp */ 0, 1, &pointerProperties, &pointerCoords,
            0, 0, 0, /* videoFrames */ {});
            AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, buttonState, MotionClassification::NONE,
            AMOTION_EVENT_EDGE_FLAG_NONE, /* deviceTimestamp */ 0, 1,
            &pointerProperties, &pointerCoords, 0, 0, 0, /* videoFrames */ {});
    getListener()->notifyMotion(&args);
}

+5 −1
Original line number Diff line number Diff line
@@ -99,6 +99,10 @@ struct NotifyMotionArgs : public NotifyArgs {
    int32_t flags;
    int32_t metaState;
    int32_t buttonState;
    /**
     * Classification of the current touch gesture
     */
    MotionClassification classification;
    int32_t edgeFlags;
    /**
     * A timestamp in the input device's time base, not the platform's.
@@ -120,7 +124,7 @@ struct NotifyMotionArgs : public NotifyArgs {
    NotifyMotionArgs(uint32_t sequenceNum, nsecs_t eventTime, int32_t deviceId, uint32_t source,
            int32_t displayId, uint32_t policyFlags,
            int32_t action, int32_t actionButton, int32_t flags,
            int32_t metaState, int32_t buttonState,
            int32_t metaState, int32_t buttonState, MotionClassification classification,
            int32_t edgeFlags, uint32_t deviceTimestamp, uint32_t pointerCount,
            const PointerProperties* pointerProperties, const PointerCoords* pointerCoords,
            float xPrecision, float yPrecision, nsecs_t downTime,