From 20f56747b3479957d652e455c3e44b2aabdd5370 Mon Sep 17 00:00:00 2001 From: Kazuki Takise Date: Tue, 13 Jun 2023 17:52:30 +0900 Subject: Request transition when PIP is removed This CL is a reland of the following change with a fix for CTS: I4c13ecc1b3c1dff15bd0d61aeafeacc1d7705460 Original commit message from here When PIP gets killed via removeRootTasksWithActivityTypes(), no transition is requested. For non-PIP tasks, processRemoveTask() is called to remove the task, in which requestCloseTransitionIfNeeded() is invoked. But in the case of PIP, removePinnedRootTaskInSurfaceTransaction() is called but we seem to miss requesting a close transition. Original commit message to here The original change broke a CTS test, which expects onStop() is called before onPictureInPictureModeChanged() when PiP is removed. This is because scheduling a transition at the beginning of removePinnedRootTaskInSurfaceTransaction() prevents the workaround of forcefully stopping the PiP activity in the same function from working. The reason why the workaround doesn't work is, in processStoppingAndFinishingActivities(), there's a check whether a stopping activity is in a transition, and if it is, stopping it is deferred. However, we need to start a transition before we forcefully make the activity invisible and stopped to properly collect it, so this CL gives an exception to forcefully hidden PiP so that it will be stoppped immediately even if it's in a transition. Bug: 277864359 Bug: 275021556 Bug: 273141544 Bug: 272637936 Test: PinnedStackTests Change-Id: Iec89dcdd0081eca1f26161aaead1662f0f661ab6 --- services/core/java/com/android/server/wm/ActivityTaskSupervisor.java | 3 ++- services/core/java/com/android/server/wm/Task.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java b/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java index 738797b809a5..4833b66fa5a5 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java +++ b/services/core/java/com/android/server/wm/ActivityTaskSupervisor.java @@ -2198,7 +2198,8 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks { displaySwapping |= s.isDisplaySleepingAndSwapping(); ProtoLog.v(WM_DEBUG_STATES, "Stopping %s: nowVisible=%b animating=%b " + "finishing=%s", s, s.nowVisible, animating, s.finishing); - if ((!animating && !displaySwapping) || mService.mShuttingDown) { + if ((!animating && !displaySwapping) || mService.mShuttingDown + || s.getRootTask().isForceHiddenForPinnedTask()) { if (!processPausingActivities && s.isState(PAUSING)) { // Defer processing pausing activities in this iteration and reschedule // a delayed idle to reprocess it again diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 9c23beb21a92..c5e5b1de6f83 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -4504,6 +4504,10 @@ class Task extends TaskFragment { return mForceHiddenFlags != 0; } + boolean isForceHiddenForPinnedTask() { + return (mForceHiddenFlags & FLAG_FORCE_HIDDEN_FOR_PINNED_TASK) != 0; + } + @Override protected boolean isForceTranslucent() { return mForceTranslucent; -- cgit v1.2.3-59-g8ed1b