ViewRootImpl src track

ActivityThread.java:
private Activity performLaunchActivity(ActivityClientRecord r, Intent customIntent) {
...........................................................
activity.attach(appContext, this, getInstrumentation(), r.token,
                        r.ident, app, r.intent, r.activityInfo, title, r.parent,
                        r.embeddedID, r.lastNonConfigurationInstances, config);
...........................................................
}

Activity.java:(mWindow 由 Policy.java的makeNewWindow(Context context) 生成)
final void attach(Context context, ActivityThread aThread,
            Instrumentation instr, IBinder token, int ident,
            Application application, Intent intent, ActivityInfo info,
            CharSequence title, Activity parent, String id,
            NonConfigurationInstances lastNonConfigurationInstances,
            Configuration config) {
		...................................
	    mWindow.setWindowManager(
                (WindowManager)context.getSystemService(Context.WINDOW_SERVICE),
                mToken, mComponent.flattenToString(),
                (info.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0);
}



Window.java:
    /**
     * Set the window manager for use by this Window to, for example,
     * display panels.  This is <em>not</em> used for displaying the
     * Window itself -- that must be done by the client.
     *
     * @param wm The window manager for adding new windows.
     */
    public void setWindowManager(WindowManager wm, IBinder appToken, String appName,
            boolean hardwareAccelerated) {
	.......................................................................
        mWindowManager = ((WindowManagerImpl)wm).createLocalWindowManager(this);
    }

WindowManagerImpl.java:
private final WindowManagerGlobal mGlobal = WindowManagerGlobal.getInstance();

WindowManagerGlobal:

    public void addView(View view, ViewGroup.LayoutParams params,
            Display display, Window parentWindow) {
..............................................
root = new ViewRootImpl(view.getContext(), display);
..............................................
root.setView(view, wparams, panelParentView);
..............................................
}

这个加入到ViewRootImpl中的view是:
PhoneWindow中的
private void openPanel(final PanelFeatureState st, KeyEvent event) {
.........................................................
	final WindowManager wm = getWindowManager();
.........................................................
wm.addView(st.decorView, lp);
.........................................................

}

ViewRootImpl.java:
public ViewRootImpl(Context context, Display display) {
...................................................
mAttachInfo = new View.AttachInfo(mWindowSession, mWindow, display, this, mHandler, this);
...................................................
}

ViewRootImpl.Java
private void performTraversals() {
final View host = mView;
..............................................
只有在mFirst时才进行:
mFirst在ViewRootImpl时是true,
在performTraversals()一次以后就变成了false.
host.dispatchAttachedToWindow(attachInfo, 0);
.............................................
}

ViewGroup.java:
void dispatchAttachedToWindow(AttachInfo info, int visibility) {
......................................
	for (int i = 0; i < count; i++) {
            final View child = children[i];
            child.dispatchAttachedToWindow(info,
                    visibility | (child.mViewFlags & VISIBILITY_MASK));
        }
}

View.java:
void dispatchAttachedToWindow(AttachInfo info, int visibility) {
mAttachInfo = info;
.............
onAttachedToWindow();
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值