Merge "Set SurfaceTransactionApplier on non-stale RemoteAnimationTargets" into sc-v2-dev am: 0ff2ad6ff4

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15956593

Change-Id: Ifc5c08374ce590e7c417be6355ae1abdfc36796b
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 74c8e39..77676a1 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -4237,13 +4237,19 @@
             return;
         }
 
-        if (mSyncTransactionApplier != null) {
-            recentsAnimationTargets.addReleaseCheck(mSyncTransactionApplier);
-        }
-
         RemoteTargetGluer gluer = new RemoteTargetGluer(getContext(), getSizeStrategy());
         mRemoteTargetHandles = gluer.assignTargetsForSplitScreen(recentsAnimationTargets);
         mSplitBoundsConfig = gluer.getStagedSplitBounds();
+        if (mSyncTransactionApplier != null) {
+            // Add release check to the targets from the RemoteTargetGluer and not the targets
+            // passed in because in the event we're in split screen, we use the passed in targets
+            // to create new RemoteAnimationTargets in assignTargetsForSplitScreen(), and the
+            // mSyncTransactionApplier doesn't get transferred over
+            runActionOnRemoteHandles(remoteTargetHandle -> remoteTargetHandle
+                    .getTransformParams().getTargetSet()
+                    .addReleaseCheck(mSyncTransactionApplier));
+        }
+
         TaskView runningTaskView = getRunningTaskView();
         if (runningTaskView instanceof GroupedTaskView) {
             // We initially create a GroupedTaskView in showCurrentTask() before launcher even