Merge "Don't launch orientation-matching unresizable apps in freeform" into sc-dev
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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());
|
||||
@@ -709,6 +710,38 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
|
||||
WINDOWING_MODE_FREEFORM);
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
Reference in New Issue
Block a user