Fixing animation regression due to ag/957220.

- Ensure we clear deferred relayouts after finishing all animations in
  case they trigger a deferred layout in the animation-end callback.

Bug: 28287904
Change-Id: I6d71328fb3dc4595ea67ee18cfa57d85d741e6c6
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
index fc7bba5..270d981 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
@@ -416,7 +416,7 @@
         int prevFocusState = mFocusState;
         mFocusState = focusState;
         updateFrontBackTransforms();
-        if (mCb != null && (prevFocusState != focusState)) {
+        if (mCb != null) {
             mCb.onFocusStateChanged(prevFocusState, focusState);
         }
     }
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 6732b17..a158482 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -1664,10 +1664,10 @@
 
     public final void onBusEvent(DismissRecentsToHomeAnimationStarted event) {
         // Stop any scrolling
-        cancelDeferredTaskViewLayoutAnimation();
+        mTouchHandler.finishAnimations();
         mStackScroller.stopScroller();
         mStackScroller.stopBoundScrollAnimation();
-        mTouchHandler.finishAnimations();
+        cancelDeferredTaskViewLayoutAnimation();
 
         // Start the task animations
         mAnimationHelper.startExitToHomeAnimation(event.animated, event.getAnimationTrigger());