Merge "Respect previously resolved size if layout has no size value" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1a852b8969
@@ -180,6 +180,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
|
||||
} else if (launchMode == WINDOWING_MODE_FULLSCREEN) {
|
||||
if (DEBUG) appendLog("activity-options-fullscreen=" + outParams.mBounds);
|
||||
} else if (layout != null && canApplyFreeformPolicy) {
|
||||
mTmpBounds.set(currentParams.mBounds);
|
||||
getLayoutBounds(display, root, layout, mTmpBounds);
|
||||
if (!mTmpBounds.isEmpty()) {
|
||||
launchMode = WINDOWING_MODE_FREEFORM;
|
||||
@@ -500,11 +501,11 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
|
||||
}
|
||||
|
||||
private void getLayoutBounds(@NonNull DisplayContent display, @NonNull ActivityRecord root,
|
||||
@NonNull ActivityInfo.WindowLayout windowLayout, @NonNull Rect outBounds) {
|
||||
@NonNull ActivityInfo.WindowLayout windowLayout, @NonNull Rect inOutBounds) {
|
||||
final int verticalGravity = windowLayout.gravity & Gravity.VERTICAL_GRAVITY_MASK;
|
||||
final int horizontalGravity = windowLayout.gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
|
||||
if (!windowLayout.hasSpecifiedSize() && verticalGravity == 0 && horizontalGravity == 0) {
|
||||
outBounds.setEmpty();
|
||||
inOutBounds.setEmpty();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -518,11 +519,17 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
|
||||
int width;
|
||||
int height;
|
||||
if (!windowLayout.hasSpecifiedSize()) {
|
||||
outBounds.setEmpty();
|
||||
getTaskBounds(root, display, windowLayout, WINDOWING_MODE_FREEFORM,
|
||||
/* hasInitialBounds */ false, outBounds);
|
||||
width = outBounds.width();
|
||||
height = outBounds.height();
|
||||
if (!inOutBounds.isEmpty()) {
|
||||
// If the bounds is resolved already and WindowLayout doesn't have any opinion on
|
||||
// its size, use the already resolved size and apply the gravity to it.
|
||||
width = inOutBounds.width();
|
||||
height = inOutBounds.height();
|
||||
} else {
|
||||
getTaskBounds(root, display, windowLayout, WINDOWING_MODE_FREEFORM,
|
||||
/* hasInitialBounds */ false, inOutBounds);
|
||||
width = inOutBounds.width();
|
||||
height = inOutBounds.height();
|
||||
}
|
||||
} else {
|
||||
width = defaultWidth;
|
||||
if (windowLayout.width > 0 && windowLayout.width < defaultWidth) {
|
||||
@@ -563,11 +570,11 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
|
||||
fractionOfVerticalOffset = 0.5f;
|
||||
}
|
||||
|
||||
outBounds.set(0, 0, width, height);
|
||||
outBounds.offset(displayStableBounds.left, displayStableBounds.top);
|
||||
inOutBounds.set(0, 0, width, height);
|
||||
inOutBounds.offset(displayStableBounds.left, displayStableBounds.top);
|
||||
final int xOffset = (int) (fractionOfHorizontalOffset * (defaultWidth - width));
|
||||
final int yOffset = (int) (fractionOfVerticalOffset * (defaultHeight - height));
|
||||
outBounds.offset(xOffset, yOffset);
|
||||
inOutBounds.offset(xOffset, yOffset);
|
||||
}
|
||||
|
||||
private boolean shouldLaunchUnresizableAppInFreeform(ActivityRecord activity,
|
||||
|
||||
@@ -521,6 +521,7 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
|
||||
WINDOWING_MODE_FULLSCREEN);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testKeepsPictureInPictureLaunchModeInOptions() {
|
||||
final TestDisplayContent freeformDisplay = createNewDisplayContent(
|
||||
@@ -588,11 +589,14 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonEmptyLayoutInfersFreeformWithEmptySize() {
|
||||
public void testLayoutWithGravityAndEmptySizeInfersFreeformAndRespectsCurrentSize() {
|
||||
final TestDisplayContent freeformDisplay = createNewDisplayContent(
|
||||
WINDOWING_MODE_FREEFORM);
|
||||
|
||||
final Rect expectedLaunchBounds = new Rect(0, 0, 200, 100);
|
||||
|
||||
mCurrent.mPreferredTaskDisplayArea = freeformDisplay.getDefaultTaskDisplayArea();
|
||||
mCurrent.mBounds.set(expectedLaunchBounds);
|
||||
|
||||
final ActivityInfo.WindowLayout layout = new WindowLayoutBuilder()
|
||||
.setGravity(Gravity.LEFT).build();
|
||||
@@ -600,6 +604,9 @@ public class TaskLaunchParamsModifierTests extends WindowTestsBase {
|
||||
assertEquals(RESULT_CONTINUE,
|
||||
new CalculateRequestBuilder().setLayout(layout).calculate());
|
||||
|
||||
assertEquals(expectedLaunchBounds.width(), mResult.mBounds.width());
|
||||
assertEquals(expectedLaunchBounds.height(), mResult.mBounds.height());
|
||||
|
||||
assertEquivalentWindowingMode(WINDOWING_MODE_FREEFORM, mResult.mWindowingMode,
|
||||
WINDOWING_MODE_FREEFORM);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user