窗口管理器相关的几个线程:
=======
WindowManagerService 类的mian函数调用:
WMThread thr = new WMThread(context, pm, haveInputMethods)
创建窗口线程 WMThread 在线程 run中 实例化 WindowManagerService 类
WindowManagerService s = new WindowManagerService(mContext, mPM,mHaveInputMethods)
然后进入 Looper.loop();
=======
WindowManagerService构造函数里面有
mQueue = new KeyQ();
因为 KeyQ 继承 KeyInputQueue 而 KeyInputQueue 中有
Thread mThread = new Thread("InputDeviceReader")
在线程 InputDeviceReader 里面通过 readEvent(ev) 读取事件
readEvent本地调用 com_android_server_KeyInputQueue.cpp (frameworks\base\services\jni)中的函数
static jboolean android_server_KeyInputQueue_readEvent(JNIEnv* env, jobject clazz,jobject event)
=======
WindowManagerService构造函数里面有
PolicyThread thr = new PolicyThread(mPolicy, this, context, pm);
创建 PolicyThread 线程
=======
WindowManagerService构造函数里面有
mInputThread = new InputDispatcherThread();
mInputThread.start();
首先执行 run 函数,在里面循环调用 process()
在 process()里面对事件进行分发:
按键事件: dispatchKey((KeyEvent)ev.event, 0, 0);
触摸屏事件:dispatchPointer(ev, (MotionEvent)ev.event, 0, 0);
轨迹球事件:dispatchTrackball(ev, (MotionEvent)ev.event, 0, 0);
=======
private boolean dispatchKey(KeyEvent event, int pid, int uid)
Object focusObj = mKeyWaiter.waitForNextEventTarget(event, null,null, false, false)
Object waitForNextEventTarget(KeyEvent nextKey, QueuedEvent qev,MotionEvent nextMotion, boolean isPointerEvent,boolean failIfTimeout)
Object findTargetWindow(KeyEvent nextKey, QueuedEvent qev,MotionEvent nextMotion, boolean isPointerEvent)
阅读(875) | 评论(0) | 转发(0) |