From b9438a8dce895c69c70acd5db88e307ac781a6e7 Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Tue, 29 Mar 2022 07:29:43 +0000 Subject: [PATCH] Include all not occluded leaf tasks while wrapping animation target There might be other leaf tasks beside the top leaf task are not occluded. Like the case when split screen is activated, both top leaf tasks in each side are not occluded. This makes sure to include them into remote animation target. Fix: 227307495 Test: pass existing tests Test: enter split, quick switch back and forth won't crash Change-Id: Ic8af56b1a9e029dc4f1c2c57ab59071aab2924b4 --- data/etc/services.core.protolog.json | 18 +++------ .../server/wm/RecentsAnimationController.java | 37 +++++++++++-------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json index 3a900e6e6bfa5..fb8385cd3ae17 100644 --- a/data/etc/services.core.protolog.json +++ b/data/etc/services.core.protolog.json @@ -1945,12 +1945,6 @@ "group": "WM_DEBUG_ORIENTATION", "at": "com\/android\/server\/wm\/ScreenRotationAnimation.java" }, - "-172900257": { - "message": "addTaskToTargets, target: %s", - "level": "DEBUG", - "group": "WM_DEBUG_RECENTS_ANIMATIONS", - "at": "com\/android\/server\/wm\/RecentsAnimationController.java" - }, "-172326720": { "message": "Saving icicle of %s: %s", "level": "INFO", @@ -2779,12 +2773,6 @@ "group": "WM_DEBUG_APP_TRANSITIONS", "at": "com\/android\/server\/wm\/WindowState.java" }, - "599897753": { - "message": "Previous Activity is %s. Back type is %s", - "level": "DEBUG", - "group": "WM_DEBUG_BACK_PREVIEW", - "at": "com\/android\/server\/wm\/BackNavigationController.java" - }, "600140673": { "message": "checkBootAnimationComplete: Waiting for anim complete", "level": "INFO", @@ -3319,6 +3307,12 @@ "group": "WM_DEBUG_WINDOW_ORGANIZER", "at": "com\/android\/server\/wm\/DisplayAreaOrganizerController.java" }, + "1151072840": { + "message": "collectTaskRemoteAnimations, target: %s", + "level": "DEBUG", + "group": "WM_DEBUG_RECENTS_ANIMATIONS", + "at": "com\/android\/server\/wm\/RecentsAnimationController.java" + }, "1164325516": { "message": "onExitAnimationDone in %s: exiting=%b remove=%b selfAnimating=%b anim=%s", "level": "VERBOSE", diff --git a/services/core/java/com/android/server/wm/RecentsAnimationController.java b/services/core/java/com/android/server/wm/RecentsAnimationController.java index 0495302533a5b..fc407e616bd94 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimationController.java +++ b/services/core/java/com/android/server/wm/RecentsAnimationController.java @@ -707,13 +707,7 @@ public class RecentsAnimationController implements DeathRecipient { if (isAnimatingTask(task) || skipAnimation(task)) { return; } - final RemoteAnimationTarget target = createTaskRemoteAnimation(task, MODE_OPENING, - finishedCallback); - if (target == null) { - return; - } - ProtoLog.d(WM_DEBUG_RECENTS_ANIMATIONS, "addTaskToTargets, target: %s", target); - mPendingTaskAppears.add(target); + collectTaskRemoteAnimations(task, MODE_OPENING, finishedCallback); } } @@ -729,19 +723,30 @@ public class RecentsAnimationController implements DeathRecipient { } } - private RemoteAnimationTarget createTaskRemoteAnimation(Task task, int mode, + private void collectTaskRemoteAnimations(Task task, int mode, OnAnimationFinishedCallback finishedCallback) { final SparseBooleanArray recentTaskIds = mService.mAtmService.getRecentTasks().getRecentTaskIds(); + // The target must be built off the root task (the leaf task surface would be cropped - // within the root surface). However, recents only tracks leaf task ids, so we'll replace - // the task-id with the leaf id. - final Task leafTask = task.getTopLeafTask(); - int taskId = leafTask.mTaskId; - TaskAnimationAdapter adapter = addAnimation(task, - !recentTaskIds.get(taskId), true /* hidden */, finishedCallback); - mPendingNewTaskTargets.add(taskId); - return adapter.createRemoteAnimationTarget(taskId, mode); + // within the root surface). However, recents only tracks leaf task ids, so we'll traverse + // and create animation target for all visible leaf tasks. + task.forAllLeafTasks(leafTask -> { + if (!leafTask.shouldBeVisible(null /* starting */)) { + return; + } + final int taskId = leafTask.mTaskId; + TaskAnimationAdapter adapter = addAnimation(leafTask, + !recentTaskIds.get(taskId), true /* hidden */, finishedCallback); + mPendingNewTaskTargets.add(taskId); + final RemoteAnimationTarget target = + adapter.createRemoteAnimationTarget(taskId, mode); + if (target != null) { + mPendingTaskAppears.add(target); + ProtoLog.d(WM_DEBUG_RECENTS_ANIMATIONS, + "collectTaskRemoteAnimations, target: %s", target); + } + }, true); } void logRecentsAnimationStartTime(int durationMs) {