Analysis of analog difference between Android "real machine" and "simulator" touch screen events

Source: Internet
Author: User
Tags final touch

The difference between Android and simulator is the eternal topic, the question of why, the puzzle. The simulator exists and has its effect, but do not believe anything about the simulator. Unless you're an Android pure top app developer or enthusiast, I suggest you throw away the simulator. Its idealized guidance gave us a lot of trouble. Of course, that's a good thing. At the very least, I am interested to find the answer, let me gain more.

The reason for this problem is that there is an automated test requirement, I need to write a script to simulate the touch screen of a series of operations, in lieu of manual test (say ~ 1000 consecutive camera and after the camera exit this abnormal test, how do you do? )。 To prove: Chief, this bug really solved!

Linux can be sendevent to simulate keyboard or mouse click events, and Android is based on Linux2.6, so can also simulate the Click event. A lot of network articles give such a piece of data information, tell you how to achieve analog click:

ADB shell sendevent/dev/input/event0 3 0//x coordinates

ADB shell sendevent/dev/input/event0 3 1//y coordinates

ADB shell sendevent/dev/input/event0 1 330 1//press State, accurate is the pressure value

ADB shell sendevent/dev/input/event0 0 0 0//required row of data

ADB Shell sendevent/dev/input/event0 1 330 0//lift state, no pressure value

ADB shell sendevent/dev/input/event0 0 0 0//required line, equivalent to terminate a complete set of data of the Peugeot

Use the above method to click on the simulator (110,70) point, but, in the real machine, but not, for two points.

1./dev/input/event0x

There's only one/dev/input/event0 on the simulator, but not on the real machine (if that's true, you don't have to leave the factory.-_-| | )。

The device corresponding to event information obtained by CAT:

# cat/proc/bus/input/devices

i:bus=0000 vendor=0000 product=0000 version=0000

N:name= "Qtouch-touchscreen"

p:phys=

S:sysfs=/devices/virtual/input/input5

u:uniq=

H:handlers=event5

B:ev=b

b:key=400 0 4 0 0 0 0 0 0 0 0

b:abs=2750000 11030003

"Qtouch-touchscreen" is not a rule of death event a few, say 1234567 is possible, look at your equipment.

2. Data type X

When exploring the cause, by:

#adb Shell getevent/dev/input/event5 > GetValue

can be obtained:

0003 0035 000007c8

0003 0036 00000771

0003 0038 00000001

0000 0002 00000000

0003 0037 00000010

0000 0000 00000000

This and I previously imagined the coordinates of information is not the same, see C, you know is 16 into the number, the first reaction is to make a 10-system conversion. How exactly is the conversion?

int main (int argc, char *argv[]) dot dot ... (this. c can't write yet?) I can't write it, can't I search? )

can be obtained:

3 53 1992

3 54 1905

3 56 1

0 2 0

3 55 16

0 0 0

No matter why, do a test to verify the results:

ADB Shell SENDEVENT/DEV/INPUT/EVENT5 3 53 1992

ADB Shell sendevent/dev/input/event5 3 54 1905

ADB Shell SENDEVENT/DEV/INPUT/EVENT5 3 56 1

ADB Shell SENDEVENT/DEV/INPUT/EVENT5 0 2 0

ADB Shell SENDEVENT/DEV/INPUT/EVENT5 3 55 16

ADB shell sendevent/dev/input/event5 0 0 0

Here to mention, if the operation of the data is particularly large, then we can use the strong VI, in the script to implement the bulk data conversion, for example:

Vim ' +%normal GG ' +., $g/^/s//adb shell sendevent//dev//input//event5/g ' +wq ' value

Results can be achieved by clicking

Since the test results prove that the messy number is right, then it will be the reason! In fact, the root cause of the problem is because the hand of the real machine device has been supported by Multi-Touch.

In Android, multi-touch functionality relies on the following key software bits defined in Rawinputevent.java:

public class Rawinputevent {     
        
...    
  public static final int abs_mt_touch_major = 0x30;     
        
  public static final int abs_mt_touch_minor = 0x31;     
        
  public static final int abs_mt_width_major = 0x32;     
        
  public static final int abs_mt_width_minor = 0x33;     
        
  public static final int abs_mt_orientation = 0x34;     
        
  public static final int abs_mt_position_x = 0x35;     
        
  public static final int abs_mt_position_y = 0x36;     
        
  public static final int abs_mt_tool_type = 0x37;     
        
  public static final int abs_mt_blob_id = 0x38;     
        
...    
}

In Keyinputqueue.java, the system creates a thread that puts all input events into a queue, and at the end of the Keyinputqueue.java, converts the multiple-point event type to a single point event type, returning a new inputdevice.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

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.