【Android】Android(安卓)Input
文章目录
- 1、简介
- 2、input命令
- 3、hardware相关的java代码
- 4、jni
- 5、service相关的java代码
- 6、libinputservice
- 7、libandroid
- 8、libinput
- 9、InputFlinger
- 10、evdev
- 11、te
1、简介
本文简要介绍Android Input系统的目录结构,详细说明可参考:https://blog.csdn.net/iEearth/article/details/86756978。
2、input命令
input命令是adb shell中的一个命令行调试input的工具,详细说明可参考:https://blog.csdn.net/iEearth/article/details/73555140。
3、hardware相关的java代码
在目录frameworks/base/core/java/android/hardware/input中有一些hardware相关的java代码,如下所示。各文件的用途可以从文件名看出来,重要的是InputManger,上面提到的input命令就是通过InputManager的injectInputEvent注入input事件的。
frameworks/base/core/java/android/hardware/input├── IInputDevicesChangedListener.aidl├── IInputManager.aidl├── InputDeviceIdentifier.aidl├── InputDeviceIdentifier.java├── InputManagerInternal.java├── InputManager.java├── ITabletModeChangedListener.aidl├── KeyboardLayout.aidl├── KeyboardLayout.java├── TouchCalibration.aidl└── TouchCalibration.java
4、jni
下面是input相关的jni文件,重点是com_android_server_input_InputManagerService.cpp中的NativeInputManager,是Java层InputManagerService与Native层InputManager沟通的桥梁。
frameworks/base/services/core/jni/com_android_server_input_InputWindowHandle.cppframeworks/base/services/core/jni/com_android_server_input_InputApplicationHandle.hframeworks/base/services/core/jni/com_android_server_input_InputWindowHandle.hframeworks/base/services/core/jni/com_android_server_input_InputManagerService.cppframeworks/base/services/core/jni/com_android_server_input_InputApplicationHandle.cpp
5、service相关的java代码
在目录frameworks/base/services/core/java/com/android/server/input中有一些service相关的java代码,如下所示。
frameworks/base/services/core/java/com/android/server/input├── InputApplicationHandle.java├── InputForwarder.java├── InputManagerService.java├── InputWindowHandle.java├── OWNERS└── PersistentDataStore.java
6、libinputservice
libinputservice用于光标控制,即Pointer、Sprinte,包括如下几个文件。
frameworks/base/libs/input├── Android.bp├── PointerController.cpp├── PointerController.h├── SpriteController.cpp└── SpriteController.h
7、libandroid
libandroid中包括一个input相关的文件,把AInputEvent中的函数作了个简单的封装,如下所示。
frameworks/base/native/android/input.cppint32_t AInputEvent_getType(const AInputEvent* event) { return static_cast(event)->getType();}
8、libinput
libinput包括如下几个文件,其中有一个很重要的InputTransport,定义了Input事件的传输机制,包括InputChannel、InputMessage、InputPublisher和InputConsumer四部分。InputMessage是Input事件传输的基本单元;InputChannel用于跨进程传输InputMessage;InputPublisher用于事件派发;InputConsumer用于事件接收。
frameworks/native/include/android/input.hframeworks/native/include/input├── DisplayViewport.h├── IInputFlinger.h├── InputDevice.h├── InputEventLabels.h├── Input.h├── InputTransport.h├── Keyboard.h├── KeyCharacterMap.h├── KeyLayoutMap.h├── VelocityControl.h├── VelocityTracker.h└── VirtualKeyMap.hframeworks/native/libs/input├── Android.bp├── IInputFlinger.cpp├── Input.cpp├── InputDevice.cpp├── InputTransport.cpp├── Keyboard.cpp├── KeyCharacterMap.cpp├── KeyLayoutMap.cpp├── VelocityControl.cpp├── VelocityTracker.cpp└── VirtualKeyMap.cpp
9、InputFlinger
InputFlinger是Android Native层Input相关的核心模块,简单来说就是InputReader从EventHub中读取Input事件,然后交由InputDispatcher进行事件派发。文件目录如下。
frameworks/native/services/inputflinger├── Android.bp├── EventHub.cpp├── EventHub.h├── host│ ├── Android.bp│ ├── InputDriver.cpp│ ├── InputDriver.h│ ├── InputFlinger.cpp│ ├── InputFlinger.h│ ├── inputflinger.rc│ ├── InputHost.cpp│ ├── InputHost.h│ └── main.cpp├── InputApplication.cpp├── InputApplication.h├── InputDispatcher.cpp├── InputDispatcher.h├── InputListener.cpp├── InputListener.h├── InputManager.cpp├── InputManager.h├── InputReader.cpp├── InputReader.h├── InputWindow.cpp├── InputWindow.h├── PointerControllerInterface.h
10、evdev
evdev、hal相关,目录结构如下。
hardware/libhardware/include/hardware/input.hhardware/libhardware/modules/input└── evdev ├── Android.bp ├── BitUtils.cpp ├── BitUtils.h ├── EvdevModule.cpp ├── InputDevice.cpp ├── InputDevice.h ├── InputDeviceManager.cpp ├── InputDeviceManager.h ├── InputHost.cpp ├── InputHost.h ├── InputHub.cpp ├── InputHub.h ├── InputMapper.cpp ├── InputMapper.h ├── MouseInputMapper.cpp ├── MouseInputMapper.h ├── SwitchInputMapper.cpp └── SwitchInputMapper.h
11、te
安全相关,包括如下两个文件。
system/sepolicy/private/inputflinger.tesystem/sepolicy/public/inputflinger.te
更多相关文章
- android intent.setDate方法
- repo 切换分支一种简单的方法
- android 在java代码中动态设置控件的位置和设置片大小
- Ubuntu下使用git和repo下载Android的源代码
- Android(安卓)adapter中调用activity中的方法
- Android(安卓): java.lang.UnsatisfiedLinkError: dalvik.system
- 搭建Android(安卓)CTS测试环境总结
- android include 控件详解
- Android(安卓)GPS