文章目錄
1、簡介
本文簡要介紹Android Input系統(tǒng)的目錄結(jié)構(gòu),詳細(xì)說明可參考:https://blog.csdn.net/iEearth/article/details/86756978。
2、input命令
input命令是adb shell中的一個命令行調(diào)試input的工具,詳細(xì)說明可參考:https://blog.csdn.net/iEearth/article/details/73555140。
3、hardware相關(guān)的java代碼
在目錄frameworks/base/core/java/android/hardware/input中有一些hardware相關(guān)的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相關(guān)的jni文件,重點(diǎn)是com_android_server_input_InputManagerService.cpp中的NativeInputManager,是Java層InputManagerService與Native層InputManager溝通的橋梁。
frameworks/base/services/core/jni/com_android_server_input_InputWindowHandle.cpp
frameworks/base/services/core/jni/com_android_server_input_InputApplicationHandle.h
frameworks/base/services/core/jni/com_android_server_input_InputWindowHandle.h
frameworks/base/services/core/jni/com_android_server_input_InputManagerService.cpp
frameworks/base/services/core/jni/com_android_server_input_InputApplicationHandle.cpp
5、service相關(guān)的java代碼
在目錄frameworks/base/services/core/java/com/android/server/input中有一些service相關(guān)的java代碼,如下所示。
frameworks/base/services/core/java/com/android/server/input
├── InputApplicationHandle.java
├── InputForwarder.java
├── InputManagerService.java
├── InputWindowHandle.java
├── OWNERS
└── PersistentDataStore.java
6、libinputservice
libinputservice用于光標(biāo)控制,即Pointer、Sprinte,包括如下幾個文件。
frameworks/base/libs/input
├── Android.bp
├── PointerController.cpp
├── PointerController.h
├── SpriteController.cpp
└── SpriteController.h
7、libandroid
libandroid中包括一個input相關(guān)的文件,把AInputEvent中的函數(shù)作了個簡單的封裝,如下所示。
frameworks/base/native/android/input.cpp
int32_t AInputEvent_getType(const AInputEvent* event) {
return static_cast<const InputEvent*>(event)->getType();
}
8、libinput
libinput包括如下幾個文件,其中有一個很重要的InputTransport,定義了Input事件的傳輸機(jī)制,包括InputChannel、InputMessage、InputPublisher和InputConsumer四部分。InputMessage是Input事件傳輸?shù)幕締卧?;InputChannel用于跨進(jìn)程傳輸InputMessage;InputPublisher用于事件派發(fā);InputConsumer用于事件接收。
frameworks/native/include/android/input.h
frameworks/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.h
frameworks/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相關(guān)的核心模塊,簡單來說就是InputReader從EventHub中讀取Input事件,然后交由InputDispatcher進(jìn)行事件派發(fā)。文件目錄如下。
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相關(guān),目錄結(jié)構(gòu)如下。
hardware/libhardware/include/hardware/input.h
hardware/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
安全相關(guān),包括如下兩個文件。
system/sepolicy/private/inputflinger.te
system/sepolicy/public/inputflinger.te
來源:http://www./content-4-184501.html
|