I want to control an Android device programmatically via ADB.
Since I have to scroll a list, I tried to scroll via a command like:
adb shell input touchscreen swipe 935 500 789 500 1000
This works, but the problem is that Android adds a fling/rubber band effect. So when the swipe is done it still scrolls a bit further. But I need to scoll pixel-perfect so this approach doesn't work in the way I need it. Even when I increase the swipe duration to 3000ms it scrolls for some more pixels.
Is there maybe an easy trick to tell ADB/my device 'swipe but hold down the finger after moving for ~500ms before releasing the finger in order to prevent the fling effect'?
What I also tried is to control the events manually.
Therefore I ran adb getevent
, performed a swipe on the device and collected the output:
[...]
/dev/input/event6: 0000 0000 00000000
/dev/input/event6: 0003 0035 000000fb
/dev/input/event6: 0003 0030 0000000a
/dev/input/event6: 0000 0000 00000000
/dev/input/event6: 0003 0035 000000fa
/dev/input/event6: 0003 0030 0000000b
/dev/input/event6: 0000 0000 00000000
/dev/input/event6: 0003 0036 000001b6
/dev/input/event6: 0003 0030 0000000c
/dev/input/event6: 0000 0000 00000000
/dev/input/event6: 0003 0035 000000f9
/dev/input/event6: 0003 0030 0000000d
/dev/input/event6: 0000 0000 00000000
/dev/input/event6: 0003 0035 000000f8
/dev/input/event6: 0003 0030 0000000e
/dev/input/event6: 0000 0000 00000000
/dev/input/event6: 0003 0035 000000f7
/dev/input/event6: 0003 0030 0000000f
/dev/input/event6: 0000 0000 00000000
/dev/input/event6: 0003 0030 00000000
/dev/input/event6: 0003 0039 ffffffff
/dev/input/event6: 0000 0000 00000000
/dev/input/event6: 0003 002f 0000000c
/dev/input/event6: 0003 0039 0000000c
/dev/input/event6: 0003 0035 000000f7
/dev/input/event6: 0003 0036 000001b6
/dev/input/event6: 0000 0000 00000000
I guess this should tell me that my event is /dev/input/event6
and I assume that the event codes I need are 0035
, 0036
and 0039
.
So I tried around a little bit and came up with an approach like:
adb shell sendevent /dev/input/event6 3 53 935
adb shell sendevent /dev/input/event6 0 0 0
adb shell sendevent /dev/input/event6 3 54 500
adb shell sendevent /dev/input/event6 0 0 0
adb shell sendevent /dev/input/event6 3 57 1
adb shell sendevent /dev/input/event6 0 0 0
adb shell sendevent /dev/input/event6 3 53 789
adb shell sendevent /dev/input/event6 0 0 0
adb shell sendevent /dev/input/event6 3 54 500
adb shell sendevent /dev/input/event6 0 0 0
adb shell sendevent /dev/input/event6 3 57 0
adb shell sendevent /dev/input/event6 0 0 0
This is also done similarly here. But it didn't work at all, nothing changed on the device. Since I don't know what to try next or if my approach is correct at all, I'd like to ask you if you could tell me where my mistakes are.
Thanks!