From d260e1cbcdd3834331978d00a349d5fb55432169 Mon Sep 17 00:00:00 2001 From: Evan Rosky Date: Mon, 9 May 2022 15:15:53 -0700 Subject: Ensure move-to-back has its own transition. In general, we need to move to a model where each transition is a "fixed" transaction (rather than absorbing everything within a specific time-window). Bug: 232020248 Test: PinnedStackTests#testMovePipToBack* Change-Id: Icf5d36e507bc70736e7760c50d5de297bfe4d8f4 --- data/etc/services.core.protolog.json | 12 ++-- services/core/java/com/android/server/wm/Task.java | 83 ++++++++++++++++------ 2 files changed, 69 insertions(+), 26 deletions(-) diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json index 0d62d20d1176..6e6d240d1eb7 100644 --- a/data/etc/services.core.protolog.json +++ b/data/etc/services.core.protolog.json @@ -163,6 +163,12 @@ "group": "WM_ERROR", "at": "com\/android\/server\/wm\/WindowManagerService.java" }, + "-1941440781": { + "message": "Creating Pending Move-to-back: %s", + "level": "VERBOSE", + "group": "WM_DEBUG_WINDOW_TRANSITIONS", + "at": "com\/android\/server\/wm\/Task.java" + }, "-1939861963": { "message": "Create root task displayId=%d winMode=%d", "level": "VERBOSE", @@ -2917,12 +2923,6 @@ "group": "WM_DEBUG_LOCKTASK", "at": "com\/android\/server\/wm\/ActivityTaskManagerService.java" }, - "716528224": { - "message": "Focused window found using wmService.getFocusedWindowLocked()", - "level": "DEBUG", - "group": "WM_DEBUG_BACK_PREVIEW", - "at": "com\/android\/server\/wm\/BackNavigationController.java" - }, "726205185": { "message": "Moving to DESTROYED: %s (destroy skipped)", "level": "VERBOSE", diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index ded5beb6e81a..ed7009b37df9 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -197,6 +197,7 @@ import android.window.WindowContainerToken; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.app.IVoiceInteractor; +import com.android.internal.protolog.ProtoLogGroup; import com.android.internal.protolog.common.ProtoLog; import com.android.internal.util.XmlUtils; import com.android.internal.util.function.pooled.PooledConsumer; @@ -5507,23 +5508,10 @@ class Task extends TaskFragment { } } - /** - * Worker method for rearranging history task. Implements the function of moving all - * activities for a specific task (gathering them if disjoint) into a single group at the - * bottom of the root task. - * - * If a watcher is installed, the action is preflighted and the watcher has an opportunity - * to premeptively cancel the move. - * - * @param tr The task to collect and move to the bottom. - * @return Returns true if the move completed, false if not. - */ - boolean moveTaskToBack(Task tr) { - Slog.i(TAG, "moveTaskToBack: " + tr); - + private boolean canMoveTaskToBack(Task task) { // In LockTask mode, moving a locked task to the back of the root task may expose unlocked // ones. Therefore we need to check if this operation is allowed. - if (!mAtmService.getLockTaskController().canMoveTaskToBack(tr)) { + if (!mAtmService.getLockTaskController().canMoveTaskToBack(task)) { return false; } @@ -5531,7 +5519,7 @@ class Task extends TaskFragment { // for *other* available tasks, but if none are available, then try again allowing the // current task to be selected. if (isTopRootTaskInDisplayArea() && mAtmService.mController != null) { - ActivityRecord next = topRunningActivity(null, tr.mTaskId); + ActivityRecord next = topRunningActivity(null, task.mTaskId); if (next == null) { next = topRunningActivity(null, INVALID_TASK_ID); } @@ -5549,15 +5537,70 @@ class Task extends TaskFragment { } } } + return true; + } + + /** + * Worker method for rearranging history task. Implements the function of moving all + * activities for a specific task (gathering them if disjoint) into a single group at the + * bottom of the root task. + * + * If a watcher is installed, the action is preflighted and the watcher has an opportunity + * to premeptively cancel the move. + * + * If this is a pinned task, it will be removed instead of rearranged. + * + * @param tr The task to collect and move to the bottom. + * @return Returns true if the move completed, false if not. + */ + boolean moveTaskToBack(Task tr) { + Slog.i(TAG, "moveTaskToBack: " + tr); + + if (!canMoveTaskToBack(tr)) return false; if (DEBUG_TRANSITION) Slog.v(TAG_TRANSITION, "Prepare to back transition: task=" + tr.mTaskId); - // Skip the transition for pinned task. - if (!inPinnedWindowingMode()) { - mDisplayContent.requestTransitionAndLegacyPrepare(TRANSIT_TO_BACK, tr); + if (mTransitionController.isShellTransitionsEnabled()) { + final Transition transition = new Transition(TRANSIT_TO_BACK, 0 /* flags */, + mTransitionController, mWmService.mSyncEngine); + // Guarantee that this gets its own transition by queueing on SyncEngine + if (mWmService.mSyncEngine.hasActiveSync()) { + ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS, + "Creating Pending Move-to-back: %s", transition); + mWmService.mSyncEngine.queueSyncSet( + () -> mTransitionController.moveToCollecting(transition), + () -> { + mTransitionController.requestStartTransition(transition, tr, + null /* remoteTransition */, null /* displayChange */); + // Need to check again since this happens later and the system might + // be in a different state. + if (!canMoveTaskToBack(tr)) { + Slog.e(TAG, "Failed to move task to back after saying we could: " + + tr.mTaskId); + transition.abort(); + return; + } + moveTaskToBackInner(tr); + }); + } else { + mTransitionController.moveToCollecting(transition); + mTransitionController.requestStartTransition(transition, tr, + null /* remoteTransition */, null /* displayChange */); + moveTaskToBackInner(tr); + } + } else { + // Skip the transition for pinned task. + if (!inPinnedWindowingMode()) { + mDisplayContent.prepareAppTransition(TRANSIT_TO_BACK); + } + moveTaskToBackInner(tr); } - moveToBack("moveTaskToBackLocked", tr); + return true; + } + + private boolean moveTaskToBackInner(@NonNull Task task) { + moveToBack("moveTaskToBackInner", task); if (inPinnedWindowingMode()) { mTaskSupervisor.removeRootTask(this); -- cgit v1.2.3-59-g8ed1b