From 2a47e6a6ed4d5fdc812e9c1ce3f60b5ff226f31c Mon Sep 17 00:00:00 2001 From: Tony Huang Date: Mon, 20 Mar 2023 18:47:21 +0800 Subject: [PATCH] Improve exit transition for task close case We got task vanished callback after its transition animation finished, and it lead to cause animation not smooth due to the delay. When task go to close, we will get a task info changed callback first and the top activity is null in this callback task info. We could use it to remove children task info early to reduce the delay to dismiss split. Fix: 263320869 Test: manual Test: pass existing tests Change-Id: I48486e46e539fe4647fc82a82b530d4637e3a544 --- .../wm/shell/common/split/SplitLayout.java | 4 ++++ .../wm/shell/splitscreen/StageTaskListener.java | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java index ffc56b6f6106d..b4acd60461829 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java @@ -727,6 +727,10 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange getRefBounds2(mTempRect); t.setPosition(leash2, mTempRect.left, mTempRect.top) .setWindowCrop(leash2, mTempRect.width(), mTempRect.height()); + // Make right or bottom side surface always higher than left or top side to avoid weird + // animation when dismiss split. e.g. App surface fling above on decor surface. + t.setLayer(leash1, 1); + t.setLayer(leash2, 2); if (mImePositionProcessor.adjustSurfaceLayoutForIme( t, dividerLeash, leash1, leash2, dimLayer1, dimLayer2)) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java index a841b7f96d3c5..d6f4d6daaa830 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageTaskListener.java @@ -220,12 +220,20 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener { mCallbacks.onNoLongerSupportMultiWindow(); return; } - mChildrenTaskInfo.put(taskInfo.taskId, taskInfo); + if (taskInfo.topActivity == null && mChildrenTaskInfo.contains(taskInfo.taskId) + && mChildrenTaskInfo.get(taskInfo.taskId).topActivity != null) { + // If top activity become null, it means the task is about to vanish, we use this + // signal to remove it from children list earlier for smooth dismiss transition. + mChildrenTaskInfo.remove(taskInfo.taskId); + mChildrenLeashes.remove(taskInfo.taskId); + } else { + mChildrenTaskInfo.put(taskInfo.taskId, taskInfo); + } mCallbacks.onChildTaskStatusChanged(taskInfo.taskId, true /* present */, taskInfo.isVisible); - if (!ENABLE_SHELL_TRANSITIONS) { - updateChildTaskSurface( - taskInfo, mChildrenLeashes.get(taskInfo.taskId), false /* firstAppeared */); + if (!ENABLE_SHELL_TRANSITIONS && mChildrenLeashes.contains(taskInfo.taskId)) { + updateChildTaskSurface(taskInfo, mChildrenLeashes.get(taskInfo.taskId), + false /* firstAppeared */); } } else { throw new IllegalArgumentException(this + "\n Unknown task: " + taskInfo