Input子系统的一些学习心得

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.

InputPublisher:

Publishes input events to an input channel

InputEventReceiver

WindowInputEventReceiver 继承于 InputEventReceiver 。
public InputEventReceiver(InputChannel inputChannel, Looper looper)

第一个参数是事件来源,
在它的构造方法中,
调用 nativeInit 在 native 层生成一个NativeInputEventReceiver
并调用它的 initialize() 方法 。

ALOOPER_EVENT_INPUT = 1 << 0,

InputConsumer:

Consumes input events from an input channel
什么时候创建的?:
InputConsumer 作为 NativeInputEventReceiver 的一个成员变量,在 jni的NativeInputEventReceiver 的构造方法中被创建的 。

它的consume方法是什么时候调用的?

Looper 收到事件之后调用NativeInputEventReceiver::handleEvent ,
调用NativeInputEventReceiver::consumeEvents,到

InputChannel:

An input channel consists of a local unix domain socket used to send and receive input messages across processes。

openInputChannelPair : 创建收和发的fd 。

receiveMessage方法被谁调用?:

InputReader(服务端)

InputReader 的 loopOnce 方法会调用 mEventHub->getEvents获取到输入事件,然后会调用到比如 InputDispatcher::notifyKey方法,然后通知epoll ,
然后到 InputDispatcher::dispatchOnce方法,

InputDispatcher(服务端)

Dispatches events to input targets .

start方法会启动线程 InputThread ,循环调用 InputDispatcher::dispatchOnce方法。

mPendingEvent : 已经发生,但还没有发送出去的事件。

InputDispatcher::createInputChannel 调用 InputChannel的openInputChannelPair方法来创建收和发的fd ,

InputDispatcher::startDispatchCycleLocked 调用 InputPublisher::publishKeyEvent ,
然后 InputPublisher 通过写入fd把事件发送出去。

android::inputdispatcher:: Connection:

何时创建:

InputDevice

何时创建:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值