File: /home/andy/aosp13/frameworks/native/include/input
InputReader --------> InputPublisher <----------> InputChannel <--------> InputConsumer
/**
* Native input transport.
*
* The InputChannel provides a mechanism for exchanging InputMessage structures across processes.
*
* The InputPublisher and InputConsumer each handle one end-point of an input channel.
* The InputPublisher is used by the input dispatcher to send events to the application.
* The InputConsumer is used by the application to receive events from the input dispatcher.
*/
InputChannel:
An input channel consists of a local unix domain socket used to send and receive
input messages across processes
InputPublisher:
Publishes input events to an input channel
publishMotionEvent()
publishKeyEvent()
publishFocusEvent()
publishDragEvent()
publishTouchModeEvent()
InputConsumer:
Consumes input events from an input channel
consume()
sendFinishedSignal()
InputEventReceiver
child class:
PointerEventDispatcher
android.view.ViewRootImpl.WindowInputEventReceiver
When to create a InputEventReceiver?
NativeInputEventReceiver
class NativeInputEventReceiver : public LooperCallback {
public:
status_t finishInputEvent(uint32_t seq, bool handled);
status_t reportTimeline(int32_t inputEventId, nsecs_t gpuCompletedTime, nsecs_t presentTime);
status_t consumeEvents(JNIEnv* env, bool consumeBatches, nsecs_t frameTime,
bool* outConsumedBatch);
system server call inputManager.start();
com_android_server_input_InputManagerService.cpp#nativeStart()
InputManager::start() : InputDispatcher::start() InputReader::start()
InputDispatcher::dispatchOnce
InputDispatcher::dispatchOnceInnerLocked call
dispatchKeyLocked()
dispatchMotionLocked
dispatchSensorLocked
dispatchDragLocked
findFocusedWindowTargetsLocked: find input targets.
InputDispatcher::dispatchEventLocked for each InputTarget call following :
InputDispatcher::prepareDispatchCycleLocked()
InputDispatcher::enqueueDispatchEntriesLocked InputDispatcher::enqueueDispatchEntryLocked
InputDispatcher::startDispatchCycleLocked(): iterate all the events
InputPublisher::publishTouchModeEvent()
InputPublisher::publishDragEvent()
InputPublisher::publishMotionEvent()
InputPublisher::publishKeyEvent()
InputChannel::sendMessage()
###################################################
InputChannel::receiveMessage()
InputConsumer::consume()
call java InputEventReceiver#dispatchInputEvent()
What is InputTarget?
aosp13/frameworks/native/services/inputflinger/dispatcher/InputTarget.h
InputDispatcher::addWindowTargetLocked