/** * 代码位于:frameworks/base/core/java/android/view/Surface.java * Create an empty surface, which will later be filled in by readFromParcel(). * @hide */ @UnsupportedAppUsage publicSurface() { }
/** * 代码位于:frameworks/base/core/java/android/view/Surface.java * * @param from The SurfaceControl to associate this Surface with */ publicSurface(@NonNull SurfaceControl from) { copyFrom(from); }
/** * 代码位于:frameworks/base/core/java/android/view/Surface.java */ publicSurface(SurfaceTexture surfaceTexture) { if (surfaceTexture == null) { thrownewIllegalArgumentException("surfaceTexture must not be null"); } mIsSingleBuffered = surfaceTexture.isSingleBuffered(); synchronized (mLock) { mName = surfaceTexture.toString(); setNativeObjectLocked(nativeCreateFromSurfaceTexture(surfaceTexture)); } }
@Override publicvoidhandleResumeActivity(ActivityClientRecord r, boolean finalStateRequest, boolean isForward, String reason) { // If we are getting ready to gc after going to the background, well // we are back active so skip it. unscheduleGcIdler(); mSomeActivitiesChanged = true;
// TODO Push resumeArgs into the activity for consideration // skip below steps for double-resume and r.mFinish = true case. // 此处会触发 onResume 声明周期回调 if (!performResumeActivity(r, finalStateRequest, reason)) { return; } if (mActivitiesToBeDestroyed.containsKey(r.token)) { // Although the activity is resumed, it is going to be destroyed. So the following // UI operations are unnecessary and also prevents exception because its token may // be gone that window manager cannot recognize it. All necessary cleanup actions // performed below will be done while handling destruction. return; } // 获取需要Resume的Activity finalActivitya= r.activity;
if (localLOGV) { Slog.v(TAG, "Resume " + r + " started activity: " + a.mStartedActivity + ", hideForNow: " + r.hideForNow + ", finished: " + a.mFinished); }
WindowManager.LayoutParamsl= r.window.getAttributes(); a.mDecor = decor; l.type = WindowManager.LayoutParams.TYPE_BASE_APPLICATION; l.softInputMode |= forwardBit; // ...... if (a.mVisibleFromClient) { if (!a.mWindowAdded) { a.mWindowAdded = true; // 往WindowManager里面添加decorView wm.addView(decor, l); } else { // The activity will get a callback for this {@link LayoutParams} change // earlier. However, at that time the decor will not be set (this is set // in this method), so no action will be taken. This call ensures the // callback occurs with the decor set. a.onWindowAttributesChanged(l); } }
// If the window has already been added, but during resume // we started another activity, then don't yet make the // window visible. } elseif (!willBeVisible) { if (localLOGV) Slog.v(TAG, "Launch " + r + " mStartedActivity set"); r.hideForNow = true; }
// Get rid of anything left hanging around. cleanUpPendingRemoveWindows(r, false/* force */); // ......
r.nextIdle = mNewActivities; mNewActivities = r; if (localLOGV) Slog.v(TAG, "Scheduling idle handler for " + r); Looper.myQueue().addIdleHandler(newIdler()); }