Consolidate recent animation in split screen with shell-transition

Also exclude corresponding parent task when wrapping up remote animation
target for recents animation.

Bug: 206487881
Test: manual check recent animation after split screen activated
Change-Id: I2e80eca1124d9a9e360513334211bde8a52575ea
diff --git a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java
index 8e2b566..afb4d4d 100644
--- a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java
+++ b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java
@@ -27,6 +27,8 @@
 import com.android.quickstep.util.TransformParams;
 import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
 
+import java.util.ArrayList;
+
 /**
  * Glues together the necessary components to animate a remote target using a
  * {@link TaskViewSimulator}
@@ -144,20 +146,29 @@
      */
     private RemoteAnimationTargets createRemoteAnimationTargetsForTarget(
             RemoteAnimationTargets targets,
-            @Nullable RemoteAnimationTargetCompat targetToExclude) {
-        int finalLength = targets.unfilteredApps.length - (targetToExclude == null ? 0 : 1);
-        RemoteAnimationTargetCompat[] targetsWithoutExcluded =
-                new RemoteAnimationTargetCompat[finalLength];
-        int i = 0;
+            RemoteAnimationTargetCompat targetToExclude) {
+        ArrayList<RemoteAnimationTargetCompat> targetsWithoutExcluded =
+                new ArrayList<RemoteAnimationTargetCompat>();
+
         for (RemoteAnimationTargetCompat targetCompat : targets.unfilteredApps) {
             if (targetCompat == targetToExclude) {
                 continue;
             }
-            targetsWithoutExcluded[i] = targetCompat;
-            i++;
+            if (targetToExclude != null
+                    && targetToExclude.taskInfo != null
+                    && targetCompat.taskInfo != null
+                    && targetToExclude.taskInfo.parentTaskId == targetCompat.taskInfo.taskId) {
+                // Also exclude corresponding parent task
+                continue;
+            }
+
+            targetsWithoutExcluded.add(targetCompat);
         }
-        return new RemoteAnimationTargets(targetsWithoutExcluded,
-                targets.wallpapers, targets.nonApps, targets.targetMode);
+        final RemoteAnimationTargetCompat[] filteredApps =
+                targetsWithoutExcluded.toArray(
+                        new RemoteAnimationTargetCompat[targetsWithoutExcluded.size()]);
+        return new RemoteAnimationTargets(
+                filteredApps, targets.wallpapers, targets.nonApps, targets.targetMode);
     }
 
     public RemoteTargetHandle[] getRemoteTargetHandles() {