使用Adb输入时记录按键事件 [英] Log the Key Event when using Adb input

查看:993
本文介绍了使用Adb输入时记录按键事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用命令adb shell su -- getevent -lt /dev/input/event5 > Test.txt记录触摸事件.当我触摸屏幕时,它可以工作,即,它可以记录所有动作(按下键,按下键并使用坐标键向上键).

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).

但是,当我使用命令adb shell input tap x y模拟触摸时,即使设备获得了事件(例如,打开了应用程序),但在日志文件中,也没有关于此点击的日志行.

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.

如何记录使用adb进行的模拟按键事件触摸?

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

推荐答案

之所以不能在getevent输出中看到input tap事件,是因为sendeventgetevent可与Linux内核输入一起使用events and input命令将事件直接注入Android输入事件队列.

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.

这篇(古老但仍然有用的文章)有一些漂亮的图表,说明了Android中输入事件的传播.

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

不幸的是,没有简单(即用)的方法可以完成您所要的事情.我能想到的最接近的事情是使用dumpsys input命令-它在 RecentQueue:部分中显示了最后10个输入事件(包括由input命令注入的事件).

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.

这篇关于使用Adb输入时记录按键事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