Cartucho / android-touch-record-replay

How to record and replay touchscreen events on an Android device.
Apache License 2.0
224 stars 46 forks source link

Android 10 device: SELinux gives permission denied when trying to replay #22

Open peterdk opened 4 years ago

peterdk commented 4 years ago

Unfortunately it seems that on Android 10 it's no longer allowed to write to /dev/input/eventX.

Errors: could not open /dev/input/event2, Permission denied And in logcat: mysendevent: type=1400 audit(0.0:18056): avc: denied { write } for name="event2" dev="tmpfs" ino=13462 scontext=u:r:shell:s0 tcontext=u:object_r:input_device:s0 tclass=chr_file permissive=0 So i am afraid you need root access for replay. Recording goes well.

peterdk commented 4 years ago

So, could not get replay to work on my Andorid 10 device, but I did succeed in recording on device, and then replaying on 10.0 Emulator. Really cool.

Use

su
setenforce 0

to disable SELinux in adb shell on the emulator.

I wrote a script to convert the absolute x,y positions from the recording to relative coordinates, since the emulator uses a different scale on both x,y event though I recreated the exact screen specs in a emulator. So using these MAX_Y and MAX_X properly, I can now reproduce my touch event recording on device on a emulator. Still a work in progress, it's not perfect yet.

Cartucho commented 4 years ago

Thank you for sharing this info. At least we can use in the emulator.

fadiaburaid commented 3 years ago

So this won't run on Android 10 devices because I am getting the same error 😔?

Cartucho commented 3 years ago

@fadiaburaid I don't think so, they keep adding extra security making these kinds of scripts harder to run

fadiaburaid commented 3 years ago

Thanks @Cartucho . I have managed to translate the hex getevent codes for taps to "adb shell input" format with the delay time between taps using the timestamps. However translating swipes will be very tricky.