Snap for 8018982 from d0b4d10f0e19a1bd5c587aea34ea6f1b24777a3e to sc-v2-release

Change-Id: I8a19d5cfd4315edba320ccf748a83180ba216c67
diff --git a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java
index b031c47..ed1a06d 100644
--- a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java
+++ b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java
@@ -77,7 +77,7 @@
         for (int i = 0; i < mRemoteTargetHandles.length; i++) {
             RemoteAnimationTargetCompat primaryTaskTarget = targets.apps[i];
             mRemoteTargetHandles[i].mTransformParams.setTargetSet(
-                    createRemoteAnimationTargetsForTarget(primaryTaskTarget, targets));
+                    createRemoteAnimationTargetsForTarget(targets, null));
             mRemoteTargetHandles[i].mTaskViewSimulator.setPreview(primaryTaskTarget, null);
         }
         return mRemoteTargetHandles;
@@ -95,47 +95,68 @@
     }
 
     /**
-     * Assigns the provided splitIDs to the {@link #mRemoteTargetHandles}, with index 0 will beint
+     * Assigns the provided splitIDs to the {@link #mRemoteTargetHandles}, with index 0 will being
      * the left/top task, index 1 right/bottom
      */
     public RemoteTargetHandle[] assignTargetsForSplitScreen(RemoteAnimationTargets targets,
             int[] splitIds) {
-        RemoteAnimationTargetCompat primaryTaskTarget;
-        RemoteAnimationTargetCompat secondaryTaskTarget;
+        RemoteAnimationTargetCompat topLeftTarget; // only one set if single/fullscreen task
+        RemoteAnimationTargetCompat bottomRightTarget;
         if (mRemoteTargetHandles.length == 1) {
             // If we're not in split screen, the splitIds count doesn't really matter since we
             // should always hit this case.
             mRemoteTargetHandles[0].mTransformParams.setTargetSet(targets);
             if (targets.apps.length > 0) {
                 // Unclear why/when target.apps length == 0, but it sure does happen :(
-                primaryTaskTarget = targets.apps[0];
-                mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(primaryTaskTarget, null);
+                topLeftTarget = targets.apps[0];
+                mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(topLeftTarget, null);
             }
         } else {
             // split screen
-            primaryTaskTarget = targets.findTask(splitIds[0]);
-            secondaryTaskTarget = targets.findTask(splitIds[1]);
+            topLeftTarget = targets.findTask(splitIds[0]);
+            bottomRightTarget = targets.findTask(splitIds[1]);
 
+            // remoteTargetHandle[0] denotes topLeft task, so we pass in the bottomRight to exclude,
+            // vice versa
             mStagedSplitBounds = new StagedSplitBounds(
-                    primaryTaskTarget.screenSpaceBounds,
-                    secondaryTaskTarget.screenSpaceBounds, splitIds[0], splitIds[1]);
+                    topLeftTarget.screenSpaceBounds,
+                    bottomRightTarget.screenSpaceBounds, splitIds[0], splitIds[1]);
             mRemoteTargetHandles[0].mTransformParams.setTargetSet(
-                    createRemoteAnimationTargetsForTarget(primaryTaskTarget, targets));
-            mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(primaryTaskTarget,
+                    createRemoteAnimationTargetsForTarget(targets, bottomRightTarget));
+            mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(topLeftTarget,
                     mStagedSplitBounds);
 
             mRemoteTargetHandles[1].mTransformParams.setTargetSet(
-                    createRemoteAnimationTargetsForTarget(secondaryTaskTarget, targets));
-            mRemoteTargetHandles[1].mTaskViewSimulator.setPreview(secondaryTaskTarget,
+                    createRemoteAnimationTargetsForTarget(targets, topLeftTarget));
+            mRemoteTargetHandles[1].mTaskViewSimulator.setPreview(bottomRightTarget,
                     mStagedSplitBounds);
         }
         return mRemoteTargetHandles;
     }
 
+    /**
+     * Ensures that we aren't excluding ancillary targets such as home/recents
+     *
+     * @param targetToExclude Will be excluded from the resulting return value.
+     *                        Pass in {@code null} to not exclude anything
+     * @return RemoteAnimationTargets where all the app targets from the passed in
+     *         {@param targets} are included except {@param targetToExclude}
+     */
     private RemoteAnimationTargets createRemoteAnimationTargetsForTarget(
-            RemoteAnimationTargetCompat target,
-            RemoteAnimationTargets targets) {
-        return new RemoteAnimationTargets(new RemoteAnimationTargetCompat[]{target},
+            RemoteAnimationTargets targets,
+            @Nullable RemoteAnimationTargetCompat targetToExclude) {
+        int finalLength = targets.unfilteredApps.length - (targetToExclude == null ? 0 : 1);
+        RemoteAnimationTargetCompat[] targetsWithoutExcluded =
+                new RemoteAnimationTargetCompat[finalLength];
+        int i = 0;
+        for (RemoteAnimationTargetCompat targetCompat : targets.unfilteredApps) {
+            if (targetCompat == targetToExclude) {
+                continue;
+            }
+            targetsWithoutExcluded[i] = targetCompat;
+            i++;
+        }
+        return new RemoteAnimationTargets(targetsWithoutExcluded,
                 targets.wallpapers, targets.nonApps, targets.targetMode);
     }
 
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index 67e7f88..a343438 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -34,6 +34,7 @@
 import android.os.RemoteException;
 import android.os.UserHandle;
 import android.util.Log;
+import android.util.Slog;
 import android.view.MotionEvent;
 import android.view.RemoteAnimationAdapter;
 import android.view.RemoteAnimationTarget;
@@ -760,8 +761,10 @@
     public ArrayList<GroupedRecentTaskInfo> getRecentTasks(int numTasks, int userId) {
         if (mRecentTasks != null) {
             try {
-                return new ArrayList<>(Arrays.asList(mRecentTasks.getRecentTasks(numTasks,
-                        RECENT_IGNORE_UNAVAILABLE, userId)));
+                final GroupedRecentTaskInfo[] tasks = mRecentTasks.getRecentTasks(numTasks,
+                        RECENT_IGNORE_UNAVAILABLE, userId);
+                Log.d("b/206648922", "getRecentTasks(" + numTasks + "): result=" + tasks);
+                return new ArrayList<>(Arrays.asList(tasks));
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed call getRecentTasks", e);
             }
diff --git a/src/com/android/launcher3/util/MultiValueAlpha.java b/src/com/android/launcher3/util/MultiValueAlpha.java
index 326141d..11cd07c 100644
--- a/src/com/android/launcher3/util/MultiValueAlpha.java
+++ b/src/com/android/launcher3/util/MultiValueAlpha.java
@@ -128,6 +128,9 @@
 
         public void setConsumer(Consumer<Float> consumer) {
             mConsumer = consumer;
+            if (mConsumer != null) {
+                mConsumer.accept(mValue);
+            }
         }
 
         @Override