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

Commit 4052d9c5 authored by Harry Cutts's avatar Harry Cutts
Browse files

TouchInputMapper: remove unnecessary dispatchMotion parameters

Since the pointer gestures code was removed, the source, xPrecision,
yPrecision, downTime, and classification parameters were the same at
every call site, so they can be removed.

Bug: 281840344
Test: $ atest --host inputflinger_tests
Flag: EXEMPT refactor
Change-Id: I5ca68bed5c7b58aa7c95250a34879744c9801c36
parent 0917213c
Loading
Loading
Loading
Loading
+28 −47
Original line number Diff line number Diff line
@@ -1834,15 +1834,14 @@ std::list<NotifyArgs> TouchInputMapper::abortTouches(
    if (!currentIdBits.isEmpty()) {
        int32_t metaState = getContext()->getGlobalMetaState();
        int32_t buttonState = mCurrentCookedState.buttonState;
        out.push_back(dispatchMotion(when, readTime, policyFlags, mSource,
        out.push_back(dispatchMotion(when, readTime, policyFlags,
                                     currentGestureDisplayId.value_or(resolveDisplayId()),
                                     AMOTION_EVENT_ACTION_CANCEL, 0, AMOTION_EVENT_FLAG_CANCELED,
                                     metaState, buttonState,
                                     mCurrentCookedState.cookedPointerData.pointerProperties,
                                     mCurrentCookedState.cookedPointerData.pointerCoords,
                                     mCurrentCookedState.cookedPointerData.idToIndex, currentIdBits,
                                     -1, mOrientedXPrecision, mOrientedYPrecision, mDownTime,
                                     MotionClassification::NONE));
                                     -1));
        mCurrentMotionAborted = true;
    }
    return out;
@@ -1890,14 +1889,12 @@ std::list<NotifyArgs> TouchInputMapper::dispatchTouches(nsecs_t when, nsecs_t re
        if (!currentIdBits.isEmpty()) {
            // No pointer id changes so this is a move event.
            // The listener takes care of batching moves so we don't have to deal with that here.
            out.push_back(dispatchMotion(when, readTime, policyFlags, mSource, resolveDisplayId(),
            out.push_back(dispatchMotion(when, readTime, policyFlags, resolveDisplayId(),
                                         AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, buttonState,
                                         mCurrentCookedState.cookedPointerData.pointerProperties,
                                         mCurrentCookedState.cookedPointerData.pointerCoords,
                                         mCurrentCookedState.cookedPointerData.idToIndex,
                                         currentIdBits, -1, mOrientedXPrecision,
                                         mOrientedYPrecision, mDownTime,
                                         MotionClassification::NONE));
                                         currentIdBits, -1));
        }
    } else {
        // There may be pointers going up and pointers going down and pointers moving
@@ -1927,16 +1924,14 @@ std::list<NotifyArgs> TouchInputMapper::dispatchTouches(nsecs_t when, nsecs_t re
            if (isCanceled) {
                ALOGI("Canceling pointer %d for the palm event was detected.", upId);
            }
            out.push_back(dispatchMotion(when, readTime, policyFlags, mSource, resolveDisplayId(),
            out.push_back(dispatchMotion(when, readTime, policyFlags, resolveDisplayId(),
                                         AMOTION_EVENT_ACTION_POINTER_UP, 0,
                                         isCanceled ? AMOTION_EVENT_FLAG_CANCELED : 0, metaState,
                                         buttonState,
                                         mLastCookedState.cookedPointerData.pointerProperties,
                                         mLastCookedState.cookedPointerData.pointerCoords,
                                         mLastCookedState.cookedPointerData.idToIndex,
                                         dispatchedIdBits, upId, mOrientedXPrecision,
                                         mOrientedYPrecision, mDownTime,
                                         MotionClassification::NONE));
                                         dispatchedIdBits, upId));
            dispatchedIdBits.clearBit(upId);
            mCurrentCookedState.cookedPointerData.canceledIdBits.clearBit(upId);
        }
@@ -1946,14 +1941,12 @@ std::list<NotifyArgs> TouchInputMapper::dispatchTouches(nsecs_t when, nsecs_t re
        // events, they do not generally handle them except when presented in a move event.
        if (moveNeeded && !moveIdBits.isEmpty()) {
            ALOG_ASSERT(moveIdBits.value == dispatchedIdBits.value);
            out.push_back(dispatchMotion(when, readTime, policyFlags, mSource, resolveDisplayId(),
            out.push_back(dispatchMotion(when, readTime, policyFlags, resolveDisplayId(),
                                         AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState, buttonState,
                                         mCurrentCookedState.cookedPointerData.pointerProperties,
                                         mCurrentCookedState.cookedPointerData.pointerCoords,
                                         mCurrentCookedState.cookedPointerData.idToIndex,
                                         dispatchedIdBits, -1, mOrientedXPrecision,
                                         mOrientedYPrecision, mDownTime,
                                         MotionClassification::NONE));
                                         dispatchedIdBits, -1));
        }

        // Dispatch pointer down events using the new pointer locations.
@@ -1967,13 +1960,12 @@ std::list<NotifyArgs> TouchInputMapper::dispatchTouches(nsecs_t when, nsecs_t re
            }

            out.push_back(
                    dispatchMotion(when, readTime, policyFlags, mSource, resolveDisplayId(),
                    dispatchMotion(when, readTime, policyFlags, resolveDisplayId(),
                                   AMOTION_EVENT_ACTION_POINTER_DOWN, 0, 0, metaState, buttonState,
                                   mCurrentCookedState.cookedPointerData.pointerProperties,
                                   mCurrentCookedState.cookedPointerData.pointerCoords,
                                   mCurrentCookedState.cookedPointerData.idToIndex,
                                   dispatchedIdBits, downId, mOrientedXPrecision,
                                   mOrientedYPrecision, mDownTime, MotionClassification::NONE));
                                   dispatchedIdBits, downId));
        }
    }
    return out;
