From c04541c05398076a3e2a1694a5b0544116559bac Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Thu, 13 May 2021 08:06:58 +0800 Subject: [PATCH] Do not dismiss split if stages are not visible due to screen is sleeping Pass isSleeping information in TaskInfo to determine whether the task is sleeping due to display state. Prevent to dismiss staged split when both stages is not visible due to the display is sleeping, like keyguard showing or screen off. Bug: 188010345 Test: atest WMShellUnitTests Test: verified staged split won't be dismissed while keyguard showing and screen off. Change-Id: I0ee8943b035a9e9f937c22d2a228913e597ac79f --- core/java/android/app/TaskInfo.java | 12 +++++++++++- .../wm/shell/splitscreen/StageCoordinator.java | 13 ++++++++----- services/core/java/com/android/server/wm/Task.java | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/core/java/android/app/TaskInfo.java b/core/java/android/app/TaskInfo.java index b95412f00453e..7b96511b11564 100644 --- a/core/java/android/app/TaskInfo.java +++ b/core/java/android/app/TaskInfo.java @@ -239,6 +239,12 @@ public class TaskInfo { */ public boolean isVisible; + /** + * Whether this task is sleeping due to sleeping display. + * @hide + */ + public boolean isSleeping; + TaskInfo() { // Do nothing } @@ -342,7 +348,8 @@ public class TaskInfo { && getWindowingMode() == that.getWindowingMode() && Objects.equals(taskDescription, that.taskDescription) && isFocused == that.isFocused - && isVisible == that.isVisible; + && isVisible == that.isVisible + && isSleeping == that.isSleeping; } /** @@ -396,6 +403,7 @@ public class TaskInfo { parentTaskId = source.readInt(); isFocused = source.readBoolean(); isVisible = source.readBoolean(); + isSleeping = source.readBoolean(); topActivityToken = source.readStrongBinder(); topActivityInSizeCompat = source.readBoolean(); mTopActivityLocusId = source.readTypedObject(LocusId.CREATOR); @@ -434,6 +442,7 @@ public class TaskInfo { dest.writeInt(parentTaskId); dest.writeBoolean(isFocused); dest.writeBoolean(isVisible); + dest.writeBoolean(isSleeping); dest.writeStrongBinder(topActivityToken); dest.writeBoolean(topActivityInSizeCompat); dest.writeTypedObject(mTopActivityLocusId, flags); @@ -462,6 +471,7 @@ public class TaskInfo { + " parentTaskId=" + parentTaskId + " isFocused=" + isFocused + " isVisible=" + isVisible + + " isSleeping=" + isSleeping + " topActivityToken=" + topActivityToken + " topActivityInSizeCompat=" + topActivityInSizeCompat + " locusId= " + mTopActivityLocusId 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 f2a134fcdf695..bb1d06fbbbf2e 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 @@ -116,7 +116,7 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, private final List mListeners = new ArrayList<>(); private final DisplayImeController mDisplayImeController; private final SplitScreenTransitions mSplitTransitions; - private boolean mExitSplitScreenOnHide = true; + private boolean mExitSplitScreenOnHide; private boolean mKeyguardOccluded; // TODO(b/187041611): remove this flag after totally deprecated legacy split @@ -415,10 +415,13 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler, // Divider is only visible if both the main stage and side stages are visible setDividerVisibility(isSplitScreenVisible()); - if (mExitSplitScreenOnHide && !mainStageVisible && !sideStageVisible) { - // Exit split-screen if both stage are not visible. - // TODO: This is only a temporary request from UX and is likely to be removed soon... - exitSplitScreen(); + if (!mainStageVisible && !sideStageVisible) { + if (mExitSplitScreenOnHide + // Don't dismiss staged split when both stages are not visible due to sleeping display, + // like the cases keyguard showing or screen off. + || (!mMainStage.mRootTaskInfo.isSleeping && !mSideStage.mRootTaskInfo.isSleeping)) { + exitSplitScreen(); + } } else if (mKeyguardOccluded) { // At least one of the stages is visible while keyguard occluded. Dismiss split because // there's show-when-locked activity showing on top of keyguard. Also make sure the diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 93fc4f2a31494..656088fe259fc 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -4136,6 +4136,7 @@ class Task extends WindowContainer { : INVALID_TASK_ID; info.isFocused = isFocused(); info.isVisible = hasVisibleChildren(); + info.isSleeping = shouldSleepActivities(); ActivityRecord topRecord = getTopNonFinishingActivity(); info.mTopActivityLocusId = topRecord != null ? topRecord.getLocusId() : null; }