Fix thumbnail header animations in freeform to recents.

The thumbnail header animations were constructed based on opening apps,
in this case Recents. This is obviously wrong, but used to work because
there was only one closing app in non-multi window world.

For the animation to work correctly, i.e. each thumbnail have its own
header animation, we need to correctly construct animations for either
opening apps or closing apps (depending on the transition type we are
seeing).

The CL also refactors handleAppTransition into smaller methods.

Bug: 24913782
Change-Id: I9f30a53d2f90f0628bb8c6238b2d0f35592b8f63
diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java
index a3c841b..a7a4ed1 100644
--- a/services/core/java/com/android/server/wm/AppTransition.java
+++ b/services/core/java/com/android/server/wm/AppTransition.java
@@ -74,6 +74,7 @@
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -309,6 +310,16 @@
         return mNextAppTransitionScaleUp;
     }
 
+    boolean isNextAppTransitionThumbnailUp() {
+        return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_UP ||
+                mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP;
+    }
+
+    boolean isNextAppTransitionThumbnailDown() {
+        return mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_SCALE_DOWN ||
+                mNextAppTransitionType == NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
+    }
+
     /**
      * @return true if and only if we are currently fetching app transition specs from the future
      *         passed into {@link #overridePendingAppTransitionMultiThumbFuture}