publicvoidhandleResumeActivity(IBinder token, boolean finalStateRequest, boolean isForward, String reason){ // 调用 activity#onResume final ActivityClientRecord r = performResumeActivity(token, finalStateRequest, reason); ...
final Activity a = r.activity; finalint forwardBit = isForward ? WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION : 0;
// If the window hasn't yet been added to the window manager, // and this guy didn't finish itself or start another activity, // then go ahead and add the window. boolean willBeVisible = !a.mStartedActivity; if (!willBeVisible) { try { willBeVisible = ActivityTaskManager.getService().willActivityBeVisible( a.getActivityToken()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } if (r.window == null && !a.mFinished && willBeVisible) { r.window = r.activity.getWindow(); View decor = r.window.getDecorView(); decor.setVisibility(View.INVISIBLE); ViewManager wm = a.getWindowManager(); WindowManager.LayoutParams l = r.window.getAttributes(); a.mDecor = decor; ... if (a.mVisibleFromClient) { if (!a.mWindowAdded) { a.mWindowAdded = true; wm.addView(decor, l); // 主流程下一步 } else { a.onWindowAttributesChanged(l); } } } elseif (!willBeVisible) { r.hideForNow = true; } ...
// The window is now visible if it has been added, we are not // simply finishing, and we are not starting another activity. if (!r.activity.mFinished && willBeVisible && r.activity.mDecor != null && !r.hideForNow) { ViewRootImpl impl = r.window.getDecorView().getViewRootImpl(); WindowManager.LayoutParams l = impl != null ? impl.mWindowAttributes : r.window.getAttributes(); ... r.activity.mVisibleFromServer = true; mNumVisibleActivities++; if (r.activity.mVisibleFromClient) { r.activity.makeVisible(); } } Looper.myQueue().addIdleHandler(new Idler()); }
synchronized (mLock) { int index = findViewLocked(view, false); if (index >= 0) { if (mDyingViews.contains(view)) { mRoots.get(index).doDie(); } else { throw } // The previous removeView() had not completed executing. Now it has. }
root = new ViewRootImpl(view.getContext(), display);
publicfinalclassViewRootImplimplementsViewParent, View.AttachInfo.Callbacks, ThreadedRenderer.DrawCallbacks{ final ViewRootHandler mHandler = new ViewRootHandler();