From a04e746e84f918fd5e6d4fa2cda7b60d90462cf0 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Fri, 31 May 2019 13:33:00 -0700 Subject: [PATCH] Fix getting stuck in BackgroundAppState for 2-button mode When ending in recents, we reapply the state - therefore, it's important to make sure we are in OverviewState before onSwipeUpComplete(). This is done by mLauncherTransitionController, which sets OverviewState on end. We already force mLauncherTransitionController to end before calling onSwipeUpComplete(), but in this case we were calling cancel() and setting mLauncherTransitionController = null, which meant we could never call end() on it. Instead, we should always call end() if we set it to null. Also ensure mLauncherTransitionController is created even if the gesture is completed, if an existing controller isn't already running. This can happen if you swipe up quickly enough that we get onGestureEnd before launcher is drawn, and in that case we still want the launcher component to animate once its ready. This is even more important for 2-button mode, because again, we rely on mLauncherTransitionController to set the state to OverviewState before we reapply it. Finally, clarified some methods by renaming "swipeUp" to "swipeUpToRecents". Bug: 132757019 Change-Id: Ieb24a4f36a39780e5d64d7bc312791608db474d1 --- .../quickstep/GoActivityControlHelper.java | 2 +- .../FallbackActivityControllerHelper.java | 2 +- .../LauncherActivityControllerHelper.java | 2 +- .../WindowTransformSwipeHandler.java | 30 ++++++++++--------- .../quickstep/ActivityControlHelper.java | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/go/quickstep/src/com/android/quickstep/GoActivityControlHelper.java b/go/quickstep/src/com/android/quickstep/GoActivityControlHelper.java index 8b6f8bcfe0..2db8b39d94 100644 --- a/go/quickstep/src/com/android/quickstep/GoActivityControlHelper.java +++ b/go/quickstep/src/com/android/quickstep/GoActivityControlHelper.java @@ -29,7 +29,7 @@ public abstract class GoActivityControlHelper im } @Override - public void onSwipeUpComplete(T activity) { + public void onSwipeUpToRecentsComplete(T activity) { // Go does not support swipe up gesture. } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityControllerHelper.java index f12efc83cd..dc58a4efc9 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityControllerHelper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityControllerHelper.java @@ -70,7 +70,7 @@ public final class FallbackActivityControllerHelper implements } @Override - public void onSwipeUpComplete(RecentsActivity activity) { + public void onSwipeUpToRecentsComplete(RecentsActivity activity) { RecentsView recentsView = activity.getOverviewPanel(); recentsView.getClearAllButton().setVisibilityAlpha(1); recentsView.setDisallowScrollToClearAll(false); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java index 5af09f7fd9..d0a41f3b53 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java @@ -91,7 +91,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe } @Override - public void onSwipeUpComplete(Launcher activity) { + public void onSwipeUpToRecentsComplete(Launcher activity) { // Re apply state in case we did something funky during the transition. activity.getStateManager().reapplyState(); DiscoveryBounce.showForOverviewIfNeeded(activity); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java index c7aaa9bb27..87b7326648 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -353,7 +353,7 @@ public class WindowTransformSwipeHandler | STATE_LAUNCHER_DRAWN | STATE_SCALED_CONTROLLER_RECENTS | STATE_CURRENT_TASK_FINISHED | STATE_GESTURE_COMPLETED | STATE_GESTURE_STARTED, - this::setupLauncherUiAfterSwipeUpAnimation); + this::setupLauncherUiAfterSwipeUpToRecentsAnimation); mStateCallback.addCallback(STATE_HANDLER_INVALIDATED, this::invalidateHandler); mStateCallback.addCallback(STATE_LAUNCHER_PRESENT | STATE_HANDLER_INVALIDATED, @@ -647,7 +647,10 @@ public class WindowTransformSwipeHandler } private void buildAnimationController() { - if (mStateCallback.hasStates(STATE_GESTURE_COMPLETED)) { + if (mGestureEndTarget == HOME || (mLauncherTransitionController != null + && mLauncherTransitionController.getAnimationPlayer().isStarted())) { + // We don't want a new mLauncherTransitionController if mGestureEndTarget == HOME (it + // has its own animation) or if we're already animating the current controller. return; } initTransitionEndpoints(mActivity.getDeviceProfile()); @@ -1276,12 +1279,7 @@ public class WindowTransformSwipeHandler } private void invalidateHandlerWithLauncher() { - if (mLauncherTransitionController != null) { - if (mLauncherTransitionController.getAnimationPlayer().isStarted()) { - mLauncherTransitionController.getAnimationPlayer().cancel(); - } - mLauncherTransitionController = null; - } + endLauncherTransitionController(); mRecentsView.onGestureAnimationEnd(); @@ -1289,6 +1287,13 @@ public class WindowTransformSwipeHandler mActivity.getRootView().getOverlay().remove(mLiveTileOverlay); } + private void endLauncherTransitionController() { + if (mLauncherTransitionController != null) { + mLauncherTransitionController.getAnimationPlayer().end(); + mLauncherTransitionController = null; + } + } + private void notifyTransitionCancelled() { mAnimationFactory.onTransitionCancelled(); } @@ -1390,12 +1395,9 @@ public class WindowTransformSwipeHandler doLogGesture(HOME); } - private void setupLauncherUiAfterSwipeUpAnimation() { - if (mLauncherTransitionController != null) { - mLauncherTransitionController.getAnimationPlayer().end(); - mLauncherTransitionController = null; - } - mActivityControlHelper.onSwipeUpComplete(mActivity); + private void setupLauncherUiAfterSwipeUpToRecentsAnimation() { + endLauncherTransitionController(); + mActivityControlHelper.onSwipeUpToRecentsComplete(mActivity); mRecentsAnimationWrapper.setCancelWithDeferredScreenshot(true); mRecentsView.onSwipeUpAnimationSuccess(); diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/ActivityControlHelper.java index 279a946195..b17d8d69c7 100644 --- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java +++ b/quickstep/src/com/android/quickstep/ActivityControlHelper.java @@ -51,7 +51,7 @@ public interface ActivityControlHelper { int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect); - void onSwipeUpComplete(T activity); + void onSwipeUpToRecentsComplete(T activity); void onAssistantVisibilityChanged(float visibility);