[-> InputDispatcher.cpp]
bool InputDispatcherThread::threadLoop() {
mDispatcher->dispatchOnce();
return true;
}
//将NotifyKeyArgs封装的事件信息解析出来,构造两个结构体KeyEvent和KeyEntry,为什么是两个?因为KeyEvent是会首先传递到java层的PhoneWindowManager中去判断是否将此事件加入分发队列
InputDispatcher::notifyKey
// 构建KeyEvent event;
event.initialize...
mPolicy->interceptKeyBeforeQueueing(&event, policyFlags);//mPolicy指向NativeInputManager,这个函数最终会通过JNI调到java层PhoneWindowManager
(1)AccessibilityService辅助服务拦截注入Input事件 IMS:AccessibilityService辅助服务拦截注入Input事件_accessibility inputfilter-优快云博客
shouldSendKeyToInputFilterLocked?
mPolicy->filterInputEvent(&event, policyFlags)
AccessibilityManagerService-> mInputFilter.sendInputEvent
-> InputFilter::sendInputEvent
-> mHost.sendInputEvent
-> InputFilterHost.sendInputEvent

本文详细解析了Android系统中InputDispatcher线程如何处理并分发Keyevent,从InputDispatcherThread的threadLoop开始,经过notifyKey、interceptKeyBeforeQueueing、filterInputEvent等步骤,直到事件传递到目标窗口进行实际的分发处理,涉及到 AccessibilityService 拦截、焦点窗口判断等多个关键环节。
最低0.47元/天 解锁文章
923

被折叠的 条评论
为什么被折叠?



