Android sendevent确实很慢-如何加快速度? [英] Android sendevent is really slow - how to speed it up?

查看:987
本文介绍了Android sendevent确实很慢-如何加快速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行一些ui自动化,并且可以使用getevent存储屏幕触摸,但是当我尝试使用sendevent发送此触摸时,这会花费很长时间,因此很难真正重播输入.

I am doing some ui automation, and I am able to store screen touches using getevent, but when I try to send this using sendevent, it takes a really long time, making it hard to actually replay the inputs.

我已经尝试将脚本加载到设备上并在设备上本地运行脚本(带有一堆sendevent命令的脚本).但这只是稍微改善了一点.还有其他方法可以更快地注入这些命令吗?

I have already trying loading the script onto the device and running the script locally on the device (a script with a bunch of sendevent commands). But this only imporved this slightly. Is there some other way to inject these commands in a quicker way?

推荐答案

触摸处理程序在不同设备上的实现方式有所不同.您应该cat /proc/bus/input/devices以查看在何处实现了触摸处理程序.

The handler for touch is implemented differently across devices. You should cat /proc/bus/input/devices to see where the touch handler is implemented.

您还可以执行adb shell getevent,与设备进行交互并查看接口名称的输出.

You can also do adb shell getevent, interact with the device and see the output for the interface name.

重放需要很长时间的原因是因为sendevent二进制文件会打开接口文件,向其中写入数据,并在每次调用sendevent时将其关闭.因此,从理论上讲,如果您有一堆sendevent命令,则二进制文件将打开接口文件,写入数据并为每个命令关闭数据.

The reason why your replay takes a long time is because the sendevent binary opens the interface file, writes data to it and closes it for every call to sendevent. So in theory, if you have a bunch of sendevent commands, the binary is opening the interface file, writing data and closing it for every command.

我解决此问题的方法是,将/system/core/toolbox下的sendevent.c文件重写为仅在重播期间打开一次文件,然后写入所有数据并在重播结束时将其关闭.它对我来说很完美!

The way I've solved this issue is by re-writing the sendevent.c file under /system/core/toolbox to open the file only once during replay, writing all the data and closing it at the end of the replay. It works perfectly for me!

这篇关于Android sendevent确实很慢-如何加快速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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