Android input event reporting Overview (1)

Source: Internet
Author: User
Android input event reporting Overview

How does Android obtain input events? How to dispatch input events to the corresponding window?

1. Android input Design Philosophy

The driver listens to the input events of users on different devices and outputs the events to files. Android listens to these files to learn about event reporting and then sends the event to the corresponding view. The following are the event output files in the mobile phone system. Each file represents one or more event types.

add device 1: /dev/input/event0  name:     "lsm303dlhc_acc" add device 2: /dev/input/event1  name:     "lsm303dlhc_mag" add device 3: /dev/input/event5  name:     "7k_handset"    add device 4: /dev/input/event4  name:     "7x27a_kp"    add device 5: /dev/input/event3  name:     "ft5x0x_ts"    add device 6: /dev/input/event2  name:     "tmd2771x"  

Lsm303dlhc_acc:Msensor

Lsm303dlhc_mag:Gsensor

7k_handset:Earphone plugging event

7x27a_kp:Keypad is mainly used for physical key events, Volume addition and subtraction keys, etc.

Ft5x0x_ts:TP, including virtual buttons and screen touch events

Tmd2771x:Psensor and lsensor

2. Function Analysis

When the corresponding device driver detects an event change, the corresponding event is written to the above file. When Android detects a change in these files, it reads the current event and distributes the event.

Android framework has two threads that are responsible for reading and distributing data. They are started During WMS initialization and run continuously. inputreaderthread is responsible for reading events in device files, the inputdispatcherthread is responsible for dispatching the obtained events.

Dispatch events. Keys are pre-processed in WMS before they are distributed to the corresponding window. Touch events are directly distributed to the corresponding window, how is Android distributed to the customer window? In Android 2.3 and later versions, pipelines are used. In earlier versions, binder communication is used. The customer window registers the MPs queue in advance, reads the events in the MPs queue by the customer process, and distributes the events within the MPs queue.

3. Summary The processing of each piece of Android will be parsed separately in the subsequent articles.
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.