派发循环是指 InputDispatcher 不断地派发队列取出事件,寻找合适的窗口并进行发送的过程,是 InputDispatcher 线程的主要工作
事件发送循环是 InputDispatcher 通过 Connection 对象将事件发送给窗口,并接受其反馈的过程
InputDispatcher —> dispatchEventLocked:dispatchEventLocked 根据 InputTarget 中的 InputChannel 找到对应的Connection
@frameworks/native/services/inputflinger/dispatcher/InputDispatcher.cpp
//1. InputReader将事件注入派发队列
InputDispatcher::notifyMotion
mPolicy->interceptMotionBeforeQueueing(args->displayId, args->eventTime, /*byref*/ policyFlags);
needWake = enqueueInboundEventLocked(std::move(newEntry));
mInboundQueue.push_back(std::move(newEntry));
//2.派发线程的线程循环
InputDispatcher::dispatchOnce
//3. 为事件寻找合适的窗口,窗口分为普通窗口和监听窗口,普通通过按点和焦点查找,监听窗口则无条件监听所有输入事件
dispatchOnceInnerLocked(&nextWakeupTime);
mPendingEvent = mInboundQueue.front();
case EventEntry::Type::FOCUS:
dispatchFocu