大鹏一日同风起,扶摇直上九万里。这篇文章主要讲述10.10 android输入系统_APP获得并处理输入事件流程相关的知识,希望能为你提供帮助。
APP对fd/InputChannel的注册过程:
new WindowInputEventReceiver extends
InputEventReceiver//InputEventReceiver类的dispatchInputEvent函数会调用onInputEvent
onInputEvent函数在收到事件后被调用//被父类的dispatchInputEvent调用
在InputEventReceiver的构造函数中调用nativeInit
nativeInit//从java进入C++
new NativeInputEventReceiver
consumeEvents//调用Java层的函数dispatchInputEvent
dispatchInputEvent
最后会把fd加入epoll去监控
APP获得并处理输入事件流程
pollOnce
polInner
epoll_wait//等待各种事件的发生
pushResponse(events,mRequests.valueAt(requestIndex))构造response放入某个缓冲区
Response&
response = mResponses.editItemAt(i)//从缓冲取出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))
【10.10 android输入系统_APP获得并处理输入事件流程】env->
CallVoidMethod(receiverObj.get(),gInputEventReceivrrClassInfo.dispatchInputEvent,seq,inputEventObj)
onInputEvent(event)
enqueueInputEvent(event,this,0,true)
mPendingInputEventTail =q
doProcessInputEvents//处理众多的输入事件
QueueInputEvent q = mPendingInputEventHead;
mPendingInputEventHead = q.mNext
deliverInputEvent(q)
stage = q.shouldSkipIme()?mFirstPostImeInputStage:mFirstInputStage;
//如果应用程序使用输入法,就从mFirstInputStage开始处理,如果不使用输入法,就从mFirstPostImeInputStage开始处理
stage.deliver(q)
InputStage stage的分析见下图
如果应用程序使用输入法,就从mFirstInputStage开始处理,如果不使用输入法,就从mFirstPostImeInputStage开始处理
文章图片
推荐阅读
- Ambiguous mapping found. Cannot map 'competeController' bean method
- app前端代码打包步骤
- Android中Application向Activity 传递数值
- PrimeFaces ColorPicker组件用法
- PrimeFaces标签chip
- PrimeFaces Ajax监听器示例
- PrimeFaces面包屑导航用法
- PrimeFaces SelectBooleanCheckbox实例
- PrimeFaces SelectBooleanButton示例