"Android Learning" Android device for touch event monitoring, cross-process event injection

Source: Internet
Author: User

Recently want to implement the touch screen event recording, and make timestamp tag, similar to the getevent/setevent under the ADB shell, looked up a lot of information, the following is some summary.

Implementation method:

1, using the OnClick method and so on. This method can only be used in your own activity and view, if you want to detect other activity, such as the keyboard is not.

2. Start with the Linux kernel. Intercepts events prior to event distribution, enabling event capture for any activity.


The process of Android touch event:

http://blog.csdn.net/sunnyfans/article/details/8221505

In the Linux kernel, the event is written directly to/dev/input/event*, and then another thread continuously flushes the event. Therefore, to realize the monitoring and injection, is to achieve the/dev/input/event* read and write.


Requirements:

1. ROOT

2. Get SU (Super user privileges)


Analyze event:

To clarify the meaning of each event representative, we use the getevent under the ADB shell to illustrate


From the top down you can see EVENT6 on behalf of Compass (Compass), Event3 for touch screen, below is the event7 (light sensing) event that is heard. The specific agreement can be see this article http://www.ddjava.com/blog/blog.html?blogId=612

This method can be used to monitor Android device events on the PC, but the disadvantage is to be connected to the computer. If it doesn't matter if the face is attached to the computer, you can end up with a script that handles the data http://www.jtben.com/document/919575


C4droid implementation:

C4droid is an app that compiles C/C + + on Android phones, and can operate directly on the underlying Linux kernel in the language of the.

http://tieba.baidu.com/p/2960331527#48299953890l


Java implementations:

Learning ... Live

Get Su, monitor dev/input/event*

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.