@@ -1986,15 +1978,13 @@ std::list<NotifyArgs> TouchInputMapper::dispatchHoverExit(nsecs_t when, nsecs_t
        (mCurrentCookedState.cookedPointerData.hoveringIdBits.isEmpty() ||
         !mCurrentCookedState.cookedPointerData.touchingIdBits.isEmpty())) {
        int32_t metaState = getContext()->getGlobalMetaState();
        out.push_back(dispatchMotion(when, readTime, policyFlags, mSource, resolveDisplayId(),
        out.push_back(dispatchMotion(when, readTime, policyFlags, resolveDisplayId(),
                                     AMOTION_EVENT_ACTION_HOVER_EXIT, 0, 0, metaState,
                                     mLastCookedState.buttonState,
                                     mLastCookedState.cookedPointerData.pointerProperties,
                                     mLastCookedState.cookedPointerData.pointerCoords,
                                     mLastCookedState.cookedPointerData.idToIndex,
                                     mLastCookedState.cookedPointerData.hoveringIdBits, -1,
                                     mOrientedXPrecision, mOrientedYPrecision, mDownTime,
                                     MotionClassification::NONE));
                                     mLastCookedState.cookedPointerData.hoveringIdBits, -1));
        mSentHoverEnter = false;
    }
    return out;
@@ -2007,27 +1997,23 @@ std::list<NotifyArgs> TouchInputMapper::dispatchHoverEnterAndMove(nsecs_t when,
        !mCurrentCookedState.cookedPointerData.hoveringIdBits.isEmpty()) {
        int32_t metaState = getContext()->getGlobalMetaState();
        if (!mSentHoverEnter) {
            out.push_back(dispatchMotion(when, readTime, policyFlags, mSource, resolveDisplayId(),
            out.push_back(dispatchMotion(when, readTime, policyFlags, resolveDisplayId(),
                                         AMOTION_EVENT_ACTION_HOVER_ENTER, 0, 0, metaState,
                                         mCurrentRawState.buttonState,
                                         mCurrentCookedState.cookedPointerData.pointerProperties,
                                         mCurrentCookedState.cookedPointerData.pointerCoords,
                                         mCurrentCookedState.cookedPointerData.idToIndex,
                                         mCurrentCookedState.cookedPointerData.hoveringIdBits, -1,
                                         mOrientedXPrecision, mOrientedYPrecision, mDownTime,
                                         MotionClassification::NONE));
                                         mCurrentCookedState.cookedPointerData.hoveringIdBits, -1));
            mSentHoverEnter = true;
        }

        out.push_back(dispatchMotion(when, readTime, policyFlags, mSource, resolveDisplayId(),
        out.push_back(dispatchMotion(when, readTime, policyFlags, resolveDisplayId(),
                                     AMOTION_EVENT_ACTION_HOVER_MOVE, 0, 0, metaState,
                                     mCurrentRawState.buttonState,
                                     mCurrentCookedState.cookedPointerData.pointerProperties,
                                     mCurrentCookedState.cookedPointerData.pointerCoords,
                                     mCurrentCookedState.cookedPointerData.idToIndex,
                                     mCurrentCookedState.cookedPointerData.hoveringIdBits, -1,
                                     mOrientedXPrecision, mOrientedYPrecision, mDownTime,
                                     MotionClassification::NONE));
                                     mCurrentCookedState.cookedPointerData.hoveringIdBits, -1));
    }
    return out;
}
@@ -2042,14 +2028,12 @@ std::list<NotifyArgs> TouchInputMapper::dispatchButtonRelease(nsecs_t when, nsec
    while (!releasedButtons.isEmpty()) {
        int32_t actionButton = BitSet32::valueForBit(releasedButtons.clearFirstMarkedBit());
        buttonState &= ~actionButton;
        out.push_back(dispatchMotion(when, readTime, policyFlags, mSource, resolveDisplayId(),
        out.push_back(dispatchMotion(when, readTime, policyFlags, resolveDisplayId(),
                                     AMOTION_EVENT_ACTION_BUTTON_RELEASE, actionButton, 0,
                                     metaState, buttonState,
                                     mLastCookedState.cookedPointerData.pointerProperties,
                                     mLastCookedState.cookedPointerData.pointerCoords,
                                     mLastCookedState.cookedPointerData.idToIndex, idBits, -1,
                                     mOrientedXPrecision, mOrientedYPrecision, mDownTime,
                                     MotionClassification::NONE));
                                     mLastCookedState.cookedPointerData.idToIndex, idBits, -1));
    }
    return out;
}
@@ -2064,14 +2048,12 @@ std::list<NotifyArgs> TouchInputMapper::dispatchButtonPress(nsecs_t when, nsecs_
    while (!pressedButtons.isEmpty()) {
        int32_t actionButton = BitSet32::valueForBit(pressedButtons.clearFirstMarkedBit());
        buttonState |= actionButton;
        out.push_back(dispatchMotion(when, readTime, policyFlags, mSource, resolveDisplayId(),
        out.push_back(dispatchMotion(when, readTime, policyFlags, resolveDisplayId(),
                                     AMOTION_EVENT_ACTION_BUTTON_PRESS, actionButton, 0, metaState,
                                     buttonState,
                                     mCurrentCookedState.cookedPointerData.pointerProperties,
                                     mCurrentCookedState.cookedPointerData.pointerCoords,
                                     mCurrentCookedState.cookedPointerData.idToIndex, idBits, -1,
                                     mOrientedXPrecision, mOrientedYPrecision, mDownTime,
                                     MotionClassification::NONE));
                                     mCurrentCookedState.cookedPointerData.idToIndex, idBits, -1));
    }
    return out;
}
@@ -2308,12 +2290,10 @@ void TouchInputMapper::cookPointerData() {
}

