InputReader触摸调用流程

请部分请参考android Input专题- Q/R/S 10/11/12 InputReader源码分析1_learnframework的博客-CSDN博客

1、frameworks/native/services/inputflinger/InputReader.cpp

void InputReader::processEventsLocked(const RawEvent* rawEvents, size_t count) {

#if DEBUG_RAW_EVENTS
            ALOGD("BatchSize: %d Count: %d", batchSize, count);
#endif
            processEventsForDeviceLocked(deviceId, rawEvent, batchSize);
        } else {
}

2、frameworks/native/services/inputflinger/InputReader.cpp

void InputReader::processEventsForDeviceLocked(int32_t deviceId,
        const RawEvent* rawEvents, size_t count) {
    ssize_t deviceIndex = mDevices.indexOfKey(deviceId);
    if (deviceIndex < 0) {
        ALOGW("Discarding event for unknown deviceId %d.", deviceId);
        return;
    }

    InputDevice* device = mDevices.valueAt(deviceIndex);
    if (device->isIgnored()) {
        //ALOGD("Discarding event for ignored deviceId %d.", deviceId);
        return;
    }

    device->process(rawEvents, count);
}

3、frameworks/native/services/inputflinger/InputReader.cpp

void InputDevice::process(const RawEvent* rawEvents, size_t count) {

        } else {
            for (size_t i = 0; i < numMappers; i++) {
                InputMapper* mapper = mMappers[i];
                mapper->process(rawEvent);
            }
4、MultiTouchInputMapper多指触摸

void MultiTouchInputMapper::process(const RawEvent* rawEvent) {
    TouchInputMapper::process(rawEvent);

    mMultiTouchMotionAccumulator.process(rawEvent);
}

5、TouchInputMapper

void TouchInputMapper::process(const RawEvent* rawEvent) {

    if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) {
        sync(rawEvent->when);
    }
}

6、TouchInputMapper

void TouchInputMapper::sync(nsecs_t when) {
 

// Sync touch

syncTouch(when, next);

// Assign pointer ids.

if (!mHavePointerIds) {

assignPointerIds(last, next);

}

processRawTouches(false /*timeout*/);

}

7、MultiTouchInputMapper

void MultiTouchInputMapper::syncTouch(nsecs_t when, RawState* outState) {
    size_t inCount = mMultiTouchMotionAccumulator.getSlotCount();
    size_t outCount = 0;
    BitSet32 newPointerIdBits;
    mHavePointerIds = true;

    mMultiTouchMotionAccumulator.finishSync();
}

8、TouchInputMapper

void TouchInputMapper::processRawTouches(bool timeout) {

for (count = 0; count < N; count++) {

// All ready to go.

clearStylusDataPendingFlags();

mCurrentRawState.copyFrom(next);

cookAndDispatch(mCurrentRawState.when);

}

}

9、TouchInputMapper

void TouchInputMapper::cookAndDispatch(nsecs_t when) {

cookPointerData();

// Apply stylus pressure to current cooked state.

applyExternalStylusTouchState(when);

if (!mCurrentMotionAborted) {

dispatchButtonRelease(when, policyFlags);

dispatchHoverExit(when, policyFlags);

dispatchTouches(when, policyFlags);

dispatchHoverEnterAndMove(when, policyFlags);

dispatchButtonPress(when, policyFlags);

}

}

10、TouchInputMapper

void TouchInputMapper::dispatchTouches(nsecs_t when, uint32_t policyFlags) {

dispatchMotion(when, policyFlags, mSource, AMOTION_EVENT_ACTION_MOVE, 0, 0, metaState,

buttonState, 0, mCurrentCookedState.cookedPointerData.pointerProperties,

mCurrentCookedState.cookedPointerData.pointerCoords,

mCurrentCookedState.cookedPointerData.idToIndex, dispatchedIdBits, -1,

mOrientedXPrecision, mOrientedYPrecision, mDownTime);

}

11、TouchInputMapper

void TouchInputMapper::dispatchMotion(.....){

    NotifyMotionArgs args(getContext()->getNextId(), when, readTime, deviceId, source, displayId,
                          policyFlags, action, actionButton, flags, metaState, buttonState,
                          MotionClassification::NONE, edgeFlags, pointerCount, pointerProperties,
                          pointerCoords, xPrecision, yPrecision, xCursorPosition, yCursorPosition,
                          downTime, std::move(frames));
    getListener().notifyMotion(&args);

}

12、InputDispatcher

void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) {

}

你可能感兴趣的:(杂记,javascript,开发语言,ecmascript)