Main Process of Android input event Transfer

Source: Internet
Author: User
Tags call back

1. windowmanagerservice

Frameworks/base/services/Java/COM/Android/Server/windowmanagerservice. Java

Dependent on inputmanager minputmanager;
Generated during initialization and started with minputmanager. Start ()

 

2. inputmanager

Frameworks/base/services/Java/COM/Android/Server/inputmanager. Java

A. New inputmanager ()

---> Nativeinit (mcallbak) // initializes inputmanager and registers the callback function for the input event.

---> Android_server_inputmanager_nativeinit () // frameworks/base/services/JNI/com_android_server_inputmanager.cpp

---> Nativeinputmanager () // frameworks/base/services/JNI/com_android_server_inputmanager.cpp

---> Inputmanager () // frameworks/base/libs/UI/inputmanager. cpp

----> Initialize dispatcherthread and readerthread.

Mreaderthread = new inputreaderthread (mreader); // inputreader loop eventhub
Mdispatcherthread = new inputdispatcherthread (mdispatcher );

 

B. inputmanager. Start ()

---> Android_server_inputmanager_nativestart // frameworks/base/services/JNI/com_android_server_inputmanager.cpp

--> Start dispatcherthread and readerthread.

 

3. inputreader // gets an event

Frameworks/base/libs/UI/inputreader. cpp

Inputreader: looponce ()

---> Eventhub. getevent ()

 

4. inputmanager. Java's mcallbacks // callback handler for input events inputmanager. Callbacks internal class

Inputdispatcher: notifykey callback nativeinputmanager method and callback inputmanager. Java mcallbacks through JNI for event processing

For example, inputdispatcher: policykey ----> inputmanager. callbacksinterceptkeybeforequeueing ()

// Frameworks/base/services/JNI/com_android_server_inputmanager.cpp

 

5. inputmanager. Callbacks internal class

A. Call back the windowmanagerservice. inputmonitor class method of windowmanagerservice to process events.

B. inputmonitor calls the mpolicy member of windowmanagerservice.

C. mpolicy is the object of windowmanagerpolicy. It is actually the phonewindowmanager created by com. Android. Internal. Policy. impl. Policy.

// Phonewindowmanager. Java

 

6. phonewindowmanager. Java

A. interceptkeybeforedispatching () Home event Interception

B. interceptkeybeforequeueing () Power

 

7. inputreader. cpp

Inputreader: Process ()

---> Inputreader: consumeevent ()

---> Inputdevice: Process ()

---> Keyboardinputmapper: Process () // or trackballinputmapper: Process () or touchinputmapper: Process ()
           --->KeyboardInputMapper::processKey()
              ----> InputDispatcher::notifyKey()
---> Windowmanagerpolicy: interceptkeybeforequeueing () // corresponds to the event processing in the early stage of table 6.
                     InputDispatcher::enqueueInboundEventLocked()
---> Minboundqueue. enqueueattail (entry); // Add the key event to the inputdispatcher message queue.
If the queue is empty, wake up the inputdispatcherthread process.
 
8. InputDispatcherThread
-->InputDispatcher::dispatchOnce()    
   --> InputDispatcher::dispatchOnceInnerLocked()
      --> InputDispatcher::dispatchKeyLocked()
        --> InputDispatcher::findFocusedWindowTargetsLocked()
            InputDispatcher::dispatchEventToCurrentInputTargetsLocked()
             --> InputDispatcher::prepareDispatchCycleLocked()
                 -->InputDispatcher::startDispatchCycleLocked()
                    --> InputPublisher::publishKeyEvent()      
                        --> NativeInputQueue::handleReceiveCallback
--> The dispatchkeyevent () method of inputqueue at the Java Layer
--> Dispatchkeyevent () method of viewroot

Refer:

Http://blog.csdn.net/yuleslie/article/details/7079448

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.