From 8151d41c9b09d19d5779b13a69938fdf7dc35462 Mon Sep 17 00:00:00 2001 From: Tony Huang Date: Wed, 26 Apr 2023 16:04:02 +0000 Subject: [PATCH] Fix black screen when recents finished after split Due to split screen might active but in background, we should check isVisible rather than isActive in mixed handler. Add more dump info in this CL too for debug convenience. Fix: 279754733 Test: manaul Test: pass existing tests Change-Id: Icb7ba7d1118cd4da84a9ed2509ba8a8f2323b5a3 --- .../shell/common/split/SplitScreenConstants.java | 13 +++++++++++++ .../wm/shell/splitscreen/StageCoordinator.java | 11 +++++++++-- .../wm/shell/splitscreen/StageTaskListener.java | 9 ++++++++- .../wm/shell/transition/DefaultMixedHandler.java | 16 ++++++++-------- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenConstants.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenConstants.java index b8204d0131051..0bcafe513b4f0 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenConstants.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitScreenConstants.java @@ -59,4 +59,17 @@ public class SplitScreenConstants { /** Flag applied to a transition change to identify it as a divider bar for animation. */ public static final int FLAG_IS_DIVIDER_BAR = FLAG_FIRST_CUSTOM; + + public static final String splitPositionToString(@SplitPosition int pos) { + switch (pos) { + case SPLIT_POSITION_UNDEFINED: + return "SPLIT_POSITION_UNDEFINED"; + case SPLIT_POSITION_TOP_OR_LEFT: + return "SPLIT_POSITION_TOP_OR_LEFT"; + case SPLIT_POSITION_BOTTOM_OR_RIGHT: + return "SPLIT_POSITION_BOTTOM_OR_RIGHT"; + default: + return "UNKNOWN"; + } + } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java index 222e7db9e903d..e5ae10c097a55 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java @@ -39,6 +39,7 @@ import static com.android.wm.shell.common.split.SplitScreenConstants.FLAG_IS_DIV import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT; import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT; import static com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED; +import static com.android.wm.shell.common.split.SplitScreenConstants.splitPositionToString; import static com.android.wm.shell.common.split.SplitScreenUtils.reverseSplitPosition; import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_MAIN; import static com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_SIDE; @@ -2853,12 +2854,18 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, final String childPrefix = innerPrefix + " "; pw.println(prefix + TAG + " mDisplayId=" + mDisplayId); pw.println(innerPrefix + "mDividerVisible=" + mDividerVisible); + pw.println(innerPrefix + "isSplitActive=" + isSplitActive()); + pw.println(innerPrefix + "isSplitVisible=" + isSplitScreenVisible()); pw.println(innerPrefix + "MainStage"); - pw.println(childPrefix + "stagePosition=" + getMainStagePosition()); + pw.println(childPrefix + "stagePosition=" + splitPositionToString(getMainStagePosition())); pw.println(childPrefix + "isActive=" + mMainStage.isActive()); + mMainStage.dump(pw, childPrefix); + pw.println(innerPrefix + "MainStageListener"); mMainStageListener.dump(pw, childPrefix); pw.println(innerPrefix + "SideStage"); - pw.println(childPrefix + "stagePosition=" + getSideStagePosition()); + pw.println(childPrefix + "stagePosition=" + splitPositionToString(getSideStagePosition())); + mSideStage.dump(pw, childPrefix); + pw.println(innerPrefix + "SideStageListener"); mSideStageListener.dump(pw, childPrefix); if (mMainStage.isActive()) { pw.println(innerPrefix + "SplitLayout"); 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..18b09b0907943 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 @@ -421,6 +421,13 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener { public void dump(@NonNull PrintWriter pw, String prefix) { final String innerPrefix = prefix + " "; final String childPrefix = innerPrefix + " "; - pw.println(prefix + this); + if (mChildrenTaskInfo.size() > 0) { + pw.println(prefix + "Children list:"); + for (int i = mChildrenTaskInfo.size() - 1; i >= 0; --i) { + final ActivityManager.RunningTaskInfo taskInfo = mChildrenTaskInfo.valueAt(i); + pw.println(childPrefix + "Task#" + i + " taskID=" + taskInfo.taskId + + " baseActivity=" + taskInfo.baseActivity); + } + } } } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java index 7c729a46b6799..49429327572e2 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java @@ -73,7 +73,7 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler, /** Pip was entered while handling an intent with its own remoteTransition. */ static final int TYPE_OPTIONS_REMOTE_AND_PIP_CHANGE = 3; - /** Recents transition while split-screen active. */ + /** Recents transition while split-screen foreground. */ static final int TYPE_RECENTS_DURING_SPLIT = 4; /** The default animation for this mixed transition. */ @@ -152,7 +152,7 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler, @NonNull TransitionRequestInfo request) { if (mPipHandler.requestHasPipEnter(request) && mSplitHandler.isSplitScreenVisible()) { ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " Got a PiP-enter request while " - + "Split-Screen is active, so treat it as Mixed."); + + "Split-Screen is foreground, so treat it as Mixed."); if (request.getRemoteTransition() != null) { throw new IllegalStateException("Unexpected remote transition in" + "pip-enter-from-split request"); @@ -183,13 +183,13 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler, mixed.mLeftoversHandler = handler.first; mActiveTransitions.add(mixed); return handler.second; - } else if (mSplitHandler.isSplitActive() + } else if (mSplitHandler.isSplitScreenVisible() && isOpeningType(request.getType()) && request.getTriggerTask() != null && request.getTriggerTask().getWindowingMode() == WINDOWING_MODE_FULLSCREEN && request.getTriggerTask().getActivityType() == ACTIVITY_TYPE_HOME) { ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " Got a going-home request while " - + "Split-Screen is active, so treat it as Mixed."); + + "Split-Screen is foreground, so treat it as Mixed."); Pair handler = mPlayer.dispatchRequest(transition, request, this); if (handler == null) { @@ -211,7 +211,7 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler, @Override public Transitions.TransitionHandler handleRecentsRequest(WindowContainerTransaction outWCT) { - if (mRecentsHandler != null && mSplitHandler.isSplitActive()) { + if (mRecentsHandler != null && mSplitHandler.isSplitScreenVisible()) { return this; } return null; @@ -219,9 +219,9 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler, @Override public void setRecentsTransition(IBinder transition) { - if (mSplitHandler.isSplitActive()) { + if (mSplitHandler.isSplitScreenVisible()) { ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " Got a recents request while " - + "Split-Screen is active, so treat it as Mixed."); + + "Split-Screen is foreground, so treat it as Mixed."); final MixedTransition mixed = new MixedTransition( MixedTransition.TYPE_RECENTS_DURING_SPLIT, transition); mixed.mLeftoversHandler = mRecentsHandler; @@ -351,7 +351,7 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler, @NonNull SurfaceControl.Transaction finishTransaction, @NonNull Transitions.TransitionFinishCallback finishCallback) { ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " Animating a mixed transition for " - + "entering PIP while Split-Screen is active."); + + "entering PIP while Split-Screen is foreground."); TransitionInfo.Change pipChange = null; TransitionInfo.Change wallpaper = null; final TransitionInfo everythingElse = subCopy(info, TRANSIT_TO_BACK, true /* changes */);