Merge "Revert "Add debug logs to help identify when setRecentsAttachedToAppWindow will not animate properly."" into tm-qpr-dev
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index b0de9ce..4b35859 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -288,7 +288,7 @@
     private AnimatorControllerWithResistance mLauncherTransitionController;
     private boolean mHasEndedLauncherTransition;
 
-    private AnimationFactory mAnimationFactory = (t, s) -> { };
+    private AnimationFactory mAnimationFactory = (t) -> { };
 
     private boolean mWasLauncherAlreadyVisible;
 
@@ -536,9 +536,7 @@
             Runnable initAnimFactory = () -> {
                 mAnimationFactory = mActivityInterface.prepareRecentsUI(mDeviceState,
                         mWasLauncherAlreadyVisible, this::onAnimatorPlaybackControllerCreated);
-                maybeUpdateRecentsAttachedState(
-                        false /* animate */,
-                        new ActiveGestureLog.CompoundString("on Launcher start (animate=false)"));
+                maybeUpdateRecentsAttachedState(false /* animate */);
                 if (mGestureState.getEndTarget() != null) {
                     // Update the end target in case the gesture ended before we init.
                     mAnimationFactory.setEndTarget(mGestureState.getEndTarget());
@@ -643,8 +641,7 @@
     }
 
     private void initializeLauncherAnimationController() {
-        buildAnimationController(new ActiveGestureLog.CompoundString(
-                "initializing launcher animation controller"));
+        buildAnimationController();
 
         Object traceToken = TraceHelper.INSTANCE.beginSection("logToggleRecents",
                 TraceHelper.FLAG_IGNORE_BINDERS);
@@ -663,11 +660,7 @@
             @Override
             public void onMotionPauseDetected() {
                 mHasMotionEverBeenPaused = true;
-                maybeUpdateRecentsAttachedState(
-                        true/* animate */,
-                        true/* moveFocusedTask */,
-                        new ActiveGestureLog.CompoundString(
-                                "motion pause detected (animate=true)"));
+                maybeUpdateRecentsAttachedState(true/* animate */, true/* moveFocusedTask */);
                 Optional.ofNullable(mActivityInterface.getTaskbarController())
                         .ifPresent(TaskbarUIController::startTranslationSpring);
                 performHapticFeedback();
@@ -680,13 +673,12 @@
         };
     }
 
-    private void maybeUpdateRecentsAttachedState(ActiveGestureLog.CompoundString reason) {
-        maybeUpdateRecentsAttachedState(true /* animate */, reason.append(" (animate=true)"));
+    private void maybeUpdateRecentsAttachedState() {
+        maybeUpdateRecentsAttachedState(true /* animate */);
     }
 
-    private void maybeUpdateRecentsAttachedState(
-            boolean animate, ActiveGestureLog.CompoundString reason) {
-        maybeUpdateRecentsAttachedState(animate, false /* moveFocusedTask */, reason);
+    private void maybeUpdateRecentsAttachedState(boolean animate) {
+        maybeUpdateRecentsAttachedState(animate, false /* moveFocusedTask */);
     }
 
     /**
@@ -698,8 +690,7 @@
      * @param animate whether to animate when attaching RecentsView
      * @param moveFocusedTask whether to move focused task to front when attaching
      */
-    private void maybeUpdateRecentsAttachedState(
-            boolean animate, boolean moveFocusedTask, ActiveGestureLog.CompoundString reason) {
+    private void maybeUpdateRecentsAttachedState(boolean animate, boolean moveFocusedTask) {
         if (!mDeviceState.isFullyGesturalNavMode() || mRecentsView == null) {
             return;
         }
@@ -709,25 +700,14 @@
         final boolean recentsAttachedToAppWindow;
         if (mGestureState.getEndTarget() != null) {
             recentsAttachedToAppWindow = mGestureState.getEndTarget().recentsAttachedToAppWindow;
-            reason.append("; gesture state end target != null (attached=")
-                    .append(Boolean.toString(recentsAttachedToAppWindow))
-                    .append(")");
         } else if (mContinuingLastGesture
                 && mRecentsView.getRunningTaskIndex() != mRecentsView.getNextPage()) {
             recentsAttachedToAppWindow = true;
-            reason.append("; continuing last gesture (attached=true)");
         } else if (runningTaskTarget != null && isNotInRecents(runningTaskTarget)) {
             // The window is going away so make sure recents is always visible in this case.
             recentsAttachedToAppWindow = true;
-            reason.append("; make sure recents is always visible (attached=true)");
         } else {
             recentsAttachedToAppWindow = mHasMotionEverBeenPaused || mIsLikelyToStartNewTask;
-            reason.append(mHasMotionEverBeenPaused
-                            ? "; motion has been paused"
-                            : "; gesture is likely to start a new task")
-                    .append(" (attached=")
-                    .append(Boolean.toString(recentsAttachedToAppWindow))
-                    .append(")");
         }
         if (moveFocusedTask && !mAnimationFactory.hasRecentsEverAttachedToAppWindow()
                 && recentsAttachedToAppWindow) {
@@ -735,8 +715,7 @@
             // TaskView jumping to new position as we move the tasks.
             mRecentsView.moveFocusedTaskToFront();
         }
-        mAnimationFactory.setRecentsAttachedToAppWindow(
-                recentsAttachedToAppWindow, animate, reason);
+        mAnimationFactory.setRecentsAttachedToAppWindow(recentsAttachedToAppWindow, animate);
 
         // Reapply window transform throughout the attach animation, as the animation affects how
         // much the window is bound by overscroll (vs moving freely).
@@ -771,29 +750,22 @@
     }
 
     public void setIsLikelyToStartNewTask(boolean isLikelyToStartNewTask) {
-        setIsLikelyToStartNewTask(
-                isLikelyToStartNewTask,
-                true /* animate */,
-                new ActiveGestureLog.CompoundString(
-                        "setting gesture likely to start (animate=true)"));
+        setIsLikelyToStartNewTask(isLikelyToStartNewTask, true /* animate */);
     }
 
-    private void setIsLikelyToStartNewTask(
-            boolean isLikelyToStartNewTask,
-            boolean animate,
-            ActiveGestureLog.CompoundString reason) {
+    private void setIsLikelyToStartNewTask(boolean isLikelyToStartNewTask, boolean animate) {
         if (mIsLikelyToStartNewTask != isLikelyToStartNewTask) {
             mIsLikelyToStartNewTask = isLikelyToStartNewTask;
-            maybeUpdateRecentsAttachedState(animate, reason);
+            maybeUpdateRecentsAttachedState(animate);
         }
     }
 
-    private void buildAnimationController(ActiveGestureLog.CompoundString reason) {
+    private void buildAnimationController() {
         if (!canCreateNewOrUpdateExistingLauncherTransitionController()) {
             return;
         }
         initTransitionEndpoints(mActivity.getDeviceProfile());
-        mAnimationFactory.createActivityInterface(mTransitionDragLength, reason);
+        mAnimationFactory.createActivityInterface(mTransitionDragLength);
     }
 
     /**
@@ -808,7 +780,7 @@
     @Override
     public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
         WindowInsets result = view.onApplyWindowInsets(windowInsets);
-        buildAnimationController(new ActiveGestureLog.CompoundString("applying window insets"));
+        buildAnimationController();
         // Reapply the current shift to ensure it takes new insets into account, e.g. when long
         // pressing to stash taskbar without moving the finger.
         updateFinalShift();
@@ -982,10 +954,7 @@
             });
         }
         notifyGestureStartedAsync();
-        setIsLikelyToStartNewTask(
-                isLikelyToStartNewTask,
-                false /* animate */,
-                new ActiveGestureLog.CompoundString("on gesture started (animate=false)"));
+        setIsLikelyToStartNewTask(isLikelyToStartNewTask, false /* animate */);
         mStateCallback.setStateOnUiThread(STATE_GESTURE_STARTED);
         mGestureStarted = true;
     }
@@ -1066,8 +1035,7 @@
 
     private void onSettledOnEndTarget() {
         // Fast-finish the attaching animation if it's still running.
-        maybeUpdateRecentsAttachedState(false, new ActiveGestureLog.CompoundString(
-                "on settled on end target (animate=false)"));
+        maybeUpdateRecentsAttachedState(false);
         final GestureEndTarget endTarget = mGestureState.getEndTarget();
         // Wait until the given View (if supplied) draws before resuming the last task.
         View postResumeLastTask = mActivityInterface.onSettledOnEndTarget(endTarget);
@@ -1391,8 +1359,7 @@
     @UiThread
     private void animateToProgressInternal(float start, float end, long duration,
             Interpolator interpolator, GestureEndTarget target, PointF velocityPxPerMs) {
-        maybeUpdateRecentsAttachedState(new ActiveGestureLog.CompoundString(
-                "animate to progress internal"));
+        maybeUpdateRecentsAttachedState();
 
         // If we are transitioning to launcher, then listen for the activity to be restarted while
         // the transition is in progress
@@ -1715,9 +1682,7 @@
                     mRecentsView.post(mRecentsView::resetTaskVisuals);
                 }
                 // Make sure recents is in its final state
-                maybeUpdateRecentsAttachedState(
-                        false, new ActiveGestureLog.CompoundString(
-                                "setting up window animation (animate=false)"));
+                maybeUpdateRecentsAttachedState(false);
                 mActivityInterface.onSwipeUpToHomeComplete(mDeviceState);
             }
         });
diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
index 2c3ba85..274b686 100644
--- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
@@ -60,7 +60,6 @@
 import com.android.launcher3.util.DisplayController;
 import com.android.launcher3.util.NavigationMode;
 import com.android.launcher3.views.ScrimView;
-import com.android.quickstep.util.ActiveGestureLog;
 import com.android.quickstep.util.ActivityInitListener;
 import com.android.quickstep.util.AnimatorControllerWithResistance;
 import com.android.quickstep.views.RecentsView;
@@ -399,16 +398,14 @@
 
     public interface AnimationFactory {
 
-        void createActivityInterface(long transitionLength, ActiveGestureLog.CompoundString reason);
+        void createActivityInterface(long transitionLength);
 
         /**
          * @param attached Whether to show RecentsView alongside the app window. If false, recents
          *                 will be hidden by some property we can animate, e.g. alpha.
          * @param animate Whether to animate recents to/from its new attached state.
-         * @param reason Explanation for why this method is being called with the given param values
          */
-        default void setRecentsAttachedToAppWindow(
-                boolean attached, boolean animate, ActiveGestureLog.CompoundString reason) { }
+        default void setRecentsAttachedToAppWindow(boolean attached, boolean animate) { }
 
         default boolean isRecentsAttachedToAppWindow() {
             return false;
@@ -450,8 +447,7 @@
         }
 
         @Override
-        public void createActivityInterface(
-                long transitionLength, ActiveGestureLog.CompoundString reason) {
+        public void createActivityInterface(long transitionLength) {
             PendingAnimation pa = new PendingAnimation(transitionLength * 2);
             createBackgroundToOverviewAnim(mActivity, pa);
             AnimatorPlaybackController controller = pa.createPlaybackController();
@@ -474,29 +470,13 @@
             // (because we set the animation as the current state animation), so we reapply the
             // attached state here as well to ensure recents is shown/hidden appropriately.
             if (DisplayController.getNavigationMode(mActivity) == NavigationMode.NO_BUTTON) {
-                setRecentsAttachedToAppWindow(
-                        mIsAttachedToWindow,
-                        false,
-                        reason.append("; reapplying the attached state (attached=")
-                                .append(Boolean.toString(mIsAttachedToWindow))
-                                .append(", animate=false)"));
+                setRecentsAttachedToAppWindow(mIsAttachedToWindow, false);
             }
         }
 
         @Override
-        public void setRecentsAttachedToAppWindow(
-                boolean attached, boolean animate, ActiveGestureLog.CompoundString reason) {
-            // TODO(b/244593270): remove these logs; too verbose
-            ActiveGestureLog.INSTANCE.addLog(
-                    new ActiveGestureLog.CompoundString("setRecentsAttachedToAppWindow: attached=")
-                            .append(Boolean.toString(attached))
-                            .append(", animate=")
-                            .append(Boolean.toString(animate))
-                            .append(", reason=")
-                            .append(reason));
+        public void setRecentsAttachedToAppWindow(boolean attached, boolean animate) {
             if (mIsAttachedToWindow == attached && animate) {
-                ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
-                        "setRecentsAttachedToAppWindow: exiting early"));
                 return;
             }
             mActivity.getStateManager()
@@ -525,11 +505,6 @@
             float fromTranslation = ADJACENT_PAGE_HORIZONTAL_OFFSET.get(
                     mActivity.getOverviewPanel());
             float toTranslation = attached ? 0 : 1;
-            ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
-                    "setRecentsAttachedToAppWindow: fromTranslation=")
-                    .append(Float.toString(fromTranslation))
-                    .append(", toTranslation=")
-                    .append(Float.toString(toTranslation)));
 
             Animator translationAnimator = mActivity.getStateManager().createStateElementAnimation(
                     INDEX_RECENTS_TRANSLATE_X_ANIM, fromTranslation, toTranslation);