记录小米设备事件获取

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 指定设备事件,如:
> 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 circular) */
#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */
#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */
#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */
#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */
#define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */
#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device (finger, pen, ...) */
#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */
#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */

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

getevent /dev/input/event1

0003 0039 00000037     初始化事件id
0003 0039 00000000     初始化事件结束
0003 0035 000000ae     坐标x
0003 0036 000001ca     坐标y
0003 003a 00000010	
0003 0032 00000010
0000 0000 00000000     压下结束
0003 003a 00000020
0003 0032 00000020
0000 0000 00000000     移动结束
0003 0039 ffffffff     事件id清空
0000 0000 00000000     一个事件的结束

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值