diff options
| author | 2020-06-05 00:05:03 +0000 | |
|---|---|---|
| committer | 2020-06-05 00:05:03 +0000 | |
| commit | 5b72ddd8edfba95e97508dd00c848794a85d5ef4 (patch) | |
| tree | 1184086d74aa724eacd052dd31cfe03de3f2eeb2 | |
| parent | bb9ea4e1fa38a9448589b4521aff06ec05ad1567 (diff) | |
| parent | 9118c9b573a743a1526beb7a0de48174ee561af2 (diff) | |
Merge "Call preserveSurfaces when detaching children." into rvc-dev
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowStateAnimator.java | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index 42c21930bdf7..c0252363a159 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -418,25 +418,25 @@ class WindowStateAnimator { if (!mDestroyPreservedSurfaceUponRedraw) { return; } - if (mSurfaceController != null) { - if (mPendingDestroySurface != null) { - // If we are preserving a surface but we aren't relaunching that means - // we are just doing an in-place switch. In that case any SurfaceFlinger side - // child layers need to be reparented to the new surface to make this - // transparent to the app. - if (mWin.mActivityRecord == null || mWin.mActivityRecord.isRelaunching() == false) { - mPostDrawTransaction.reparentChildren( - mPendingDestroySurface.getClientViewRootSurface(), - mSurfaceController.mSurfaceControl).apply(); - } - } + + // If we are preserving a surface but we aren't relaunching that means + // we are just doing an in-place switch. In that case any SurfaceFlinger side + // child layers need to be reparented to the new surface to make this + // transparent to the app. + // If the children are detached, we don't want to reparent them to the new surface. + // Instead let the children get removed when the old surface is deleted. + if (mSurfaceController != null && mPendingDestroySurface != null && !mChildrenDetached + && (mWin.mActivityRecord == null || !mWin.mActivityRecord.isRelaunching())) { + mPostDrawTransaction.reparentChildren( + mPendingDestroySurface.getClientViewRootSurface(), + mSurfaceController.mSurfaceControl).apply(); } destroyDeferredSurfaceLocked(); mDestroyPreservedSurfaceUponRedraw = false; } - void markPreservedSurfaceForDestroy() { + private void markPreservedSurfaceForDestroy() { if (mDestroyPreservedSurfaceUponRedraw && !mService.mDestroyPreservedSurface.contains(mWin)) { mService.mDestroyPreservedSurface.add(mWin); @@ -1363,9 +1363,13 @@ class WindowStateAnimator { if (mPendingDestroySurface != null && mDestroyPreservedSurfaceUponRedraw) { final SurfaceControl pendingSurfaceControl = mPendingDestroySurface.mSurfaceControl; mPostDrawTransaction.reparent(pendingSurfaceControl, null); - mPostDrawTransaction.reparentChildren( - mPendingDestroySurface.getClientViewRootSurface(), - mSurfaceController.mSurfaceControl); + // If the children are detached, we don't want to reparent them to the new surface. + // Instead let the children get removed when the old surface is deleted. + if (!mChildrenDetached) { + mPostDrawTransaction.reparentChildren( + mPendingDestroySurface.getClientViewRootSurface(), + mSurfaceController.mSurfaceControl); + } } SurfaceControl.mergeToGlobalTransaction(mPostDrawTransaction); @@ -1593,6 +1597,12 @@ class WindowStateAnimator { mSurfaceController.detachChildren(); } mChildrenDetached = true; + // If the children are detached, it means the app is exiting. We don't want to tear the + // content down too early, otherwise we could end up with a flicker. By preserving the + // current surface, we ensure the content remains on screen until the window is completely + // removed. It also ensures that the old surface is cleaned up when started again since it + // forces mSurfaceController to be set to null. + preserveSurfaceLocked(); } void setOffsetPositionForStackResize(boolean offsetPositionForStackResize) { |