input之我见02——Input调试Tips

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” 
  1. 01-01 00:00:21.734 4076 4114 V EventHub: Opening device: /dev/input/event2
  2. 01-01 00:00:21.734 4076 4114 V EventHub: Created descriptor: raw=:1b8e:0cec:, cooked=02b1ce58713e0e531eab61b0742baac6893ff49f
  3. 01-01 00:00:21.734 4076 4114 V EventHub: add device 1: /dev/input/event2
  4. 01-01 00:00:21.734 4076 4114 V EventHub: bus: 0010
  5. 01-01 00:00:21.734 4076 4114 V EventHub: vendor 1b8e
  6. 01-01 00:00:21.734 4076 4114 V EventHub: product 0cec
  7. 01-01 00:00:21.734 4076 4114 V EventHub: version 0001
  8. 01-01 00:00:21.734 4076 4114 V EventHub: name: "cec_input"
  9. 01-01 00:00:21.734 4076 4114 V EventHub: location: ""
  10. 01-01 00:00:21.734 4076 4114 V EventHub: unique id: ""
  11. 01-01 00:00:21.734 4076 4114 V EventHub: descriptor: "02b1ce58713e0e531eab61b0742baac6893ff49f"
  12. 01-01 00:00:21.734 4076 4114 V EventHub: driver: v1.0.1
  13. 01-01 00:00:21.735 4076 4114 D EventHub: No input device configuration file found for device 'cec_input'.
  14. 01-01 00:00:21.741 4076 4114 W EventHub: Unable to disable kernel key repeat for /dev/input/event2: Function not implemented
  15. 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
  16. 01-01 00:00:21.741 4076 4114 V EventHub: Opening device: /dev/input/mice
  17. 01-01 00:00:21.741 4076 4114 E EventHub: could not get driver version for /dev/input/mice, Not a typewriter
  18. 01-01 00:00:21.794 4076 4114 V EventHub: Opening device: /dev/input/event1
  19. 01-01 00:00:21.795 4076 4114 V EventHub: Created descriptor: raw=:0001:0001:, cooked=485d69228e24f5e46da1598745890b214130dbc4
  20. 01-01 00:00:21.795 4076 4114 V EventHub: add device 2: /dev/input/event1
  21. 01-01 00:00:21.795 4076 4114 V EventHub: bus: 0010
  22. 01-01 00:00:21.795 4076 4114 V EventHub: vendor 0001
  23. 01-01 00:00:21.795 4076 4114 V EventHub: product 0001
  24. 01-01 00:00:21.795 4076 4114 V EventHub: version 0100
  25. 01-01 00:00:21.795 4076 4114 V EventHub: name: "gpio_keypad"
  26. 01-01 00:00:21.795 4076 4114 V EventHub: location: "gpio_keypad/input0"
  27. 01-01 00:00:21.795 4076 4114 V EventHub: unique id: ""
  28. 01-01 00:00:21.795 4076 4114 V EventHub: descriptor: "485d69228e24f5e46da1598745890b214130dbc4"
  29. 01-01 00:00:21.795 4076 4114 V EventHub: driver: v1.0.1
  30. 01-01 00:00:21.795 4076 4114 D EventHub: No input device configuration file found for device 'gpio_keypad'.
  31. 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
  32. 01-01 00:00:21.800 4076 4114 V EventHub: Opening device: /dev/input/event0
  33. 01-01 00:00:21.801 4076 4114 V EventHub: Created descriptor: raw=:0001:0001:nonce:0001, cooked=d2c52ff0f656fac4cd7b7a118d575e0109a9fe1c
  34. 01-01 00:00:21.801 4076 4114 V EventHub: add device 3: /dev/input/event0
  35. 01-01 00:00:21.801 4076 4114 V EventHub: bus: 0010
  36. 01-01 00:00:21.801 4076 4114 V EventHub: vendor 0001
  37. 01-01 00:00:21.801 4076 4114 V EventHub: product 0001
  38. 01-01 00:00:21.801 4076 4114 V EventHub: version 0100
  39. 01-01 00:00:21.801 4076 4114 V EventHub: name: "aml_keypad"
  40. 01-01 00:00:21.801 4076 4114 V EventHub: location: "keypad/input0"
  41. 01-01 00:00:21.801 4076 4114 V EventHub: unique id: ""
  42. 01-01 00:00:21.801 4076 4114 V EventHub: descriptor: "d2c52ff0f656fac4cd7b7a118d575e0109a9fe1c"
  43. 01-01 00:00:21.801 4076 4114 V EventHub: driver: v1.0.1
  44. 01-01 00:00:21.801 4076 4114 D EventHub: No input device configuration file found for device 'aml_keypad'.
  45. 01-01 00:00:21.805 4076 4114 W EventHub: Unable to disable kernel key repeat for /dev/input/event0: Function not implemented
  46. 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
  47. 01-01 00:00:21.805 4076 4114 V EventHub: Created descriptor: raw=:0000:0000:uniqueId:<virtual>name:Virtual, cooked=a718a782d34bc767f4689c232d64d527998ea7fd
  48. 01-01 00:00:21.810 4076 4114 V EventHub: Reporting device opened: id=-1, name=<virtual>
  49. 01-01 00:00:21.810 4076 4114 V EventHub: Reporting device opened: id=3, name=/dev/input/event0
  50. 01-01 00:00:21.810 4076 4114 V EventHub: Reporting device opened: id=2, name=/dev/input/event1
  51. 01-01 00:00:21.810 4076 4114 V EventHub: Reporting device opened: id=1, name=/dev/input/event2
  52. 01-01 00:00:21.810 4076 4114 I InputReader: Device added: id=-1, name='Virtual', sources=0x00000301
  53. 01-01 00:00:21.810 4076 4114 I InputReader: Device added: id=3, name='aml_keypad', sources=0x00004703
  54. 01-01 00:00:21.811 4076 4114 I InputReader: Reconfiguring input devices. changes=0x00000080
  55. 01-01 00:00:21.811 4076 4114 I InputReader: Device added: id=2, name='gpio_keypad', sources=0x00000101
  56. 01-01 00:00:21.811 4076 4114 I InputReader: Device added: id=1, name='cec_input', sources=0x00000101
  57. 01-01 00:00:21.811 4076 4114 D InputDispatcher: notifyDeviceReset - eventTime=16199233173, deviceId=-1
  58. 01-01 00:00:21.811 4076 4114 D InputDispatcher: notifyDeviceReset - eventTime=16199233173, deviceId=3
  59. 01-01 00:00:21.811 4076 4114 D InputDispatcher: notifyDeviceReset - eventTime=16199233173, deviceId=2
  60. 01-01 00:00:21.811 4076 4113 D InputDispatcher: dispatchDeviceReset - eventTime=16199233173, deviceId=-1
  61. 01-01 00:00:21.811 4076 4113 D InputDispatcher: dispatchDeviceReset - eventTime=16199233173, deviceId=3
  62. 01-01 00:00:21.811 4076 4114 D InputDispatcher: notifyDeviceReset - eventTime=16199233173, deviceId=1
  63. 01-01 00:00:21.811 4076 4113 D InputDispatcher: dispatchDeviceReset - eventTime=16199233173, deviceId=2
  64. 01-01 00:00:21.811 4076 4114 D InputDispatcher: notifyConfigurationChanged - eventTime=16199233173
  65. 01-01 00:00:21.811 4076 4113 D InputDispatcher: dispatchDeviceReset - eventTime=16199233173, deviceId=1
  66. 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的层次关系
Comments are closed.
TOP