回去window属性
WindowManager.LayoutParams l = r.window.getAttributes();
Decor 为PhoneWindow.DecorView 这个View其实是一个Activity 的最底层View
wm.addView(decor, l);
调用PhoneWindow的LocalWindowManager 中的addView
public final void addView(View view, ViewGroup.LayoutParams params) {
// Let this throw an exception on a bad params.
WindowManager.LayoutParams wp = (WindowManager.LayoutParams)params;
CharSequence curTitle = wp.getTitle();
if (wp.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW &&
wp.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) {
if (wp.token == null) {
View decor = peekDecorView();
if (decor != null) {
wp.token = decor.getWindowToken();
}
}
if (curTitle == null || curTitle.length() == 0) {
String title;
if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA) {
title="Media";
} else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY) {
title="MediaOvr";
} else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_PANEL) {
title="Panel";
} else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL) {
title="SubPanel";
} else if (wp.type == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG) {
title="AtchDlg";
} else {
title=Integer.toString(wp.type);
}
if (mAppName != null) {
title += ":" + mAppName;
}
wp.setTitle(title);
}
} else {
if (wp.token == null) {
wp.token = mContainer == null ? mAppToken : mContainer.mAppToken;
}
if ((curTitle == null || curTitle.length() == 0)
&& mAppName != null) {
wp.setTitle(mAppName);
}
}
if (wp.packageName == null) {
wp.packageName = mContext.getPackageName();
}
mWindowManager.addView(view, params);
}
调用 WindowManagerImpl 的addView
进一步调用如下方法:
final WindowManager.LayoutParams wparams
= (WindowManager.LayoutParams)params;
root.setView(view, wparams, panelParentView);
ViewRoot里面也有一个Window Attribute变量mWindowAttributes ---Window
attrs 为Window的Attribute mWindowAttributes.copyFrom(attrs);--ViewRoot
这是两个不同的对象,有时间内容相同。 具体看代码。