打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
记录小米设备事件获取

Android 系统里面有很多小工具,运行这些工具,我们可以掌握很多数据,再顺藤摸瓜,就可以针对设备做特殊的操作。


记录获取我手机的event信息,我的手机是小米版:

  1. F:\eclipse\android_sdk-64\adt-bundle-windows-x86_64-20130219\sdk\platform-tools  
  2. adb shell  
  3. shell@android:/ $ cat /proc/bus/input/devices  
  4. cat /proc/bus/input/devices  
  5. I: Bus=0018 Vendor=0001 Product=0001 Version=0001  
  6. N: Name="mione-keypad"          ---->特殊键   
  7. P: Phys=mione-keypad/input0  
  8. S: Sysfs=/devices/platform/msm_ssbi.0/pm8058-core/pm8xxx-keypad/input/input0  
  9. U: Uniq=  
  10. H: Handlers=event0  
  11. B: PROP=0  
  12. B: EV=13  
  13. B: KEY=40000000 0 0 0 0 0 0 10000 0 0 0 0 0 0 0 0 0 0 0 0 c0000 0 0 0  
  14. B: MSC=10  
  15.   
  16.   
  17. I: Bus=0018 Vendor=4654 Product=5000 Version=0100  
  18. N: Name="ft5x0x"            ----> 触摸屏  
  19. P: Phys=/devices/i2c-3/3-0038/input/input1  
  20. S: Sysfs=/devices/i2c-3/3-0038/input/input1  
  21. U: Uniq=  
  22. H: Handlers=event1  
  23. B: PROP=0  
  24. B: EV=9  
  25. B: ABS=6640000 0  
  26.   
  27.   
  28. I: Bus=0000 Vendor=0000 Product=0000 Version=0000  
  29. N: Name="pmic8xxx_pwrkey"           ---->按键  
  30. P: Phys=pmic8xxx_pwrkey/input0  
  31. S: Sysfs=/devices/platform/msm_ssbi.0/pm8058-core/pm8xxx-pwrkey/input/input2  
  32. U: Uniq=  
  33. H: Handlers=event2  
  34. B: PROP=0  
  35. B: EV=3  
  36. B: KEY=100000 0 0 0  
  37.   
  38.   
  39. I: Bus=0000 Vendor=0000 Product=0000 Version=0000  
  40. N: Name="lightsensor"           ---->光感应器  
  41. P: Phys=/devices/virtual/input/input3  
  42. S: Sysfs=/devices/virtual/input/input3  
  43. U: Uniq=  
  44. H: Handlers=event3  
  45. B: PROP=0  
  46. B: EV=9  
  47. B: ABS=100 0  
  48.   
  49.   
  50. I: Bus=0000 Vendor=0000 Product=0000 Version=0000  
  51. N: Name="proximity"         ---->近距离感应器(脸颊感应)  
  52. P: Phys=/devices/virtual/input/input4  
  53. S: Sysfs=/devices/virtual/input/input4  
  54. U: Uniq=  
  55. H: Handlers=event4  
  56. B: PROP=0  
  57. B: EV=9  
  58. B: ABS=100 2000000  
  59.   
  60.   
  61. I: Bus=0018 Vendor=0000 Product=0000 Version=0000  
  62. N: Name="accelerometer"         ---->加速度计  
  63. P: Phys=/devices/virtual/input/input5  
  64. S: Sysfs=/devices/virtual/input/input5  
  65. U: Uniq=  
  66. H: Handlers=event5  
  67. B: PROP=0  
  68. B: EV=9  
  69. B: ABS=7  
  70.   
  71.   
  72. I: Bus=0018 Vendor=0000 Product=0000 Version=0000  
  73. N: Name="compass"           ---->定位仪  
  74. P: Phys=/devices/virtual/input/input6  
  75. S: Sysfs=/devices/virtual/input/input6  
  76. U: Uniq=  
  77. H: Handlers=event6  
  78. B: PROP=0  
  79. B: EV=9  
  80. B: ABS=7  
  81.   
  82.   
  83. I: Bus=0000 Vendor=0000 Product=0000 Version=0000  
  84. N: Name="8660_handset"          ---->线控按键  
  85. P: Phys=pmic8058_othc/input0  
  86. S: Sysfs=/devices/platform/msm_ssbi.0/pm8058-core/pm8058-othc.1/input/input7  
  87. U: Uniq=  
  88. H: Handlers=event7  
  89. B: PROP=0  
  90. B: EV=23  
  91. B: KEY=10000 110 0 0 0 0 0  
  92. B: SW=4  

然后我们用getevent了解设备运作,getevent用来监听Handler 指定设备事件,如:
  1. > adb shell getevent /dev/input/event1   (event1为屏幕事件)  

接着点击一下手机屏幕,会看到类似以下内容:

  1. [type] [code] [value]  
  2. 0003 0039 00000000   --》开始   (57)  
  3. 0003 0035 0000015d   --》x轴0x15d的位置 (53)  
  4. 0003 0036 0000011d   --》y轴0x11d的位置  (54)  
  5. 0003 003a 00000010   --》ABS_MT_PRESSURE  (58)  
  6. 0003 0032 00000010   --》ABS_MT_WIDTH_MAJOR  (50)       
  7. 0000 0002 00000000   --》SYN                 (2)  
  8. 0000 0000 00000000  
  9. 0003 0039 00000000   --》开始  
  10. 0003 0035 0000015d   --》x轴0x15d的位置  
  11. 0003 0036 0000011d   --》y轴0x11d的位置  
  12. 0003 003a 00000001   --》ABS_MT_PRESSURE   
  13. 0003 0032 00000001   --》ABS_MT_WIDTH_MAJOR  
  14. 0000 0002 00000000   --》SYN  
  15. 0000 0000 00000000  
  16. 0000 0002 00000000  
  17. 0000 0000 00000000  
  18.   
  19.   
  20. 参见 /frameworks/base/include/ui/EventHub.h 可知code意义  
  21. #define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */  
  22. #define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */  
  23. #define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */  
  24. #define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */  
  25. #define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */  
  26. #define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */  
  27. #define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */  
  28. #define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device (finger, pen, ...) */  
  29. #define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */  
  30. #define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */  
  31. #define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */  

一次快速单击app图标触屏的监听:

getevent /dev/input/event1

  1. 0003 0039 00000037     初始化事件id  
  2. 0003 0039 00000000     初始化事件结束  
  3. 0003 0035 000000ae     坐标x  
  4. 0003 0036 000001ca     坐标y  
  5. 0003 003a 00000010<span style="white-space:pre">    </span>  
  6. 0003 0032 00000010  
  7. 0000 0000 00000000     压下结束  
  8. 0003 003a 00000020  
  9. 0003 0032 00000020  
  10. 0000 0000 00000000     移动结束  
  11. 0003 0039 ffffffff     事件id清空  
  12. 0000 0000 00000000     一个事件的结束  

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
有了这款神奇的工具侠软件 再也不会被苹果小米换内存CPU忽悠了
小米自带的投屏功能,原来那么强大,现在知道还不算晚
如何用小米手机实现投屏,影像在电视电脑上出现?你还没用过吗?
小米手机官方通用解锁教程
小米手机的无线投屏功能居然这么好用,电视电脑上玩手机游戏?
小米手机5 官方解锁BL教程
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服