读书人

Window 跟 WindowManagerService建立联

发布时间: 2012-09-14 11:53:44 作者: rapoo

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();                    }                }

读书人网 >Android

热点推荐