From e1fb953f8571e01723ef2ce6f1b975fde5e564ff Mon Sep 17 00:00:00 2001 From: Matthew Duggan Date: Fri, 16 Oct 2020 17:27:22 +0900 Subject: [PATCH] Fix windowing mode for non-resizable tasks This contains 4 connected fixes for making the Dream activity non-resizable and fullscreen: 1. Non-resizable tasks should not be allowed to be in a multi-window mode. 2. Task#mForceResizableActivities should only be applied to "standard" activities (eg, Home and Dream should not be forced resizable). 3. Dreams should be set to non-resizable to ensure the activity behind is not visible, as asserted by the DreamManagerServiceTests CTS test. 4. To ensure the non-resizable dream activity is launched fullscreen, always create a new one-level task for the Dream - avoid creating an additional child task as it is not needed, there is only ever one DreamActivity. Bug: 168775742 Test: atest CtsWindowManagerDeviceTestCases:DreamManagerServiceTests Change-Id: Iffe57061cac2044699da78d84d64df0dddfb3a26 --- core/java/android/app/WindowConfiguration.java | 3 +++ .../server/wm/ActivityTaskManagerService.java | 2 ++ .../com/android/server/wm/DisplayContent.java | 7 +++++++ .../core/java/com/android/server/wm/Task.java | 17 ++++++++++++++--- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/core/java/android/app/WindowConfiguration.java b/core/java/android/app/WindowConfiguration.java index 4ae1670e90412..c4af4edb467b3 100644 --- a/core/java/android/app/WindowConfiguration.java +++ b/core/java/android/app/WindowConfiguration.java @@ -796,6 +796,9 @@ public class WindowConfiguration implements Parcelable, Comparable { int windowingMode = getResolvedOverrideConfiguration().windowConfiguration.getWindowingMode(); + final int parentWindowingMode = newParentConfig.windowConfiguration.getWindowingMode(); // Resolve override windowing mode to fullscreen for home task (even on freeform // display), or split-screen if in split-screen mode. if (getActivityType() == ACTIVITY_TYPE_HOME && windowingMode == WINDOWING_MODE_UNDEFINED) { - final int parentWindowingMode = newParentConfig.windowConfiguration.getWindowingMode(); windowingMode = WindowConfiguration.isSplitScreenWindowingMode(parentWindowingMode) ? parentWindowingMode : WINDOWING_MODE_FULLSCREEN; getResolvedOverrideConfiguration().windowConfiguration.setWindowingMode(windowingMode); } + // Do not allow non-resizable non-pinned tasks to be in a multi-window mode - they should + // use their parent's windowing mode, or fullscreen. + if (!isResizeable() && windowingMode != WINDOWING_MODE_PINNED + && WindowConfiguration.inMultiWindowMode(windowingMode)) { + windowingMode = WindowConfiguration.inMultiWindowMode(parentWindowingMode) + ? WINDOWING_MODE_FULLSCREEN : parentWindowingMode; + getResolvedOverrideConfiguration().windowConfiguration.setWindowingMode(windowingMode); + } + if (isLeafTask()) { resolveLeafOnlyOverrideConfigs(newParentConfig, mTmpBounds /* previousBounds */); } @@ -3312,7 +3321,9 @@ class Task extends WindowContainer { } boolean isResizeable(boolean checkSupportsPip) { - return (mAtmService.mForceResizableActivities || ActivityInfo.isResizeableMode(mResizeMode) + final boolean forceResizable = mAtmService.mForceResizableActivities + && getActivityType() == ACTIVITY_TYPE_STANDARD; + return (forceResizable || ActivityInfo.isResizeableMode(mResizeMode) || (checkSupportsPip && mSupportsPictureInPicture)); } @@ -7174,7 +7185,7 @@ class Task extends WindowContainer { ActivityRecord source, ActivityOptions options) { Task task; - if (DisplayContent.alwaysCreateStack(getWindowingMode(), getActivityType())) { + if (DisplayContent.canReuseExistingTask(getWindowingMode(), getActivityType())) { // This stack will only contain one task, so just return itself since all stacks ara now // tasks and all tasks are now stacks. task = reuseAsLeafTask(voiceSession, voiceInteractor, intent, info, activity);