Android analog screen Click on input tap Alternative solution

Source: Internet
Author: User

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
    1. Create a new. Sh script (line break must be UNIX.LF)
    2. Puts all the event for the specified action captured into the script
    3. Convert all values in the event to 10 binary
    4. Add a command before all the event sendevent

      Sendevent/dev/input/event1 1 330 1

    5. Importing scripts into the device

      ADB push x.sh/data/local/tmp/x.sh

    6. Execute script

      adb shell--Su-sh/data/local/tmp/x.sh

    7. Observe if the operation is playing back correctly.
System keyboard, touch event capture mode
  1. The device after root
  2. adb shell--Su-getevent
  3. Click a specified x, y coordinate location on the phone screen
  4. 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)

  5. Through the principle of single-variable operation, listen to several similar operation event
  6. By replaying the captured event multiple times and then rejecting the non-critical event by experience
  7. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.