Clear keyboardFocusTask after Meta+Tab

- keyboardFocusTask caused AbsSwiepUpHandler to map wrong progress to the swipe up animation
- OverviewCommandHelper set keyboardFocusTask in all commands, but only clear it in HIDE_ALT_TAB causing the wrong state to be stuck
- Also clear keyboardFocusTask in reset() just to make sure

Fix: 407050102
Test: Meta+Tab, launch task, then swipe up
Test: Alt+Tab to switch to Overview
Flag: EXEMPT bug fix
Change-Id: I96ba74e91ce338077af7515b66f249d178897108
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt b/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
index df1e9a4..20a9650 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.kt
@@ -46,9 +46,8 @@
 import com.android.launcher3.util.OverviewReleaseFlags.enableGridOnlyOverview
 import com.android.launcher3.util.RunnableList
 import com.android.launcher3.util.coroutines.DispatcherProvider
-import com.android.launcher3.util.coroutines.ProductionDispatchers
-import com.android.quickstep.GestureState.displaySupportsHomeGesture
 import com.android.quickstep.GestureState.GestureEndTarget
+import com.android.quickstep.GestureState.displaySupportsHomeGesture
 import com.android.quickstep.OverviewCommandHelper.CommandInfo.CommandStatus
 import com.android.quickstep.OverviewCommandHelper.CommandType.HIDE_ALT_TAB
 import com.android.quickstep.OverviewCommandHelper.CommandType.HOME
@@ -429,13 +428,13 @@
                     // Initiate a recents animation that is immediately rejected, which will
                     // provide visual feedback that home is not supported.
                     return startRecentsTransitionWithEndTarget(
-                            command,
-                            onCallbackResult,
-                            containerInterface,
-                            taskAnimationManager,
-                            GestureState.GestureEndTarget.REJECT_HOME,
-                            recentsView
-                        )
+                        command,
+                        onCallbackResult,
+                        containerInterface,
+                        taskAnimationManager,
+                        GestureState.GestureEndTarget.REJECT_HOME,
+                        recentsView,
+                    )
                 }
             }
 
@@ -481,7 +480,7 @@
             containerInterface,
             taskAnimationManager,
             GestureState.GestureEndTarget.RECENTS,
-            recentsView
+            recentsView,
         )
     }
 
@@ -491,7 +490,7 @@
         containerInterface: BaseContainerInterface<*, *>,
         taskAnimationManager: TaskAnimationManager,
         gestureEndTarget: GestureState.GestureEndTarget,
-        recentsView: RecentsView<*, *>?
+        recentsView: RecentsView<*, *>?,
     ): Boolean {
         val recentsViewContainer = containerInterface.getCreatedContainer()
         if (gestureEndTarget == GestureState.GestureEndTarget.RECENTS) {
@@ -554,7 +553,9 @@
                         if (recentsViewContainer is RecentsWindowManager) {
                             recentsViewContainer.rootView?.let { view ->
                                 InteractionJankMonitorWrapper.begin(
-                                    view, Cuj.CUJ_LAUNCHER_QUICK_SWITCH)
+                                    view,
+                                    Cuj.CUJ_LAUNCHER_QUICK_SWITCH,
+                                )
                             }
                         }
 
@@ -680,12 +681,11 @@
 
     private fun onRecentsViewFocusUpdated(command: CommandInfo) {
         val recentsView: RecentsView<*, *> = getVisibleRecentsView(command.displayId) ?: return
-        if (command.type != HIDE_ALT_TAB || keyboardFocusTask is KeyboardFocusTask.Unfocused) {
-            return
+        if (command.type == HIDE_ALT_TAB && keyboardFocusTask !is KeyboardFocusTask.Unfocused) {
+            recentsView.currentPage = recentsView.indexOfChild(recentsView.keyboardFocusTaskView)
+            keyboardFocusTask = KeyboardFocusTask.Unfocused
         }
-        recentsView.currentPage = recentsView.indexOfChild(recentsView.keyboardFocusTaskView)
         recentsView.setKeyboardFocusTask(KeyboardFocusTask.Unfocused)
-        keyboardFocusTask = KeyboardFocusTask.Unfocused
     }
 
     private fun View?.requestFocus(): Boolean {
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 899f0a4..465f018 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -2763,6 +2763,7 @@
         if (mAddDesktopButton != null) {
             mAddDesktopButton.setGestureAlpha(1f);
         }
+        setKeyboardFocusTask(KeyboardFocusTask.Unfocused.INSTANCE);
 
         if (enableRefactorTaskThumbnail()) {
             // TODO(b/353917593): RecentsView is never destroyed, so its dependencies need to