summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kazuki Takise <takise@google.com> 2021-01-13 20:58:10 +0900
committer Kazuki Takise <takise@google.com> 2021-01-28 10:33:24 +0000
commitca3b42aea9b7cc94190c67e098512ea2ea081209 (patch)
treeb14df35e557c4f8052d0d9a36211dd275f1bfb03
parent0290ef235cc28bf8dce926a3a92e7a903b4ce6fb (diff)
Don't launch orientation-matching unresizable apps in freeform
TaskLaunchParamsModifier seems to handle size-compat apps and other unresizable apps in the same way, so if the develeper option for freeform size compat is enabled, normal unresizable apps are also launched in freeform, which makes some CTS fail. This CL changes this logic so that an unresizable app will be launched in freeform if and only if the orientaion of the activity doesn't match that of the freeform display. Bug: 177209298 Test: atest android.server.wm.FreeformWindowingModeTests Test: #testNonResizeableActivityHasFullDisplayBounds Change-Id: I4d220ab08360c53300f96d6391a13e7a9ee44dd9
-rw-r--r--services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java52
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java37
2 files changed, 76 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java b/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java
index 106db0b15c46..82d9c214ece7 100644
--- a/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java
+++ b/services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java
@@ -234,19 +234,28 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
}
}
- // STEP 2.3: Adjust launch parameters as needed for freeform display. We enforce the policy
- // that legacy (pre-D) apps and those apps that can't handle multiple screen density well
- // are forced to be maximized. The rest of this step is to define the default policy when
- // there is no initial bounds or a fully resolved current params from callers.
+ // STEP 2.3: Adjust launch parameters as needed for freeform display. We enforce the
+ // policies related to unresizable apps here. If an app is unresizable and the freeform
+ // size-compat mode is enabled, it can be launched in freeform depending on other properties
+ // such as orientation. Otherwise, the app is forcefully launched in maximized. The rest of
+ // this step is to define the default policy when there is no initial bounds or a fully
+ // resolved current params from callers.
if (display.inFreeformWindowingMode()) {
if (launchMode == WINDOWING_MODE_PINNED) {
if (DEBUG) appendLog("picture-in-picture");
- } else if (!mSupervisor.mService.mSizeCompatFreeform && !root.isResizeable()) {
- // We're launching an activity in size-compat mode and they aren't allowed in
- // freeform, so force it to be maximized.
- launchMode = WINDOWING_MODE_FULLSCREEN;
- outParams.mBounds.setEmpty();
- if (DEBUG) appendLog("forced-maximize");
+ } else if (!root.isResizeable()) {
+ if (shouldLaunchUnresizableAppInFreeform(root, suggestedDisplayArea)) {
+ launchMode = WINDOWING_MODE_FREEFORM;
+ if (outParams.mBounds.isEmpty()) {
+ getTaskBounds(root, display, layout, launchMode, hasInitialBounds,
+ outParams.mBounds);
+ }
+ if (DEBUG) appendLog("unresizable-freeform");
+ } else {
+ launchMode = WINDOWING_MODE_FULLSCREEN;
+ outParams.mBounds.setEmpty();
+ if (DEBUG) appendLog("unresizable-forced-maximize");
+ }
}
} else {
if (DEBUG) appendLog("non-freeform-display");
@@ -322,7 +331,6 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
}
getTaskBounds(root, display, layout, resolvedMode, hasInitialBounds, outParams.mBounds);
}
-
return RESULT_CONTINUE;
}
@@ -562,6 +570,28 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
outBounds.offset(xOffset, yOffset);
}
+ private boolean shouldLaunchUnresizableAppInFreeform(ActivityRecord activity,
+ TaskDisplayArea displayArea) {
+ // TODO(176061101): Migrate |mSizeCompatFreeform| to |mSupportsNonResizableMultiWindow|.
+ if (!mSupervisor.mService.mSizeCompatFreeform || activity.isResizeable()) {
+ return false;
+ }
+ final DisplayContent display = displayArea.getDisplayContent();
+ if (display == null) {
+ return false;
+ }
+
+ final int displayOrientation = orientationFromBounds(displayArea.getBounds());
+ final int activityOrientation = resolveOrientation(activity, display,
+ displayArea.getBounds());
+ if (displayArea.getWindowingMode() == WINDOWING_MODE_FREEFORM
+ && displayOrientation != activityOrientation) {
+ return true;
+ }
+
+ return false;
+ }
+
/**
* Resolves activity requested orientation to 4 categories:
* 1) {@link ActivityInfo#SCREEN_ORIENTATION_LOCKED} indicating app wants to lock down
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
index 49847992125e..f8346efba06d 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java
@@ -683,12 +683,12 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
}
@Test
- public void testLaunchesAppInWindowOnFreeformDisplay() {
+ public void testLaunchesPortraitSizeCompatOnFreeformLandscapeDisplayWithFreeformSizeCompat() {
mAtm.mSizeCompatFreeform = true;
final TestDisplayContent freeformDisplay = createNewDisplayContent(
WINDOWING_MODE_FREEFORM);
- Rect expectedLaunchBounds = new Rect(0, 0, 200, 100);
+ Rect expectedLaunchBounds = new Rect(0, 0, 100, 200);
final ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchWindowingMode(WINDOWING_MODE_FREEFORM);
@@ -699,6 +699,7 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
mCurrent.mBounds.set(expectedLaunchBounds);
mActivity.info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
+ mActivity.info.screenOrientation = SCREEN_ORIENTATION_PORTRAIT;
assertEquals(RESULT_CONTINUE,
new CalculateRequestBuilder().setOptions(options).calculate());
@@ -710,6 +711,38 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
}
@Test
+ public void testLaunchesLandscapeSizeCompatOnFreeformLandscapeDisplayWithFreeformSizeCompat() {
+ mAtm.mSizeCompatFreeform = true;
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
+ WINDOWING_MODE_FREEFORM);
+ final ActivityOptions options = ActivityOptions.makeBasic();
+ mCurrent.mPreferredTaskDisplayArea = freeformDisplay.getDefaultTaskDisplayArea();
+ mActivity.info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
+ mActivity.info.screenOrientation = SCREEN_ORIENTATION_LANDSCAPE;
+ assertEquals(RESULT_CONTINUE,
+ new CalculateRequestBuilder().setOptions(options).calculate());
+
+ assertEquivalentWindowingMode(WINDOWING_MODE_FULLSCREEN, mResult.mWindowingMode,
+ WINDOWING_MODE_FREEFORM);
+ }
+
+ @Test
+ public void testLaunchesPortraitUnresizableOnFreeformDisplayWithFreeformSizeCompat() {
+ mAtm.mSizeCompatFreeform = true;
+ final TestDisplayContent freeformDisplay = createNewDisplayContent(
+ WINDOWING_MODE_FREEFORM);
+ final ActivityOptions options = ActivityOptions.makeBasic();
+ mCurrent.mPreferredTaskDisplayArea = freeformDisplay.getDefaultTaskDisplayArea();
+ mActivity.info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
+ mActivity.info.screenOrientation = SCREEN_ORIENTATION_PORTRAIT;
+ assertEquals(RESULT_CONTINUE,
+ new CalculateRequestBuilder().setOptions(options).calculate());
+
+ assertEquivalentWindowingMode(WINDOWING_MODE_FREEFORM, mResult.mWindowingMode,
+ WINDOWING_MODE_FREEFORM);
+ }
+
+ @Test
public void testSkipsForceMaximizingAppsOnNonFreeformDisplay() {
final ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchWindowingMode(WINDOWING_MODE_FREEFORM);