input之我见02——Input调试Tips
在kernel对Input有了一定的认识之后,就开始Android的Input之旅,先不急着深挖代码,来看看如何获得Input的相关打印信息。
1,根据事件路由,打开各个节点debug信息
- EventHub.cpp
KeyWord:
#define LOG_TAG “EventHub”
#define LOG_NDEBUG 0
KeyFunction:
getEvents()
- InputReader.cpp
KeyWord:
#define LOG_TAG “InputReader”
#define LOG_NDEBUG 0
KeyFunction:
loopOnce()
- InputDispatcher()
KeyWord:
#define LOG_TAG “InputDispatcher”
#define LOG_NDEBUG 0
#define DEBUG_INBOUND_EVENT_DETAILS 1
#define DEBUG_OUTBOUND_EVENT_DETAILS 2
KeyFunction:
notifyKey()
示例:
logcat -s “EventHub” “InputReader” “InputDispatcher”
01-01 00:00:21.734 4076 4114 V EventHub: Opening device: /dev/input/event2
01-01 00:00:21.734 4076 4114 V EventHub: Created descriptor: raw=:1b8e:0cec:, cooked=02b1ce58713e0e531eab61b0742baac6893ff49f
01-01 00:00:21.734 4076 4114 V EventHub: add device 1: /dev/input/event2
01-01 00:00:21.734 4076 4114 V EventHub: bus: 0010
01-01 00:00:21.734 4076 4114 V EventHub: vendor 1b8e
01-01 00:00:21.734 4076 4114 V EventHub: product 0cec
01-01 00:00:21.734 4076 4114 V EventHub: version 0001
01-01 00:00:21.734 4076 4114 V EventHub: name: "cec_input"
01-01 00:00:21.734 4076 4114 V EventHub: location: ""
01-01 00:00:21.734 4076 4114 V EventHub: unique id: ""
01-01 00:00:21.734 4076 4114 V EventHub: descriptor: "02b1ce58713e0e531eab61b0742baac6893ff49f"
01-01 00:00:21.734 4076 4114 V EventHub: driver: v1.0.1
01-01 00:00:21.735 4076 4114 D EventHub: No input device configuration file found for device 'cec_input'.
01-01 00:00:21.741 4076 4114 W EventHub: Unable to disable kernel key repeat for /dev/input/event2: Function not implemented
01-01 00:00:21.741 4076 4114 I EventHub: New device: id=1, fd=88, path='/dev/input/event2', name='cec_input', classes=0x1, configuration='', keyLayout='/system/usr/keylayout/Generic.kl', keyCharacterMap='/system/usr/keychars/Generic.kcm', builtinKeyboard=false, wakeMechanism=EPOLLWAKEUP, usingClockIoctl=true
01-01 00:00:21.741 4076 4114 V EventHub: Opening device: /dev/input/mice
01-01 00:00:21.741 4076 4114 E EventHub: could not get driver version for /dev/input/mice, Not a typewriter
01-01 00:00:21.794 4076 4114 V EventHub: Opening device: /dev/input/event1
01-01 00:00:21.795 4076 4114 V EventHub: Created descriptor: raw=:0001:0001:, cooked=485d69228e24f5e46da1598745890b214130dbc4
01-01 00:00:21.795 4076 4114 V EventHub: add device 2: /dev/input/event1
01-01 00:00:21.795 4076 4114 V EventHub: bus: 0010
01-01 00:00:21.795 4076 4114 V EventHub: vendor 0001
01-01 00:00:21.795 4076 4114 V EventHub: product 0001
01-01 00:00:21.795 4076 4114 V EventHub: version 0100
01-01 00:00:21.795 4076 4114 V EventHub: name: "gpio_keypad"
01-01 00:00:21.795 4076 4114 V EventHub: location: "gpio_keypad/input0"
01-01 00:00:21.795 4076 4114 V EventHub: unique id: ""
01-01 00:00:21.795 4076 4114 V EventHub: descriptor: "485d69228e24f5e46da1598745890b214130dbc4"
01-01 00:00:21.795 4076 4114 V EventHub: driver: v1.0.1
01-01 00:00:21.795 4076 4114 D EventHub: No input device configuration file found for device 'gpio_keypad'.
01-01 00:00:21.800 4076 4114 I EventHub: New device: id=2, fd=89, path='/dev/input/event1', name='gpio_keypad', classes=0x1, configuration='', keyLayout='/system/usr/keylayout/Generic.kl', keyCharacterMap='/system/usr/keychars/Generic.kcm', builtinKeyboard=false, wakeMechanism=EPOLLWAKEUP, usingClockIoctl=true
01-01 00:00:21.800 4076 4114 V EventHub: Opening device: /dev/input/event0
01-01 00:00:21.801 4076 4114 V EventHub: Created descriptor: raw=:0001:0001:nonce:0001, cooked=d2c52ff0f656fac4cd7b7a118d575e0109a9fe1c
01-01 00:00:21.801 4076 4114 V EventHub: add device 3: /dev/input/event0
01-01 00:00:21.801 4076 4114 V EventHub: bus: 0010
01-01 00:00:21.801 4076 4114 V EventHub: vendor 0001
01-01 00:00:21.801 4076 4114 V EventHub: product 0001
01-01 00:00:21.801 4076 4114 V EventHub: version 0100
01-01 00:00:21.801 4076 4114 V EventHub: name: "aml_keypad"
01-01 00:00:21.801 4076 4114 V EventHub: location: "keypad/input0"
01-01 00:00:21.801 4076 4114 V EventHub: unique id: ""
01-01 00:00:21.801 4076 4114 V EventHub: descriptor: "d2c52ff0f656fac4cd7b7a118d575e0109a9fe1c"
01-01 00:00:21.801 4076 4114 V EventHub: driver: v1.0.1
01-01 00:00:21.801 4076 4114 D EventHub: No input device configuration file found for device 'aml_keypad'.
01-01 00:00:21.805 4076 4114 W EventHub: Unable to disable kernel key repeat for /dev/input/event0: Function not implemented
01-01 00:00:21.805 4076 4114 I EventHub: New device: id=3, fd=90, path='/dev/input/event0', name='aml_keypad', classes=0x863, configuration='', keyLayout='/system/usr/keylayout/Generic.kl', keyCharacterMap='/system/usr/keychars/Generic.kcm', builtinKeyboard=false, wakeMechanism=EPOLLWAKEUP, usingClockIoctl=true
01-01 00:00:21.805 4076 4114 V EventHub: Created descriptor: raw=:0000:0000:uniqueId:<virtual>name:Virtual, cooked=a718a782d34bc767f4689c232d64d527998ea7fd
01-01 00:00:21.810 4076 4114 V EventHub: Reporting device opened: id=-1, name=<virtual>
01-01 00:00:21.810 4076 4114 V EventHub: Reporting device opened: id=3, name=/dev/input/event0
01-01 00:00:21.810 4076 4114 V EventHub: Reporting device opened: id=2, name=/dev/input/event1
01-01 00:00:21.810 4076 4114 V EventHub: Reporting device opened: id=1, name=/dev/input/event2
01-01 00:00:21.810 4076 4114 I InputReader: Device added: id=-1, name='Virtual', sources=0x00000301
01-01 00:00:21.810 4076 4114 I InputReader: Device added: id=3, name='aml_keypad', sources=0x00004703
01-01 00:00:21.811 4076 4114 I InputReader: Reconfiguring input devices. changes=0x00000080
01-01 00:00:21.811 4076 4114 I InputReader: Device added: id=2, name='gpio_keypad', sources=0x00000101
01-01 00:00:21.811 4076 4114 I InputReader: Device added: id=1, name='cec_input', sources=0x00000101
01-01 00:00:21.811 4076 4114 D InputDispatcher: notifyDeviceReset - eventTime=16199233173, deviceId=-1
01-01 00:00:21.811 4076 4114 D InputDispatcher: notifyDeviceReset - eventTime=16199233173, deviceId=3
01-01 00:00:21.811 4076 4114 D InputDispatcher: notifyDeviceReset - eventTime=16199233173, deviceId=2
01-01 00:00:21.811 4076 4113 D InputDispatcher: dispatchDeviceReset - eventTime=16199233173, deviceId=-1
01-01 00:00:21.811 4076 4113 D InputDispatcher: dispatchDeviceReset - eventTime=16199233173, deviceId=3
01-01 00:00:21.811 4076 4114 D InputDispatcher: notifyDeviceReset - eventTime=16199233173, deviceId=1
01-01 00:00:21.811 4076 4113 D InputDispatcher: dispatchDeviceReset - eventTime=16199233173, deviceId=2
01-01 00:00:21.811 4076 4114 D InputDispatcher: notifyConfigurationChanged - eventTime=16199233173
01-01 00:00:21.811 4076 4113 D InputDispatcher: dispatchDeviceReset - eventTime=16199233173, deviceId=1
01-01 00:00:21.812 4076 4113 D InputDispatcher: dispatchConfigurationChanged - eventTime=16199233173
2,KeyLayout文件加载debug
framework/native/libs/input/InputDevice.cpp
#define LOG_TAG “InputDevice”
+#define DEBUG_PROBE 1
+#define LOG_NDEBUG 0
framework/native/libs/input/KeyLayoutMap.cpp
#define LOG_TAG “KeyLayoutMap”
#define LOG_NDEBUG 0
#define DEBUG_PARSER 1
#define DEBUG_MAPPING 1
示例:
logcat -s “EventHub” “InputDevice” “KeyLayoutMap“
3,dumpsys input
读取Input相关的信息,大概分为Event Hub State、Input Reader State、Input Dispatcher State这三个部分,从这里,同时也初窥到了Android中Input的层次关系