Motive explanation
You can simulate keyboard events, touch-screen events keyevent, and Text,tap by using the ADB shell-I input
But the target Android 4.0.3 system input in hand only supports text and keyevent, does not support tap and cannot simulate touch-click events.
usage: input [text|keyevent] input text <string> input keyevent <event_code>
Then began to look for alternative solutions for analog touch screens.
The latest Android api.24 simulator has a wide range of input support:
Usage: input [<source>] <command> [<arg>...]The sources are: keyboard mouse joystick touchnavigation touchpad trackball dpad stylus gamepad touchscreenThe commands and default sources are: text <string> (Default: touchscreen) keyevent [--longpress] <key code number or name> ... (Default: keyboard) tap <x> <y> (Default: touchscreen) swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)
Press (Default:trackball)
Roll (Default:trackball)
Reference source
- Radhoo/android-event-injector:a JNI approach to injecting events (keys and touch) on rooted Android
Resources
- Event Primitives Android Multi-Touch interface-arm-linux-Blog Park
- Programmatically injecting Events on Android-part 1-pocketmagic
- Programmatically injecting Events on Android-part 2-pocketmagic
- Android Emulation system Events (iii)-Banketree-Blog channel-csdn.net
- Android Emulation System Event (ii)-Banketree-Blog channel-csdn.net
- Android Analog system events (i)-banketree-Blog channel-csdn.net
- Android sendevent/getevent Usage-kickxxx's column-Blog channel-csdn.net
- Android High segment Advanced Strategy (4) Android Analog click-AIMN open Source Library-Blog channel-csdn.net
- Recording Xiaomi device event acquisition-banketree-Blog channel-csdn.net
Event Playback Mode
- Create a new. Sh script (line break must be UNIX.LF)
- Puts all the event for the specified action captured into the script
- Convert all values in the event to 10 binary
- Add a command before all the event
sendevent
Sendevent/dev/input/event1 1 330 1
- Importing scripts into the device
ADB push x.sh/data/local/tmp/x.sh
- Execute script
adb shell--Su-sh/data/local/tmp/x.sh
- Observe if the operation is playing back correctly.
System keyboard, touch event capture mode
- The device after root
- adb shell--Su-getevent
- Click a specified x, y coordinate location on the phone screen
In the command-line window, the monitor hears many event, similar to the following
Add device 1:/dev/input/event3
Name: "bma222e" &NBSP;
Add device 2:/dev/input/event2
Name: " Headset-keyboard "&NBSP;
Add device 3:/dev/input/event1
Name:" Ft5x0x_ts "&NBSP;
Add device 4:/dev/ input/event0
Name: "Sprd-keypad" &NBSP;
/dev/input/event1:0001 014a 00000001
/dev/input/ event1:0003 0030 000000c8
/dev/input/event1:0003 0035 00000015
/dev/input/event1:0003 0036 000002ff
/dev/input/event1:0003 0032 00000001
/dev/input/event1:0000 0002 00000000
/dev /input/event1:0000 0000 00000000
/dev/input/event1:0003 0030 000000c8
/dev/input/event1:0003 0035 00000015
/dev/input/event1:0003 0036 000002ff
/dev/input/event1:0003 0032 00000001
/dev /input/event1:0000 0002 00000000
/dev/input/event1:0000 0000 00000000
/dev/input/event1:0001 014a 00000000
/dev/input/event1:0000 0000 00000000
event [Type] [code] [value]
(different system versions of mobile phone monitor may not hear the same content.) Single Touch, unlike multi-touch device events.)
Event0:name contains keypad strings, keyboard devices
Event1:name contains TS strings, touch screen devices
Event2:name contains headset, headset-related control devices (guessed)
- Through the principle of single-variable operation, listen to several similar operation event
- By replaying the captured event multiple times and then rejecting the non-critical event by experience
Extract "Common event", " critical event", similar to the following
/dev/input/event1:0001 014a 00000001
/dev/input/event1:0003 0030 000000c8
/dev/input/event1:0003 0035 000000f0
/dev/input/event1:0003 0036 00000384
/dev/input/event1:0003 0032 00000001
/dev/input/event1:0000 0002 00000000
/dev/input/event1:0000 0000 00000000
/dev/input/event1:0001 014a 00000000
/dev/input/event1:0000 0000 00000000
The key event Red section, respectively, is tested to correspond to the X, Y coordinate address. You can convert 16 into 10 to get the exact value.
Minimum event set sequence attempt
This minimal sequence does not trigger correctly after a real-world test. It seems that the underlying principle has not been mastered.
下面是两点触摸支持的最小事件集序列:ABS_MT_TOUCH_MAJOR 0x30ABS_MT_POSITION_X 0x35ABS_MT_POSITION_Y 0x36SYN_MT_REPORT 0x02 //上报第一个点ABS_MT_TOUCH_MAJORABS_MT_POSITION_XABS_MT_POSITION_YSYN_MT_REPORT //上报第二个点SYN_REPORT 0x00 //开始动作
Android analog screen Click on input tap Alternative solution