记录小米设备事件获取(一)

2014-11-24 09:40:04 · 作者: · 浏览: 12
Android 系统里面有很多小工具,运行这些工具,我们可以掌握很多数据,再顺藤摸瓜,就可以针对设备做特殊的操作。
记录获取我手机的event信息,我的手机是小米版:
F:\eclipse\android_sdk-64\adt-bundle-windows-x86_64-20130219\sdk\platform-tools  
adb shell  
shell@android:/ $ cat /proc/bus/input/devices  
cat /proc/bus/input/devices  
I: Bus=0018 Vendor=0001 Product=0001 Version=0001  
N: Name="mione-keypad"          ---->特殊键   
P: Phys=mione-keypad/input0  
S: Sysfs=/devices/platform/msm_ssbi.0/pm8058-core/pm8xxx-keypad/input/input0  
U: Uniq=  
H: Handlers=event0  
B: PROP=0  
B: EV=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  
B: MSC=10  
  
  
I: Bus=0018 Vendor=4654 Product=5000 Version=0100  
N: Name="ft5x0x"            ----> 触摸屏  
P: Phys=/devices/i2c-3/3-0038/input/input1  
S: Sysfs=/devices/i2c-3/3-0038/input/input1  
U: Uniq=  
H: Handlers=event1  
B: PROP=0  
B: EV=9  
B: ABS=6640000 0  
  
  
I: Bus=0000 Vendor=0000 Product=0000 Version=0000  
N: Name="pmic8xxx_pwrkey"           ---->按键  
P: Phys=pmic8xxx_pwrkey/input0  
S: Sysfs=/devices/platform/msm_ssbi.0/pm8058-core/pm8xxx-pwrkey/input/input2  
U: Uniq=  
H: Handlers=event2  
B: PROP=0  
B: EV=3  
B: KEY=100000 0 0 0  
  
  
I: Bus=0000 Vendor=0000 Product=0000 Version=0000  
N: Name="lightsensor"           ---->光感应器  
P: Phys=/devices/virtual/input/input3  
S: Sysfs=/devices/virtual/input/input3  
U: Uniq=  
H: Handlers=event3  
B: PROP=0  
B: EV=9  
B: ABS=100 0  
  
  
I: Bus=0000 Vendor=0000 Product=0000 Version=0000  
N: Name="proximity"         ---->近距离感应器(脸颊感应)  
P: Phys=/devices/virtual/input/input4  
S: Sysfs=/devices/virtual/input/input4  
U: Uniq=  
H: Handlers=event4  
B: PROP=0  
B: EV=9  
B: ABS=100 2000000  
  
  
I: Bus=0018 Vendor=0000 Product=0000 Version=0000  
N: Name="accelerometer"         ---->
加速度计 P: Phys=/devices/virtual/input/input5 S: Sysfs=/devices/virtual/input/input5 U: Uniq= H: Handlers=event5 B: PROP=0 B: EV=9 B: ABS=7 I: Bus=0018 Vendor=0000 Product=0000 Version=0000 N: Name="compass" ---->定位仪 P: Phys=/devices/virtual/input/input6 S: Sysfs=/devices/virtual/input/input6 U: Uniq= H: Handlers=event6 B: PROP=0 B: EV=9 B: ABS=7 I: Bus=0000 Vendor=0000 Product=0000 Version=0000 N: Name="8660_handset" ---->线控按键 P: Phys=pmic8058_othc/input0 S: Sysfs=/devices/platform/msm_ssbi.0/pm8058-core/pm8058-othc.1/input/input7 U: Uniq= H: Handlers=event7 B: PROP=0 B: EV=23 B: KEY=10000 110 0 0 0 0 0 B: SW=4 然后我们用getevent了解设备运作,getevent用来监听Handler 指定设备事件,如: [java] view plaincopy > adb shell getevent /dev/input/event1 (event1为屏幕事件)

接着点击一下手机屏幕,会看到类似以下内容:
[type] [code] [value]  
0003 0039 00000000   --》开始   (57)  
0003 0035 0000015d   --》x轴0x15d的位置 (53)  
0003 0036 0000011d   --》y轴0x11d的位置  (54)  
0003 003a 00000010   --》ABS_MT_PRESSURE  (58)  
0003 0032 00000010   --》ABS_MT_WIDTH_MAJOR  (50)       
0000 0002 00000000   --》SYN                 (2)  
0000 0000 00000000  
0003 0039 00000000   --》开始  
0003 0035 0000015d   --》x轴0x15d的位置  
0003 0036 0000011d   --》y轴0x11d的位置  
0003 003a 00000001   --》ABS_MT_PRESSURE   
0003 0032 00000001   --》ABS_MT_WIDTH_MAJOR  
0000 0002 00000000   --》SYN  
0000 0000 00000000  
0000 0002 00000000  
0000 0000 00000000  

参见 /frameworks/base/include/ui/EventHub.h 可知code意义
#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */
#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circul