Android sendevent is really slow - how to speed it up?

强颜欢笑 提交于 2020-07-05 04:37:12

问题


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.

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?


回答1:


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

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

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.

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!




回答2:


OK. Instead of using the getevent/sendevent you can try direct reading from the event interface inside adb shell try:

dd if=/dev/input/event6 of=record1 # to record

dd if=./record1of=/dev/input/event6 #to play

However, this may run too fast...



来源:https://stackoverflow.com/questions/12079591/android-sendevent-is-really-slow-how-to-speed-it-up

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!