InputDispatcher线程跑在什么进程?
跑在System_server
![](https://img.haomeiwen.com/i3858093/27e5ed835ebaf9bc.png)
InputDispatcher线程是在哪里启动的?
在 /frameworks/native/services/inputflinger/InputManager.cpp
status_t InputManager::start() {
status_t result = mDispatcherThread->run("InputDispatcher", PRIORITY_URGENT_DISPLAY);
if (result) {
ALOGE("Could not start InputDispatcher thread due to error %d.", result);
return result;
}
result = mReaderThread->run("InputReader", PRIORITY_URGENT_DISPLAY);
if (result) {
ALOGE("Could not start InputReader thread due to error %d.", result);
mDispatcherThread->requestExit();
return result;
}
return OK;
}
InputDispatcher线程入口在做什么?
bool InputDispatcherThread::threadLoop() {
mDispatcher->dispatchOnce();
return true;
}
其中mDispatcher的初始化
mDispatcher = new InputDispatcher(dispatcherPolicy);
线程在哪里睡眠?
在mLooper->pollOnce(timeoutMillis)中
![](https://img.haomeiwen.com/i3858093/3af33d1097cdba1b.png)
java层和native层通过什么联系在一起?
通过inputWindowHandle联系。
/frameworks/base/services/core/java/com/android/server/input/InputManagerService.java
public void registerInputChannel(InputChannel inputChannel,
InputWindowHandle inputWindowHandle) {
if (inputChannel == null) {
throw new IllegalArgumentException("inputChannel must not be null.");
}
nativeRegisterInputChannel(mPtr, inputChannel, inputWindowHandle, false);
}
在wms添加窗口的时候,创建了这个input的通道
public int addWindow(Session session, IWindow client, int seq,
WindowManager.LayoutParams attrs, int viewVisibility, int displayId,
Rect outContentInsets, Rect outStableInsets, Rect outOutsets,
InputChannel outInputChannel) {
................
win.openInputChannel(outInputChannel);
................
}
网友评论