NotifyMotionArgs TouchInputMapper::dispatchMotion(
        nsecs_t when, nsecs_t readTime, uint32_t policyFlags, uint32_t source,
        ui::LogicalDisplayId displayId, int32_t action, int32_t actionButton, int32_t flags,
        int32_t metaState, int32_t buttonState, const PropertiesArray& properties,
        const CoordsArray& coords, const IdToIndexArray& idToIndex, BitSet32 idBits,
        int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime,
        MotionClassification classification) const {
        nsecs_t when, nsecs_t readTime, uint32_t policyFlags, ui::LogicalDisplayId displayId,
        int32_t action, int32_t actionButton, int32_t flags, int32_t metaState, int32_t buttonState,
        const PropertiesArray& properties, const CoordsArray& coords,
        const IdToIndexArray& idToIndex, BitSet32 idBits, int32_t changedId) const {
    std::vector<PointerCoords> pointerCoords;
    std::vector<PointerProperties> pointerProperties;
    uint32_t pointerCount = 0;
@@ -2349,6 +2329,7 @@ NotifyMotionArgs TouchInputMapper::dispatchMotion(
            ALOG_ASSERT(false);
        }
    }
    uint32_t source = mSource;
    if (mCurrentStreamModifiedByExternalStylus) {
        source |= AINPUT_SOURCE_BLUETOOTH_STYLUS;
    }
@@ -2375,9 +2356,9 @@ NotifyMotionArgs TouchInputMapper::dispatchMotion(
                  [this](TouchVideoFrame& frame) { frame.rotate(this->mInputDeviceOrientation); });
    return NotifyMotionArgs(getContext()->getNextId(), when, readTime, deviceId, source, displayId,
                            policyFlags, action, actionButton, flags, metaState, buttonState,
                            classification, pointerCount, pointerProperties.data(),
                            pointerCoords.data(), xPrecision, yPrecision, xCursorPosition,
                            yCursorPosition, downTime, std::move(frames));
                            MotionClassification::NONE, pointerCount, pointerProperties.data(),
                            pointerCoords.data(), mOrientedXPrecision, mOrientedYPrecision,
                            xCursorPosition, yCursorPosition, mDownTime, std::move(frames));
}

std::list<NotifyArgs> TouchInputMapper::cancelTouch(nsecs_t when, nsecs_t readTime) {
+4 −6
Original line number Diff line number Diff line
@@ -554,12 +554,10 @@ private:
    // method will take care of setting the index and transmuting the action to DOWN or UP
    // it is the first / last pointer to go down / up.
    [[nodiscard]] NotifyMotionArgs dispatchMotion(
            nsecs_t when, nsecs_t readTime, uint32_t policyFlags, uint32_t source,
            ui::LogicalDisplayId displayId, int32_t action, int32_t actionButton, int32_t flags,
            int32_t metaState, int32_t buttonState, const PropertiesArray& properties,
            const CoordsArray& coords, const IdToIndexArray& idToIndex, BitSet32 idBits,
            int32_t changedId, float xPrecision, float yPrecision, nsecs_t downTime,
            MotionClassification classification) const;
            nsecs_t when, nsecs_t readTime, uint32_t policyFlags, ui::LogicalDisplayId displayId,
            int32_t action, int32_t actionButton, int32_t flags, int32_t metaState,
            int32_t buttonState, const PropertiesArray& properties, const CoordsArray& coords,
            const IdToIndexArray& idToIndex, BitSet32 idBits, int32_t changedId) const;

    // Returns if this touch device is a touch screen with an associated display.
    bool isTouchScreen();