From 4af3e80cae0dc3074e1ffe0bcac3b0233ef8509b Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Wed, 7 Feb 2024 11:27:58 -0800 Subject: [PATCH] Update state for when task launched in live tile mode gets cancelled. This fixes the bug where taskbar shows up on home screen. Fixes: 314790864 Flag: N/A Test: From overview, tap on app, then immediately swipe to go home Change-Id: I3aaa8cbe67edefc43ccd6db90ee7647152a862fc --- .../TaskbarLauncherStateController.java | 36 ++++++++++++------- .../com/android/quickstep/TaskViewUtils.java | 12 +++++++ .../android/quickstep/views/RecentsView.java | 18 ++++++++++ 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java index a8506805b8..72c9dcd1e6 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java @@ -304,6 +304,10 @@ public class TaskbarLauncherStateController { callbacks.addListener(mTaskBarRecentsAnimationListener); ((RecentsView) mLauncher.getOverviewPanel()).setTaskLaunchListener(() -> mTaskBarRecentsAnimationListener.endGestureStateOverride(true)); + + ((RecentsView) mLauncher.getOverviewPanel()).setTaskLaunchCancelledRunnable(() -> { + updateStateForUserFinishedToApp(false /* finishedToApp */); + }); return animatorSet; } @@ -770,21 +774,29 @@ public class TaskbarLauncherStateController { mTaskBarRecentsAnimationListener = null; ((RecentsView) mLauncher.getOverviewPanel()).setTaskLaunchListener(null); - // Update the visible state immediately to ensure a seamless handoff - boolean launcherVisible = !finishedToApp; - updateStateForFlag(FLAG_TRANSITION_TO_VISIBLE, false); - updateStateForFlag(FLAG_VISIBLE, launcherVisible); - applyState(); - - TaskbarStashController controller = mControllers.taskbarStashController; - if (DEBUG) { - Log.d(TAG, "endGestureStateOverride - FLAG_IN_APP: " + finishedToApp); - } - controller.updateStateForFlag(FLAG_IN_APP, finishedToApp); - controller.applyState(); + updateStateForUserFinishedToApp(finishedToApp); } } + /** + * Updates the visible state immediately to ensure a seamless handoff. + * @param finishedToApp True iff user is in an app. + */ + private void updateStateForUserFinishedToApp(boolean finishedToApp) { + // Update the visible state immediately to ensure a seamless handoff + boolean launcherVisible = !finishedToApp; + updateStateForFlag(FLAG_TRANSITION_TO_VISIBLE, false); + updateStateForFlag(FLAG_VISIBLE, launcherVisible); + applyState(); + + TaskbarStashController controller = mControllers.taskbarStashController; + if (DEBUG) { + Log.d(TAG, "endGestureStateOverride - FLAG_IN_APP: " + finishedToApp); + } + controller.updateStateForFlag(FLAG_IN_APP, finishedToApp); + controller.applyState(); + } + private static String getStateString(int flags) { StringJoiner result = new StringJoiner("|"); appendFlag(result, flags, FLAG_VISIBLE, "flag_visible"); diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index 4e84f4a6c4..23fb789a54 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -641,6 +641,18 @@ public final class TaskViewUtils { }); }); } + + @Override + public void onAnimationCancel(Animator animation) { + super.onAnimationCancel(animation); + recentsView.onTaskLaunchedInLiveTileModeCancelled(); + } + + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + recentsView.setTaskLaunchCancelledRunnable(null); + } }; } else { AnimatorPlaybackController controller = diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 997624f3d1..396865d14e 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -759,6 +759,9 @@ public abstract class RecentsView