Merge "Inherit source windowing mode in some cases." am: 530fa56bc0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1412208 Change-Id: I13d8cc8acc9eb60ddcb4e8e5aa2afa6376d7e36f
This commit is contained in:
@@ -159,11 +159,23 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// STEP 2: Resolve launch windowing mode.
|
// STEP 2: Resolve launch windowing mode.
|
||||||
// STEP 2.1: Determine if any parameter has specified initial bounds. That might be the
|
// STEP 2.1: Determine if any parameter can specify initial bounds/windowing mode. That
|
||||||
// launch bounds from activity options, or size/gravity passed in layout. It also treats the
|
// might be the launch bounds from activity options, or size/gravity passed in layout. It
|
||||||
// launch windowing mode in options as a suggestion for future resolution.
|
// also treats the launch windowing mode in options and source activity windowing mode in
|
||||||
|
// some cases as a suggestion for future resolution.
|
||||||
int launchMode = options != null ? options.getLaunchWindowingMode()
|
int launchMode = options != null ? options.getLaunchWindowingMode()
|
||||||
: WINDOWING_MODE_UNDEFINED;
|
: WINDOWING_MODE_UNDEFINED;
|
||||||
|
// In some cases we want to use the source's windowing mode as the default value, e.g. when
|
||||||
|
// source is a freeform window in a fullscreen display launching an activity on the same
|
||||||
|
// display.
|
||||||
|
if (launchMode == WINDOWING_MODE_UNDEFINED
|
||||||
|
&& canInheritWindowingModeFromSource(display, source)) {
|
||||||
|
launchMode = source.getWindowingMode();
|
||||||
|
if (DEBUG) {
|
||||||
|
appendLog("inherit-from-source="
|
||||||
|
+ WindowConfiguration.windowingModeToString(launchMode));
|
||||||
|
}
|
||||||
|
}
|
||||||
// hasInitialBounds is set if either activity options or layout has specified bounds. If
|
// hasInitialBounds is set if either activity options or layout has specified bounds. If
|
||||||
// that's set we'll skip some adjustments later to avoid overriding the initial bounds.
|
// that's set we'll skip some adjustments later to avoid overriding the initial bounds.
|
||||||
boolean hasInitialBounds = false;
|
boolean hasInitialBounds = false;
|
||||||
@@ -334,6 +346,31 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
|
|||||||
? displayId : DEFAULT_DISPLAY;
|
? displayId : DEFAULT_DISPLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canInheritWindowingModeFromSource(@NonNull ActivityDisplay display,
|
||||||
|
@Nullable ActivityRecord source) {
|
||||||
|
if (source == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// There is not really any strong reason to tie the launching windowing mode and the source
|
||||||
|
// on freeform displays. The launching windowing mode is more tied to the content of the new
|
||||||
|
// activities.
|
||||||
|
if (display.inFreeformWindowingMode()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int sourceWindowingMode = source.getWindowingMode();
|
||||||
|
if (sourceWindowingMode != WINDOWING_MODE_FULLSCREEN
|
||||||
|
&& sourceWindowingMode != WINDOWING_MODE_FREEFORM) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only inherit windowing mode if both source and target activities are on the same display.
|
||||||
|
// Otherwise we may have unintended freeform windows showing up if an activity in freeform
|
||||||
|
// window launches an activity on a fullscreen display by specifying display ID.
|
||||||
|
return display.mDisplayId == source.getDisplayId();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean canApplyFreeformWindowPolicy(@NonNull ActivityDisplay display, int launchMode) {
|
private boolean canApplyFreeformWindowPolicy(@NonNull ActivityDisplay display, int launchMode) {
|
||||||
return mSupervisor.mService.mSupportsFreeformWindowManagement
|
return mSupervisor.mService.mSupportsFreeformWindowManagement
|
||||||
&& (display.inFreeformWindowingMode() || launchMode == WINDOWING_MODE_FREEFORM);
|
&& (display.inFreeformWindowingMode() || launchMode == WINDOWING_MODE_FREEFORM);
|
||||||
|
|||||||
@@ -248,6 +248,20 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
|
|||||||
WINDOWING_MODE_FULLSCREEN);
|
WINDOWING_MODE_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInheritsFreeformModeFromSourceOnFullscreenDisplay() {
|
||||||
|
final TestActivityDisplay fullscreenDisplay = createNewActivityDisplay(
|
||||||
|
WINDOWING_MODE_FULLSCREEN);
|
||||||
|
final ActivityRecord source = createSourceActivity(fullscreenDisplay);
|
||||||
|
source.setWindowingMode(WINDOWING_MODE_FREEFORM);
|
||||||
|
|
||||||
|
assertEquals(RESULT_CONTINUE, mTarget.onCalculate(/* task */ null, /* layout */ null,
|
||||||
|
mActivity, source, /* options */ null, mCurrent, mResult));
|
||||||
|
|
||||||
|
assertEquivalentWindowingMode(WINDOWING_MODE_FREEFORM, mResult.mWindowingMode,
|
||||||
|
WINDOWING_MODE_FULLSCREEN);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKeepsPictureInPictureLaunchModeInOptions() {
|
public void testKeepsPictureInPictureLaunchModeInOptions() {
|
||||||
final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
|
final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
|
||||||
@@ -557,6 +571,23 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
|
|||||||
assertEquals(expected, mResult.mBounds);
|
assertEquals(expected, mResult.mBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRespectsLaunchBoundsWithFreeformSourceOnFullscreenDisplay() {
|
||||||
|
final TestActivityDisplay fullscreenDisplay = createNewActivityDisplay(
|
||||||
|
WINDOWING_MODE_FULLSCREEN);
|
||||||
|
final ActivityRecord source = createSourceActivity(fullscreenDisplay);
|
||||||
|
source.setWindowingMode(WINDOWING_MODE_FREEFORM);
|
||||||
|
|
||||||
|
final ActivityOptions options = ActivityOptions.makeBasic();
|
||||||
|
final Rect expected = new Rect(0, 0, 150, 150);
|
||||||
|
options.setLaunchBounds(expected);
|
||||||
|
|
||||||
|
assertEquals(RESULT_CONTINUE, mTarget.onCalculate(/* task */ null, /* layout */ null,
|
||||||
|
mActivity, source, options, mCurrent, mResult));
|
||||||
|
|
||||||
|
assertEquals(expected, mResult.mBounds);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNonEmptyLayoutBoundsRespectsGravityWithEmptySize_LeftGravity() {
|
public void testNonEmptyLayoutBoundsRespectsGravityWithEmptySize_LeftGravity() {
|
||||||
final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
|
final TestActivityDisplay freeformDisplay = createNewActivityDisplay(
|
||||||
|
|||||||
Reference in New Issue
Block a user