WindowManager.java抽象类,具体实现靠WindowManagerImpl
WindowManagerImpl.java委托windmanagerGlobal干活
WindowManagerGlobal.java真正完成windowmanager任务
ViewRootImpl.java
PhoneWindow.java这个才是我们看到的window
PhoneWindowManager.java
以上类全部在客户端中使用.
IWindowSession:
IWindowSession 在客户端中使用,他是window在客户端持有windowManagerService的类似于应用的东西,客户端通过IWindowSession向WMS发送请求.
IWindowSession 在viewRootImpl构造函数中初始化:
final IWindowSession mWindowSession;
public ViewRootImpl(Context context, Display display) {
mWindowSession = WindowManagerGlobal.getWindowSession();
}
public static IWindowSession getWindowSession() {
synchronized (WindowManagerGlobal.class) {
if (sWindowSession == null) {
try {
InputMethodManager imm = InputMethodManager.getInstance();
IWindowManager windowManager = getWindowManagerService();
sWindowSession = windowManager.openSession(
new IWindowSessionCallback.Stub() {
@Override
public void onAnimatorScaleChanged(float scale) {
ValueAnimator.setDurationScale(scale);
}
},
imm.getClient(), imm.getInputContext());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
return sWindowSession;
}
}
可以看到这里是一个binder调用,最终调用到了WMS:
public IWindowSession openSession(IWindowSessionCallback callback, IInputMethodClient client,
IInputContext inputContext) {
if (client == null) throw new IllegalArgumentException("null client");
if (inputContext == null) throw new IllegalArgumentException("null inputContext");
Session session = new Session(this, callback, client, inputContext);
return session;
}
这个session就是被用来与WMS通讯使用:
public void setView(View view, WindowManager.LayoutParams attrs, View panelParentView) {
collectViewAttributes();
res = mWindowSession.addToDisplay(mWindow, mSeq, mWindowAttributes,
getHostVisibility(), mDisplay.getDisplayId(), mWinFrame,
mAttachInfo.mContentInsets, mAttachInfo.mStableInsets,
mAttachInfo.mOutsets, mAttachInfo.mDisplayCutout, mInputChannel);
}