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