1.Using "adb shell" to enter your android device.
2.Then using "getevent" command to get every event happen from now
3.Touch on your Gallery item. You will get something like this ...
/dev/input/event4: 0003 0035 00000820 <-- X position
/dev/input/event4: 0003 0036 00000d26 <-- Y position
/dev/input/event4: 0003 0030 00000028
/dev/input/event4: 0003 0039 00000000
/dev/input/event4: 0000 0002 00000000
/dev/input/event4: 0003 0000 00000820
/dev/input/event4: 0003 0001 00000d26
/dev/input/event4: 0001 014a 00000001
/dev/input/event4: 0000 0000 00000000
/dev/input/event4: 0003 0035 00000820<--- unnecessary from here
/dev/input/event4: 0003 0036 00000d26
/dev/input/event4: 0003 0030 00000028
/dev/input/event4: 0003 0039 00000000
/dev/input/event4: 0000 0002 00000000
/dev/input/event4: 0000 0000 00000000
/dev/input/event4: 0003 0035 00000820
/dev/input/event4: 0003 0036 00000d26
/dev/input/event4: 0003 0030 00000028
/dev/input/event4: 0003 0039 00000000
/dev/input/event4: 0000 0002 00000000
/dev/input/event4: 0000 0000 00000000
/dev/input/event4: 0003 0035 00000820
/dev/input/event4: 0003 0036 00000d26
/dev/input/event4: 0003 0030 00000028
/dev/input/event4: 0003 0039 00000000
/dev/input/event4: 0000 0002 00000000
/dev/input/event4: 0000 0000 00000000<--- unnecessary to here
/dev/input/event4: 0003 0035 00000820
/dev/input/event4: 0003 0036 00000d26
/dev/input/event4: 0003 0030 00000028
/dev/input/event4: 0003 0039 00000000
/dev/input/event4: 0000 0002 00000000
/dev/input/event4: 0000 0000 00000000
/dev/input/event4: 0001 014a 00000000
/dev/input/event4: 0000 0000 00000000
4.Making shell script to send event directly to device.
- Convert Hex to Decimal
- Skip the middle part that is make lag and unnecessary(Timing also big problem)
- Pass parameters for x,y position.
NOTE: below script is not match with above values. It was created from another capture.
#!/bin/sh
#
# Script to send touch event directly
# $1 for x , $2 for y
#
adb shell "sendevent /dev/input/event4 3 53 $1;
sendevent /dev/input/event4 3 54 $2;
sendevent /dev/input/event4 3 48 38;
sendevent /dev/input/event4 3 57 0;
sendevent /dev/input/event4 0 2 0;
sendevent /dev/input/event4 3 0 $1;
sendevent /dev/input/event4 3 1 $2;
sendevent /dev/input/event4 1 330 1;
sendevent /dev/input/event4 0 0 0;
sendevent /dev/input/event4 3 53 $1;
sendevent /dev/input/event4 3 54 $2;
sendevent /dev/input/event4 3 48 38;
sendevent /dev/input/event4 3 57 0;
sendevent /dev/input/event4 0 2 0;
sendevent /dev/input/event4 0 0 0;
sendevent /dev/input/event4 1 330 0;
sendevent /dev/input/event4 0 0 0"
5. In your Monkey Runner script, using subprocess to call the shell script file.
try:
subprocess.Popen(['bash', '-c', './yourshellscript.sh '+str(3000)+' '+str(3500)])
except:
raise Exception('Could not open the File: yourshellscript.sh')
NOTE: x,y parameters are not the same value on screen resolution. you need to find the usable values.
Hope it will help.
No comments:
Post a Comment