diff options
| author | 2021-02-27 04:23:57 +0000 | |
|---|---|---|
| committer | 2021-02-27 04:23:57 +0000 | |
| commit | dfb9bb76fe266f79dab3430404a1063a028dcda4 (patch) | |
| tree | aacc920042eca107c3886c4425a45134e1b68672 | |
| parent | 6cd5cb738d03cc9fccd26b19c18e098d89f32b09 (diff) | |
| parent | ca3b42aea9b7cc94190c67e098512ea2ea081209 (diff) | |
Merge "Don't launch orientation-matching unresizable apps in freeform" into sc-dev
| -rw-r--r-- | services/core/java/com/android/server/wm/TaskLaunchParamsModifier.java | 52 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/TaskLaunchParamsModifierTests.java | 37 |
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); |