Fixing issue with swipe-dismiss animation clobbering home animation.

- Finish all dismiss animations when a dismiss-to-home animation is 
  started, and prevent lingering deferred layout animation requests
  from running as they will be overwritten anyways.

Bug: 28287904
Change-Id: Ie40c66c0f25705b56f6808607d2b7b8ae4e5a112
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index 48f9453..6732b17 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -647,7 +647,7 @@
      */
     private void relayoutTaskViews(AnimationProps animation, boolean ignoreTaskOverrides) {
         // If we had a deferred animation, cancel that
-        mDeferredTaskViewLayoutAnimation = null;
+        cancelDeferredTaskViewLayoutAnimation();
 
         // Synchronize the current set of TaskViews
         bindVisibleTaskViews(mStackScroller.getStackScroll(),
@@ -739,23 +739,12 @@
 
     /**
      * Cancels all {@link TaskView} animations.
-     *
-     * @see #cancelAllTaskViewAnimations(ArraySet<Task.TaskKey>)
      */
     void cancelAllTaskViewAnimations() {
-        cancelAllTaskViewAnimations(mIgnoreTasks);
-    }
-
-    /**
-     * Cancels all {@link TaskView} animations.
-     *
-     * @param ignoreTasksSet The set of tasks to continue running their animations.
-     */
-    void cancelAllTaskViewAnimations(ArraySet<Task.TaskKey> ignoreTasksSet) {
         List<TaskView> taskViews = getTaskViews();
         for (int i = taskViews.size() - 1; i >= 0; i--) {
             final TaskView tv = taskViews.get(i);
-            if (!ignoreTasksSet.contains(tv.getTask().key)) {
+            if (!mIgnoreTasks.contains(tv.getTask().key)) {
                 tv.cancelTransformAnimation();
             }
         }
@@ -1675,8 +1664,10 @@
 
     public final void onBusEvent(DismissRecentsToHomeAnimationStarted event) {
         // Stop any scrolling
+        cancelDeferredTaskViewLayoutAnimation();
         mStackScroller.stopScroller();
         mStackScroller.stopBoundScrollAnimation();
+        mTouchHandler.finishAnimations();
 
         // Start the task animations
         mAnimationHelper.startExitToHomeAnimation(event.animated, event.getAnimationTrigger());