10.10 Android input System _app get and process input event flow

Source: Internet
Author: User

App's registration process for Fd/inputchannel:

The Dispatchinputevent function of the new Windowinputeventreceiver extends Inputeventreceiver//inputeventreceiver class calls Oninputevent

The Oninputevent function is called after the event is received//called by the dispatchinputevent of the parent class

Call Nativeinit in the constructor of Inputeventreceiver

nativeinit//from Java into C + +

New Nativeinputeventreceiver

consumeevents//calls the Java layer's function dispatchinputevent

Dispatchinputevent

Finally, we'll add FD to the Epoll to monitor

App gets and handles input event flow

Pollonce

Polinner

epoll_wait//waiting for events to happen

Pushresponse (Events,mrequests.valueat (REQUESTINDEX)) constructs response into a buffer

response& Response = Mresponses.edititemat (i)//Remove from buffer Response

int callbackresult = response.request.callback->handleevent (fd,events,data)

Consumeevents (Env,false,-1,null)

Minputconsumer.consume (..., &seq,&inputevent)

Mchannel->receivemessage (&MMSG)

Nread =:: Recv (Mfd,msg,sizeof (inputmessage), msg_dontwait)

Initializekeyevent (KEYEVENT,&MMSG)

*outseq = MMsg.body.key.seq

*outevent = KeyEvent

Inputeventobj = Android_view_keyevent_fromnative (env,static_cast<keyevent*> (inputEvent))

Env->callvoidmethod (Receiverobj.get (), ginputeventreceivrrclassinfo.dispatchinputevent,seq,inputeventobj)

Oninputevent (Event)

Enqueueinputevent (Event,this,0,true)

Mpendinginputeventtail =q

doprocessinputevents//handles a multitude of input events

queueinputevent q = mpendinginputeventhead;

Mpendinginputeventhead = Q.mnext

Deliverinputevent (q)

stage = Q.shouldskipime ()? mfirstpostimeinputstage:mfirstinputstage;//if the application uses an input method, start processing from mfirstinputstage if the input method is not used , start processing from mfirstpostimeinputstage.

Stage.deliver (q)

The analysis of Inputstage stage

If your application uses input methods, start processing from mfirstinputstage, and if you do not use an IME, start processing from mfirstpostimeinputstage

  

10.10 Android input System _app get and process input event flow

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.