diff options
| author | 2023-04-05 18:22:38 +0000 | |
|---|---|---|
| committer | 2023-04-05 18:22:38 +0000 | |
| commit | 6e8eaf2858a08cfb363d2fed9cb1c12f7762d86f (patch) | |
| tree | 32f4559cf40da65fcf57977da0339c763d18251c | |
| parent | bb76d1e9392019136588e4707e4f952c0fd60d53 (diff) | |
| parent | b6a8aa222951ba1afebece37ae265404f8db7309 (diff) | |
Merge "Always detach transition-created surfaces on finish" into udc-dev
| -rw-r--r-- | services/core/java/com/android/server/wm/Transition.java | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index 0fe1f923e4e5..1fb353476592 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -33,8 +33,6 @@ import static android.view.WindowManager.TRANSIT_CHANGE; import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_FLAG_IS_RECENTS; import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_LOCKED; -import static android.view.WindowManager.TRANSIT_KEYGUARD_OCCLUDE; -import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE; import static android.view.WindowManager.TRANSIT_OPEN; import static android.view.WindowManager.TRANSIT_TO_BACK; import static android.view.WindowManager.TRANSIT_TO_FRONT; @@ -167,6 +165,9 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { private SurfaceControl.Transaction mStartTransaction = null; private SurfaceControl.Transaction mFinishTransaction = null; + /** Used for failsafe clean-up to prevent leaks due to misbehaving player impls. */ + private SurfaceControl.Transaction mCleanupTransaction = null; + /** * Contains change infos for both participants and all remote-animatable ancestors. The * ancestors can be the promotion candidates so their start-states need to be captured. @@ -787,6 +788,24 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { } /** + * Build a transaction that cleans-up transition-only surfaces (transition root and snapshots). + * This will ALWAYS be applied on transition finish just in-case + */ + private static void buildCleanupTransaction(SurfaceControl.Transaction t, TransitionInfo info) { + for (int i = info.getChanges().size() - 1; i >= 0; --i) { + final TransitionInfo.Change c = info.getChanges().get(i); + if (c.getSnapshot() != null) { + t.reparent(c.getSnapshot(), null); + } + } + for (int i = info.getRootCount() - 1; i >= 0; --i) { + final SurfaceControl leash = info.getRoot(i).getLeash(); + if (leash == null) continue; + t.reparent(leash, null); + } + } + + /** * Set whether this transition can start a pip-enter transition when finished. This is usually * true, but gets set to false when recents decides that it wants to finish its animation but * not actually finish its animation (yeah...). @@ -863,6 +882,10 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { if (mStartTransaction != null) mStartTransaction.close(); if (mFinishTransaction != null) mFinishTransaction.close(); mStartTransaction = mFinishTransaction = null; + if (mCleanupTransaction != null) { + mCleanupTransaction.apply(); + mCleanupTransaction = null; + } if (mState < STATE_PLAYING) { throw new IllegalStateException("Can't finish a non-playing transition " + mSyncId); } @@ -1286,6 +1309,8 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { } } buildFinishTransaction(mFinishTransaction, info); + mCleanupTransaction = mController.mAtm.mWindowManager.mTransactionFactory.get(); + buildCleanupTransaction(mCleanupTransaction, info); if (mController.getTransitionPlayer() != null && mIsPlayerEnabled) { mController.dispatchLegacyAppTransitionStarting(info, mStatusBarTransitionDelay); try { @@ -1385,6 +1410,10 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { ci.mSnapshot.release(); } } + if (mCleanupTransaction != null) { + mCleanupTransaction.apply(); + mCleanupTransaction = null; + } } /** The transition is ready to play. Make the start transaction show the surfaces. */ |