diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java index 50a253c6a9..05d34b5cb7 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java @@ -130,6 +130,15 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { super(context, attrs, defStyleAttr, defStyleRes); } + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + + if (mViewCallbacks != null) { + mViewCallbacks.onViewDetchedFromWindow(); + } + } + @Override protected void onFinishInflate() { super.onFinishInflate(); @@ -281,6 +290,10 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { return mDesktopTaskIndex; } + void resetViewCallbacks() { + mViewCallbacks = null; + } + protected Animator getCloseAnimation() { AnimatorSet closeAnimation = new AnimatorSet(); diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java index a80c11cc17..4f5cd135fd 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java @@ -68,6 +68,8 @@ public class KeyboardQuickSwitchViewController { private boolean mOnDesktop; private boolean mWasDesktopTaskFilteredOut; + private boolean mDetachingFromWindow = false; + protected KeyboardQuickSwitchViewController( @NonNull TaskbarControllers controllers, @NonNull TaskbarOverlayContext overlayContext, @@ -229,7 +231,12 @@ public class KeyboardQuickSwitchViewController { private void onCloseComplete() { mCloseAnimation = null; - mOverlayContext.getDragLayer().removeView(mKeyboardQuickSwitchView); + // Reset the view callbacks to prevent `onDetachedFromWindow` getting called in response to + // the `removeView(mKeyboardQuickSwitchView)` call. + mKeyboardQuickSwitchView.resetViewCallbacks(); + if (!mDetachingFromWindow) { + mOverlayContext.getDragLayer().removeView(mKeyboardQuickSwitchView); + } mControllerCallbacks.onCloseComplete(); InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_CLOSE); } @@ -319,5 +326,11 @@ public class KeyboardQuickSwitchViewController { boolean isAspectRatioSquare() { return mControllerCallbacks.isAspectRatioSquare(); } + + void onViewDetchedFromWindow() { + mDetachingFromWindow = true; + closeQuickSwitchView(false); + mDetachingFromWindow = false; + } } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index f3741b21db..146beed410 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -29,7 +29,6 @@ import static com.android.launcher3.AbstractFloatingView.TYPE_ON_BOARD_POPUP; import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE; import static com.android.launcher3.AbstractFloatingView.TYPE_TASKBAR_OVERLAY_PROXY; import static com.android.launcher3.Flags.enableCursorHoverStates; -import static com.android.launcher3.Flags.taskbarOverflow; import static com.android.launcher3.Utilities.calculateTextHeight; import static com.android.launcher3.Utilities.isRunningInTestHarness; import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION; @@ -1213,9 +1212,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { boolean shouldCloseAllOpenViews = true; Object tag = view.getTag(); - if (taskbarOverflow()) { - mControllers.keyboardQuickSwitchController.closeQuickSwitchView(false); - } + mControllers.keyboardQuickSwitchController.closeQuickSwitchView(false); if (tag instanceof GroupTask groupTask) { handleGroupTaskLaunch( diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java index 7030088287..375e7db6b7 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java @@ -126,6 +126,8 @@ public class TaskbarUIController implements BubbleBarController.BubbleBarLocatio * Manually closes the overlay window. */ public void hideOverlayWindow() { + mControllers.keyboardQuickSwitchController.closeQuickSwitchView(); + if (!DisplayController.isTransientTaskbar(mControllers.taskbarActivityContext) || mControllers.taskbarAllAppsController.isOpen()) { mControllers.taskbarOverlayController.hideWindow(); diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 1481ef2460..01508116f6 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -927,9 +927,6 @@ public class TouchInteractionService extends Service { BubbleControllers bubbleControllers = tac != null ? tac.getBubbleControllers() : null; boolean isOnBubbles = bubbleControllers != null && BubbleBarInputConsumer.isEventOnBubbles(tac, event); - if (isInSwipeUpTouchRegion && tac != null) { - tac.closeKeyboardQuickSwitchView(); - } if (mDeviceState.isButtonNavMode() && mDeviceState.supportsAssistantGestureInButtonNav()) { reasonString.append("in three button mode which supports Assistant gesture");