当前位置: 代码迷 >> Android >> Window 跟 WindowManagerService建立联系 google android源码
  详细解决方案

Window 跟 WindowManagerService建立联系 google android源码

热度:70   发布时间:2016-05-01 16:21:56.0
Window 和 WindowManagerService建立联系 google android源码
客户端访问服务端的Session。ViewRoot.java   
public static IWindowSession getWindowSession(Looper mainLooper) {        synchronized (mStaticInit) {            if (!mInitialized) {                try {                    InputMethodManager imm = InputMethodManager.getInstance(mainLooper);                    sWindowSession = IWindowManager.Stub.asInterface(                            ServiceManager.getService("window"))                            .openSession(imm.getClient(), imm.getInputContext());                    mInitialized = true;                } catch (RemoteException e) {                }            }            return sWindowSession;        }    }

客户端和服务端建立联系:setView
                requestLayout();                try {                    res = sWindowSession.add(mWindow, mWindowAttributes,                            getHostVisibility(), mAttachInfo.mContentInsets);                } catch (RemoteException e) {                    mAdded = false;                    mView = null;                    mAttachInfo.mRootView = null;                    unscheduleTraversals();                    throw new RuntimeException("Adding window failed", e);                } finally {                    if (restore) {                        attrs.restore();                    }                }
  相关解决方案