美文网首页
Android PhoneWindowManager拦截事件流程

Android PhoneWindowManager拦截事件流程

作者: 晴天12345 | 来源:发表于2017-09-23 14:15 被阅读125次
    PhoneWindowManager初始化
    wms::wms
        wms::initPolicy
            UiThread::Handler::runWithScissors
                PhoneWindowManager::init
    
    interceptKeyBeforeQueueing 调用栈
    InputDispatcher::injectInputEvent // 触发调用1
    InputDispatcher::notifyKey // 触发调用2
        com_android_server_input_InputManagerService::NativeInputManager::interceptKeyBeforeQueueing
            IMS::WindowManagerCallbacks::interceptKeyBeforeQueueing // InputMontor是WindowManagerCallbacks的实现类
                InputMontor::interceptKeyBeforeQueueing
                    WMS::PhoneWindowManager::interceptKeyBeforeQueueing
    
    interceptKeyBeforeDispatching调用栈
    InputDispatcher::dispatchOnce
        InputDispatcher::dispatchOnceInnerLocked(
            //InputDispatcher::mPolicy // mPolicy:: com_android_server_input_InputManagerService.cpp
            InputDispatcher::dispatchKeyLocked
                InputDispatcher::doInterceptKeyBeforeDispatchingLockedInterruptible
                    com_android_server_input_InputManagerService::NativeInputManager::interceptKeyBeforeDispatching
                    // jni InputManagerService::nativeInit中初始化
                        IMS::WindowManagerCallbacks::interceptKeyBeforeDispatching // InputMontor是WindowManagerCallbacks的实现类
                            InputMontor::interceptKeyBeforeDispatching
                                WMS::PhoneWindowManager::interceptKeyBeforeDispatching
    

    PhoneWindowManager 相关类图

    PhoneWindowManager.png
    1. InputMonitor 实现IMS::WindowManagerCallbacks接口,并且持有WMS引用;
    2. WMS持有WindowManagerPolicy接口的实现类PhoneWindowManager;
    3. PhoneWindowManager的内部类PolicyHandler分发业务逻辑;
    4. PhoneWindowManager的初始化在android.ui 线程;

    相关文章

      网友评论

          本文标题:Android PhoneWindowManager拦截事件流程

          本文链接:https://www.haomeiwen.com/subject/vvscextx.html