温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

关于linux input device输入子系统架构及android中的框架

发布时间:2020-07-01 10:21:43 来源:网络 阅读:1224 作者:GaoNeil 栏目:移动开发

关于linux input device输入子系统架构及android中的框架

关于linux input device输入子系统架构及android中的框架

应用app和windowmanagerservice的input event通信方式

在Native层的InputChannel就是一个通道,仅仅是一个通道,仅仅具有通信功能,不包含其他的。至于从数据流动方向,与InputChannel无关。数据流向是由InputPublisher和InputConsumer在组合了InputChannel后决定的。
把InputChannel由应用程序传递到WindowManageService的过程,涉及到的是Binder通信,不是文章的重点,不多说。需要知道的是,mWindowSession.addToDisplay最后会传递到WindowManagerService的addWindow方法。通过代码看看InputChannel是如何使用的,代码如下:
1 public int addWindow(Session session, IWindow client, int seq,
2 WindowManager.LayoutParams attrs, int viewVisibility, int displayId,
3 Rect outContentInsets, InputChannel outInputChannel) {
4 …
5 if (outInputChannel != null && (attrs.inputFeatures
6 & WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL) == 0) {
7 //这个名字是根据对象的hashcode和窗口的一些属性转化为字符串后建立的。
8 String name = win.makeInputChannelName();
9 InputChannel[] inputChannels = InputChannel.openInputChannelPair(name);
10 win.setInputChannel(inputChannels[0]);
11 inputChannels[1].transferTo(outInputChannel);
12 mInputManager.registerInputChannel(win.mInputChannel, win.mInputWindowHandle);
13 }
14 …
15 }

需要注意的是,InputDispatcher.cpp除了会向PhoneWindowManager.java传递KeyEvent外,例如SW_LID.
正方向传递,还会反方向查询policy。PhoneWindowManager.java作为android.policy的一分子。参见PhoneWindowManager.java:: interceptKeyBeforeDispatching() 和PhoneWindowManager.java:: interceptKeyBeforeQueueing()。 通过返回的ACTION_PASS_TO_USER等来判断是否需要发给app,另外还会查找有无focus app,然后发给它。在SW_LID为LID_CLOSE时屏幕变黑,此时一般按键是不会传到Application的,如果想传特定按键,那么需要更改InputDispatcher::dispatchKeyLocked()函数的逻辑,见dropReason 。

关于linux input device输入子系统架构及android中的框架

EVIOCGRAB功能

关于linux input device输入子系统架构及android中的框架

关于linux input device输入子系统架构及android中的框架

具体请参考我的免费的linux各种驱动开发课程如下:
https://edu.51cto.com/course/17138.html

另外我的相关培训视频请看:
欢迎观看我发布的各个课程: https://edu.51cto.com/lecturer/8896847.html

我的新的更多优惠的打包课程链接如下:
https://edu.51cto.com/sd/0a9d4

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI