Fix NPE crash when merge transition to remote transition.

After enable shell transition, the opening/closing target is for the
app.
In legacy RecentsAnimationController, the mode of the new
RemoteAnimationTarget is decide based on the recents activity type, so
basically the mode for all non-home/recents activity is closing.
So while create the recents window animator, the target apps will be
filter out in RemoteAnimationTargets#ctor because the mode is changed.
To make the remote animation targets compatible with shell transition,
there should only need to check the opening apps as target.

Also fix that the topMostSimulators can be null if the size of
remoteTargetHandles is zero.

Bug: 207297486
Test: Enable shell transition, run
atest TaplTestsQuickstep#testQuickSwitchFromApp
Test: Enable shell transition, enter recents, swipe to right-most page(
the page shows "Clear all"), then click the task and verify Launcher
won't crash. Test on both NexusLauncher and 3rd-party Launcher.

Change-Id: I9bde3d7864d3edd54145c66acae0cd1013d89c6b
diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java
index 0a09e34..db1d7e7 100644
--- a/quickstep/src/com/android/quickstep/TaskViewUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java
@@ -36,6 +36,7 @@
 import static com.android.launcher3.anim.Interpolators.clampToProgress;
 import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
 import static com.android.launcher3.statehandlers.DepthController.DEPTH;
+import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITIONS;
 import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
 import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING;
 
@@ -168,7 +169,7 @@
                 ENABLE_QUICKSTEP_LIVE_TILE.get() && v.getRecentsView().getRunningTaskIndex() != -1;
         final RemoteAnimationTargets targets =
                 new RemoteAnimationTargets(appTargets, wallpaperTargets, nonAppTargets,
-                        inLiveTileMode ? MODE_CLOSING : MODE_OPENING);
+                        !ENABLE_SHELL_TRANSITIONS && inLiveTileMode ? MODE_CLOSING : MODE_OPENING);
         final RemoteAnimationTargetCompat navBarTarget = targets.getNavBarRemoteAnimationTarget();
 
         SurfaceTransactionApplier applier = new SurfaceTransactionApplier(v);
@@ -282,7 +283,8 @@
             topMostSimulators = remoteTargetHandles;
         }
 
-        if (!skipViewChanges && parallaxCenterAndAdjacentTask && topMostSimulators.length > 0) {
+        if (!skipViewChanges && parallaxCenterAndAdjacentTask && topMostSimulators != null
+                && topMostSimulators.length > 0) {
             out.addFloat(v, VIEW_ALPHA, 1, 0, clampToProgress(LINEAR, 0.2f, 0.4f));
 
             RemoteTargetHandle[] simulatorCopies = topMostSimulators;