Reputation: 101
I'm trying to simulate 3 (simultaneous not consecutive) long taps on an android device using adb.
The most promising lead I found was here but I haven't been able to modify it so that I can use it.
Any thoughts on how to accomplish such feat?
Thanks.
Upvotes: 10
Views: 8102
Reputation: 3199
I found a very simple work around to simulate long touches. Simulate a swipe at the same point.
input swipe <x1> <y1> <x2> <y2> [duration in milliseconds]
Where x1 == x2, and y1 == y2.
This will simulate a swipe but since the your starting point and your end point are the same, it will act as if it was a lng press
Upvotes: 13
Reputation: 3199
I've also been working on something related to this; and after loads of research, this is the best I've got - it can do exactly what you want, but there are a few drawbacks depending on your context.
It's simple, just send a low-level input events such as:
simulating a touch down event
sendevent /dev/input/event4 1 330 1 // touch down
sendevent /dev/input/event4 0 0 0 // end of report
Waiting after the touch down event is as if the user's finger is still on the device (i.e. a long press)
simulating a touch release event
sendevent /dev/input/event4 1 330 0 // touch release
sendevent /dev/input/event4 0 0 0 // end of report
SYNTAX
sendevent <device> <type> <code> <value>
For better documentation of the arguments, refer to https://android.googlesource.com/platform/external/kernel-headers/+/8bc979c0f7b0b30b579b38712a091e7d2037c77e/original/uapi/linux/input.h
PROS:
CONS:
NOTE
If you are looking for a simpler way to send an tap, you can use the command
input tap <x> <y>
but be warned, you don't have the luxury of determining how long to simulate the press down (i.e. no long press possible)
Good luck.
Upvotes: 7