Merge changes I69baed7b,I38a1da16 into sc-dev

* changes:
  Logging config changes as well
  Reduce some logging from previous CL
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 7599234..dbb8272 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -65,6 +65,7 @@
 import android.graphics.PointF;
 import android.graphics.Rect;
 import android.os.Build;
+import android.os.Handler;
 import android.os.SystemClock;
 import android.view.MotionEvent;
 import android.view.View;
@@ -135,6 +136,7 @@
     protected final BaseActivityInterface<S, T> mActivityInterface;
     protected final InputConsumerProxy mInputConsumerProxy;
     protected final ActivityInitListener mActivityInitListener;
+    private final Handler mHandler = new Handler();
     // Callbacks to be made once the recents animation starts
     private final ArrayList<Runnable> mRecentsAnimationStartCallbacks = new ArrayList<>();
     protected RecentsAnimationController mRecentsAnimationController;
@@ -1357,6 +1359,10 @@
         mActivityInitListener.unregister();
         ActivityManagerWrapper.getInstance().unregisterTaskStackListener(mActivityRestartListener);
         mTaskSnapshot = null;
+        mHandler.post(() -> {
+            // Defer clearing the activity since invalidation can happen over multiple callbacks
+            mActivity = null;
+        });
     }
 
     private void invalidateHandlerWithLauncher() {
diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java
index cbb2a66..1db5872 100644
--- a/quickstep/src/com/android/quickstep/TaskViewUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java
@@ -500,23 +500,25 @@
             windowAnimEndListener = new AnimatorListenerAdapter() {
                 @Override
                 public void onAnimationEnd(Animator animation) {
-                    recentsView.post(() -> {
-                        stateManager.moveToRestState();
-                        stateManager.reapplyState();
+                    recentsView.finishRecentsAnimation(false /* toRecents */, () -> {
+                        recentsView.post(() -> {
+                            stateManager.moveToRestState();
+                            stateManager.reapplyState();
+                        });
                     });
                 }
             };
         } else {
             AnimatorPlaybackController controller =
-                    stateManager.createAnimationToNewWorkspace(NORMAL,
-                            RECENTS_LAUNCH_DURATION);
+                    stateManager.createAnimationToNewWorkspace(NORMAL, RECENTS_LAUNCH_DURATION);
             controller.dispatchOnStart();
             childStateAnimation = controller.getTarget();
             launcherAnim = controller.getAnimationPlayer().setDuration(RECENTS_LAUNCH_DURATION);
             windowAnimEndListener = new AnimatorListenerAdapter() {
                 @Override
                 public void onAnimationEnd(Animator animation) {
-                    stateManager.goToState(NORMAL, false);
+                    recentsView.finishRecentsAnimation(false /* toRecents */,
+                            () -> stateManager.goToState(NORMAL, false));
                 }
             };
         }
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 4918036..150ae02 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -137,7 +137,6 @@
 import com.android.quickstep.TaskThumbnailCache;
 import com.android.quickstep.TaskViewUtils;
 import com.android.quickstep.ViewUtils;
-import com.android.quickstep.util.ActiveGestureLog;
 import com.android.quickstep.util.LayoutUtils;
 import com.android.quickstep.util.MultiValueUpdateListener;
 import com.android.quickstep.util.RecentsOrientedState;
@@ -760,6 +759,12 @@
                 }
             });
             anim.play(appAnimator);
+            anim.addListener(new AnimatorListenerAdapter() {
+                @Override
+                public void onAnimationEnd(Animator animation) {
+                    finishRecentsAnimation(true /* toRecents */, null);
+                }
+            });
         } else {
             TaskViewUtils.composeRecentsLaunchAnimator(
                     anim, taskView, apps,
@@ -768,30 +773,6 @@
                     mActivity.getStateManager(), this,
                     getDepthController());
         }
-        anim.addListener(new AnimatorListenerAdapter(){
-
-            @Override
-            public void onAnimationEnd(Animator animator) {
-                cleanUp(false);
-            }
-
-            @Override
-            public void onAnimationCancel(Animator animator) {
-                cleanUp(true);
-            }
-
-            private void cleanUp(boolean canceled) {
-                if (mRecentsAnimationController != null) {
-                    finishRecentsAnimation(false /* toRecents */, null /* onFinishComplete */);
-                    if (canceled) {
-                        mRecentsAnimationController = null;
-                    } else {
-                        mSizeStrategy.onLaunchTaskSuccess();
-                    }
-                    ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", false);
-                }
-            }
-        });
         anim.start();
     }
 
@@ -1441,6 +1422,7 @@
 
         mRecentsAnimationController = null;
         mLiveTileParams.setTargetSet(null);
+        mLiveTileTaskViewSimulator.setDrawsBelowRecents(true);
 
         unloadVisibleTaskData(TaskView.FLAG_UPDATE_ALL);
         setCurrentPage(0);
@@ -3078,6 +3060,7 @@
         }
 
         mRecentsAnimationController.finish(toRecents, () -> {
+            mRecentsAnimationController = null;
             if (onFinishComplete != null) {
                 onFinishComplete.run();
             }
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 8f22622..2bb14d2 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -484,7 +484,6 @@
             mIsClickableAsLiveTile = false;
             RecentsView recentsView = getRecentsView();
             RemoteAnimationTargets targets = recentsView.getLiveTileParams().getTargetSet();
-            recentsView.getLiveTileTaskViewSimulator().setDrawsBelowRecents(false);
 
             AnimatorSet anim = new AnimatorSet();
             TaskViewUtils.composeRecentsLaunchAnimator(
@@ -494,9 +493,12 @@
                     recentsView.getDepthController());
             anim.addListener(new AnimatorListenerAdapter() {
                 @Override
+                public void onAnimationStart(Animator animator) {
+                    recentsView.getLiveTileTaskViewSimulator().setDrawsBelowRecents(false);
+                }
+
+                @Override
                 public void onAnimationEnd(Animator animator) {
-                    recentsView.getLiveTileTaskViewSimulator().setDrawsBelowRecents(true);
-                    recentsView.finishRecentsAnimation(false, null);
                     mIsClickableAsLiveTile = true;
                 }
             });
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 6331ef2..44e3138 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -168,7 +168,15 @@
     public static final BooleanFlag ENABLE_SMARTSPACE_ENHANCED = new DeviceFlag(
             "ENABLE_SMARTSPACE_ENHANCED", false,
             "Replace Smartspace with the enhanced version. "
-              + "Ignored if ENABLE_SMARTSPACE_UNIVERSAL is enabled.");
+                    + "Ignored if ENABLE_SMARTSPACE_UNIVERSAL is enabled.");
+
+    public static final BooleanFlag ENABLE_SMARTSPACE_FEEDBACK = new DeviceFlag(
+            "ENABLE_SMARTSPACE_FEEDBACK", true,
+            "Adds a menu option to send feedback for Enhanced Smartspace.");
+
+    public static final BooleanFlag ENABLE_SMARTSPACE_DISMISS = new DeviceFlag(
+            "ENABLE_SMARTSPACE_DISMISS", false,
+            "Adds a menu option to dismiss the current Enhanced Smartspace card.");
 
     public static final BooleanFlag ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS =
             getDebugFlag(