본문 바로가기

IT개발/안드로이드

Android, low level shell click on screen

Android, low level shell click on screen

To send touch event you need to do:

1 Set coordinates:

adb shell sendevent /dev/input/event2 3 0 x
adb shell sendevent
/dev/input/event2 3 1 y

2 Send touch event (must have 0 0 0 pair):

adb shell sendevent /dev/input/event2 1 330 1
adb shell sendevent
/dev/input/event2 0 0 0

3 Send release finger event (must have 0 0 0 pair):

adb shell sendevent /dev/input/event2 1 330 0
adb shell sendevent
/dev/input/event2 0 0 0

Please note:

1 You can record events:

adb shell getevent

2 if you use getevent all event values are in hex.

CONFIRMED, THIS WAY IS NOT WORKING ANYMORE, at least for Android 2.2.

I have rechecked, Android low level events signature was changed starting from Android 2.2 Froyo.

I just dumped single click:

/dev/input/event2: 0003 0030 00000068
/dev/input/event2: 0003 0032 0000000a
/dev/input/event2: 0003 0035 0000022e
/dev/input/event2: 0003 0036 00000039
/dev/input/event2: 0000 0002 00000000
/dev/input/event2: 0003 0012 0000002f
/dev/input/event2: 0003 0014 00000001
/dev/input/event2: 0000 0000 00000000
/dev/input/event2: 0003 0030 00000000
/dev/input/event2: 0003 0032 0000000a
/dev/input/event2: 0003 0035 0000022e
/dev/input/event2: 0003 0036 00000039
/dev/input/event2: 0000 0002 00000000
/dev/input/event2: 0003 0012 00000020
/dev/input/event2: 0003 0014 00000000
/dev/input/event2: 0000 0000 00000000

It has obviously another structure.. I'm investigating right now this situation,

solution will be here tomorrow ;)

After a quick investigation I have reproduced the click for Froyo Android:

Perl script (click on screen at 558, 57 point):

system("adb shell sendevent /dev/input/event2 0003 48 104");
system("adb shell sendevent /dev/input/event2 0003 50 10");
system("adb shell sendevent /dev/input/event2 0003 53 558");
system("adb shell sendevent /dev/input/event2 0003 54 57");
system("adb shell sendevent /dev/input/event2 0000 2 00000000");
system("adb shell sendevent /dev/input/event2 0003 18 47");
system("adb shell sendevent /dev/input/event2 0003 20 00000001");
system("adb shell sendevent /dev/input/event2 0000 0000 00000000");
system("adb shell sendevent /dev/input/event2 0003 48 00000000");
system("adb shell sendevent /dev/input/event2 0003 50 10");
system("adb shell sendevent /dev/input/event2 0003 53 558");
system("adb shell sendevent /dev/input/event2 0003 54 57");
system("adb shell sendevent /dev/input/event2 0000 0002 00000000");
system("adb shell sendevent /dev/input/event2 0003 18 32");
system("adb shell sendevent /dev/input/event2 0003 20 00000000");
system("adb shell sendevent /dev/input/event2 0000 0000 00000000");

How I did it:

1. Start dump motion event you need to reproduce:

~$ adb shell getevent | grep event2

grep is very useful to filter output.

2. Do motion event you want to reproduce;

3. Than just convert all values from hex in dump to decimal values! :)

To find what eventX is working for you do following:

1. Start terminal and type

~$ adb shell getevent

You will see quickly moving traces with for example /dev/input/event4 ......

2. Touch screen once

You must see between event4 few eventX and these eventX right in the moment of the touch

will be yours input interface for reproducing motion events! :)



Please check my tutorial for low level interaction with device


Happy motion events reproducing! (:


Best regards,

Yahor