From 1f6a5f50e522cea404f414dbfe30940fce65532f Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 6 Jul 2023 04:34:54 +0000 Subject: [PATCH] Ignore recents transition if there are no closing tasks - In the case where Launcher calls startRecentsTransition while there are no other visible tasks, we should not be continuing with the transition as there are no tasks for Launcher to control. This was previously handled in RecentsAnimationController in legacy transitions, but the safer fix is to ignore it on the Launcher side for this release. Bug: 289175232 Test: Manually trigger empty targets and verify no issues (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:6f7e15ff644bac2f11ecb779030255efebc18885) Merged-In: I3657c000cbc8c14c9ac989c2a57715515c96edb6 Change-Id: I3657c000cbc8c14c9ac989c2a57715515c96edb6 --- .../quickstep/RecentsAnimationCallbacks.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java index 523a98ec4b..2256cbf14b 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java @@ -15,6 +15,7 @@ */ package com.android.quickstep; +import static android.view.RemoteAnimationTarget.MODE_CLOSING; import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; @@ -37,6 +38,7 @@ import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.system.RecentsAnimationControllerCompat; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Set; @@ -101,9 +103,22 @@ public class RecentsAnimationCallbacks implements RemoteAnimationTarget[] appTargets, RemoteAnimationTarget[] wallpaperTargets, Rect homeContentInsets, Rect minimizedHomeBounds) { + long appCount = Arrays.stream(appTargets) + .filter(app -> app.mode == MODE_CLOSING) + .count(); + if (appCount == 0) { + // Edge case, if there are no closing app targets, then Launcher has nothing to handle + ActiveGestureLog.INSTANCE.addLog( + /* event= */ "RecentsAnimationCallbacks.onAnimationStart (canceled)", + /* extras= */ 0, + /* gestureEvent= */ START_RECENTS_ANIMATION); + notifyAnimationCanceled(); + animationController.finish(false /* toHome */, false /* sendUserLeaveHint */); + return; + } + mController = new RecentsAnimationController(animationController, mAllowMinimizeSplitScreen, this::onAnimationFinished); - if (mCancelled) { Utilities.postAsyncCallback(MAIN_EXECUTOR.getHandler(), mController::finishAnimationToApp);