From 842e065311d50da97938a98e9459a2e1a6308860 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Fri, 14 Jul 2023 07:59:28 +0000 Subject: [PATCH] Do not enter pip during transient launch. When Pair-to-pair switch, the closing task is accidentally enter pip during startActivityFromRecents => moveTaskToFront, which cause two problems: 1. Pip transition should happen after transient launch finich. 2. StageCoordinator cannot handle the pip change, so that pip task will enter a strange situation. By checking whether the current top root task is transient hide, if it does, don't allow it to enter pip while pausing. And if that task really need to enter pip, it shall happen after transient launch was committed. Bug: 290857445 Test: Do pair-to-pair quick switch with an auto-pip app exist, verify no auto pip happen like switch on fullscreen app. Test: Verify swipe up to enter auto-pip still work. Change-Id: I81b1bbc2e3b8617b64ec92d2ce4a528ebe8aaaa6 --- .../core/java/com/android/server/wm/Task.java | 17 +++++++++-------- .../java/com/android/server/wm/Transition.java | 4 ++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 9c23beb21a921..66dfdefb24e4c 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -5251,17 +5251,18 @@ class Task extends TaskFragment { // Ensure that we do not trigger entering PiP an activity on the root pinned task. return; } - final boolean isTransient = opts != null && opts.getTransientLaunch(); final Task targetRootTask = toFrontTask != null ? toFrontTask.getRootTask() : toFrontActivity.getRootTask(); - if (targetRootTask != null && (targetRootTask.isActivityTypeAssistant() || isTransient)) { - // Ensure the task/activity being brought forward is not the assistant and is not - // transient. In the case of transient-launch, we want to wait until the end of the - // transition and only allow switch if the transient launch was committed. - return; - } - pipCandidate.supportsEnterPipOnTaskSwitch = true; + final boolean isTransient = opts != null && opts.getTransientLaunch() + || (targetRootTask != null + && targetRootTask.mTransitionController.isTransientHide(targetRootTask)); + // Ensure the task/activity being brought forward is not the assistant and is not transient + // nor transient hide target. In the case of transient-launch, we want to wait until the end + // of the transition and only allow to enter pip on task switch after the transient launch + // was committed. + pipCandidate.supportsEnterPipOnTaskSwitch = targetRootTask == null + || !(targetRootTask.isActivityTypeAssistant() || isTransient); } /** diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index 71192cd5a3be9..8319dc026bf38 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -1041,6 +1041,10 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { ar.getTaskFragment().startPausing(false /* uiSleeping */, null /* resuming */, "finishTransition"); } finally { + // Didn't schedule for pip, clear the supportsEnterPipOnTaskSwitch flag. + if (!ar.mPauseSchedulePendingForPip) { + ar.supportsEnterPipOnTaskSwitch = false; + } mController.mAtm.mTaskSupervisor.mUserLeaving = false; } // Return false anyway because there's no guarantee that the app will enter pip.