From e81d9679c159a6f7e42573befac7109912d0a773 Mon Sep 17 00:00:00 2001 From: Evan Rosky Date: Wed, 23 Mar 2022 15:57:03 -0700 Subject: [PATCH] Implement switchtoScreenshot recents callback This lets the recents animation trigger a switchToScreenshot to avoid premature live-tile disappearance. Bug: 223321653 Test: put app in pip, open another app, go to recents, expand pip Change-Id: I7ddcd891978fca7e91d7d90c1c8d9b824f5652a6 --- .../quickstep/RecentsAnimationCallbacks.java | 19 +++++++++++++++++++ .../quickstep/TaskAnimationManager.java | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java index b50267633b..fe31f1d8bb 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java @@ -145,6 +145,18 @@ public class RecentsAnimationCallbacks implements }); } + @BinderThread + @Override + public boolean onSwitchToScreenshot(Runnable onFinished) { + Utilities.postAsyncCallback(MAIN_EXECUTOR.getHandler(), () -> { + for (RecentsAnimationListener listener : getListeners()) { + if (listener.onSwitchToScreenshot(onFinished)) return; + } + onFinished.run(); + }); + return true; + } + private final void onAnimationFinished(RecentsAnimationController controller) { Utilities.postAsyncCallback(MAIN_EXECUTOR.getHandler(), () -> { for (RecentsAnimationListener listener : getListeners()) { @@ -180,5 +192,12 @@ public class RecentsAnimationCallbacks implements * Callback made when a task started from the recents is ready for an app transition. */ default void onTasksAppeared(@NonNull RemoteAnimationTargetCompat[] appearedTaskTarget) {} + + /** + * @return whether this will call onFinished or not (onFinished should only be called once). + */ + default boolean onSwitchToScreenshot(Runnable onFinished) { + return false; + } } } diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java index 57b42f8246..4bb2400df1 100644 --- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java +++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java @@ -203,6 +203,24 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn } } } + + @Override + public boolean onSwitchToScreenshot(Runnable onFinished) { + if (!ENABLE_QUICKSTEP_LIVE_TILE.get() || !activityInterface.isInLiveTileMode() + || activityInterface.getCreatedActivity() == null) { + // No need to switch since tile is already a screenshot. + onFinished.run(); + } else { + final RecentsView recentsView = + activityInterface.getCreatedActivity().getOverviewPanel(); + if (recentsView != null) { + recentsView.switchToScreenshot(onFinished); + } else { + onFinished.run(); + } + } + return true; + } }); final long eventTime = gestureState.getSwipeUpStartTimeMs(); mCallbacks.addListener(gestureState);