Better support for cleaning up the recents animation

With Life Tiles in QuickSteps (b/111697218), launcher will
“punch a hole” for TaskView & the app window will be transformed
in it & keep the task is running.

To prevent launcher animates on TaskView without the real app surface
during task switching, launcher start RecentsAnimation to monitor
onStackOrderChanged without cancel animation when swiping to recents.

We use this as signal to screenshot the previous app window when next
app transtion start, make leash with screenshot surface to let it below
homeAnimationLayer, so that launcher can still control the leash,
and then callback onAnimationCanceled with screenshot parameter for
launcher to know if need to call IRecentsAnimation#cleanupScreenshot for
clean up screenshot, to make the next app transtion animation can work
smoothly without flickering.

Bug: 122593881
Test: manual
Test: atest RecentsAnimationControllerTest RecentsAnimationTest
Change-Id: I83504d578a17856623a53c04a7d3c54e5bcab5f4
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index ea3a7d5..a4eedba 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -666,7 +666,7 @@
             }
         }
 
-        if (isReallyAnimating()) {
+        if (isSelfAnimating()) {
             delayed = true;
         } else {
 
@@ -2436,6 +2436,12 @@
                 getWindowingMode() == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
         final boolean allowSplitScreenPrimaryAnimation = transit != TRANSIT_WALLPAPER_OPEN;
 
+        // Don't animate when the task runs recents animation.
+        final RecentsAnimationController controller = mWmService.getRecentsAnimationController();
+        if (controller != null && controller.isAnimatingTask(getTask())) {
+            return false;
+        }
+
         // We animate always if it's not split screen primary, and only some special cases in split
         // screen primary because it causes issues with stack clipping when we run an un-minimize
         // animation at the same time.