Log the Key Event when using Adb input

2020-03-25 11:30发布

I use the command adb shell su -- getevent -lt /dev/input/event5 > Test.txt to log the touch event. It works when I touch the screen, i.e, it writes all actions (key down, key move and key up with the coordinates).

But, when I use the command adb shell input tap x y to simulate the touch, even if the device get the event (for example, the app is opened) but in the log file, there is no log lines about this tap.

How can I log the simulate the key event touch with adb?

1条回答
够拽才男人
2楼-- · 2020-03-25 12:12

The reason for you not being to see your input tap events in the getevent output is that sendevent and getevent work with Linux kernel input events and input command injects the events directly into the Android input event queue.

This (old but still useful) article has some nice diagrams illustrating the input event propagation in Android.

Unfortunately there is no easy (ready to use) way to do what you asked for. The closest thing I could think of is using dumpsys input command - it shows last 10 input events (including ones injected by the input command) in the RecentQueue: section.

查看更多
登录 后发表回答