Merge "Allow letterbox repositioning only when filling of parent dimensions" into tm-qpr-dev am: 2b7f16756b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20980720

Change-Id: I53924b029339158b5b5dee8b4d367f6845babac8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Vali Calinescu
2023-01-23 22:31:46 +00:00
committed by Automerger Merge Worker
2 changed files with 141 additions and 4 deletions

View File

@@ -724,6 +724,7 @@ final class LetterboxUiController {
* <li>Activity is portrait-only. * <li>Activity is portrait-only.
* <li>Fullscreen window in landscape device orientation. * <li>Fullscreen window in landscape device orientation.
* <li>Horizontal Reachability is enabled. * <li>Horizontal Reachability is enabled.
* <li>Activity fills parent vertically.
* </ul> * </ul>
*/ */
private boolean isHorizontalReachabilityEnabled(Configuration parentConfiguration) { private boolean isHorizontalReachabilityEnabled(Configuration parentConfiguration) {
@@ -731,10 +732,14 @@ final class LetterboxUiController {
&& parentConfiguration.windowConfiguration.getWindowingMode() && parentConfiguration.windowConfiguration.getWindowingMode()
== WINDOWING_MODE_FULLSCREEN == WINDOWING_MODE_FULLSCREEN
&& (parentConfiguration.orientation == ORIENTATION_LANDSCAPE && (parentConfiguration.orientation == ORIENTATION_LANDSCAPE
&& mActivityRecord.getOrientationForReachability() == ORIENTATION_PORTRAIT); && mActivityRecord.getOrientationForReachability() == ORIENTATION_PORTRAIT)
// Check whether the activity fills the parent vertically.
&& parentConfiguration.windowConfiguration.getBounds().height()
== mActivityRecord.getBounds().height();
} }
private boolean isHorizontalReachabilityEnabled() { @VisibleForTesting
boolean isHorizontalReachabilityEnabled() {
return isHorizontalReachabilityEnabled(mActivityRecord.getParent().getConfiguration()); return isHorizontalReachabilityEnabled(mActivityRecord.getParent().getConfiguration());
} }
@@ -746,6 +751,7 @@ final class LetterboxUiController {
* <li>Activity is landscape-only. * <li>Activity is landscape-only.
* <li>Fullscreen window in portrait device orientation. * <li>Fullscreen window in portrait device orientation.
* <li>Vertical Reachability is enabled. * <li>Vertical Reachability is enabled.
* <li>Activity fills parent horizontally.
* </ul> * </ul>
*/ */
private boolean isVerticalReachabilityEnabled(Configuration parentConfiguration) { private boolean isVerticalReachabilityEnabled(Configuration parentConfiguration) {
@@ -753,10 +759,14 @@ final class LetterboxUiController {
&& parentConfiguration.windowConfiguration.getWindowingMode() && parentConfiguration.windowConfiguration.getWindowingMode()
== WINDOWING_MODE_FULLSCREEN == WINDOWING_MODE_FULLSCREEN
&& (parentConfiguration.orientation == ORIENTATION_PORTRAIT && (parentConfiguration.orientation == ORIENTATION_PORTRAIT
&& mActivityRecord.getOrientationForReachability() == ORIENTATION_LANDSCAPE); && mActivityRecord.getOrientationForReachability() == ORIENTATION_LANDSCAPE)
// Check whether the activity fills the parent horizontally.
&& parentConfiguration.windowConfiguration.getBounds().width()
== mActivityRecord.getBounds().width();
} }
private boolean isVerticalReachabilityEnabled() { @VisibleForTesting
boolean isVerticalReachabilityEnabled() {
return isVerticalReachabilityEnabled(mActivityRecord.getParent().getConfiguration()); return isVerticalReachabilityEnabled(mActivityRecord.getParent().getConfiguration());
} }

View File

@@ -2583,6 +2583,133 @@ public class SizeCompatTests extends WindowTestsBase {
assertLetterboxSurfacesDrawnBetweenActivityAndParentBounds(organizer.mPrimary.getBounds()); assertLetterboxSurfacesDrawnBetweenActivityAndParentBounds(organizer.mPrimary.getBounds());
} }
@Test
public void testIsHorizontalReachabilityEnabled_splitScreen_false() {
mAtm.mDevEnableNonResizableMultiWindow = true;
setUpDisplaySizeWithApp(2800, 1000);
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
mWm.mLetterboxConfiguration.setIsHorizontalReachabilityEnabled(true);
final TestSplitOrganizer organizer =
new TestSplitOrganizer(mAtm, mActivity.getDisplayContent());
// Unresizable portrait-only activity.
prepareUnresizable(mActivity, 1.1f, SCREEN_ORIENTATION_PORTRAIT);
// Move activity to split screen which takes half of the screen.
mTask.reparent(organizer.mPrimary, POSITION_TOP, /* moveParents= */ false , "test");
organizer.mPrimary.setBounds(0, 0, 1400, 1000);
assertEquals(WINDOWING_MODE_MULTI_WINDOW, mTask.getWindowingMode());
assertEquals(WINDOWING_MODE_MULTI_WINDOW, mActivity.getWindowingMode());
// Horizontal reachability is disabled because the app is in split screen.
assertFalse(mActivity.mLetterboxUiController.isHorizontalReachabilityEnabled());
}
@Test
public void testIsVerticalReachabilityEnabled_splitScreen_false() {
mAtm.mDevEnableNonResizableMultiWindow = true;
setUpDisplaySizeWithApp(1000, 2800);
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
mWm.mLetterboxConfiguration.setIsVerticalReachabilityEnabled(true);
final TestSplitOrganizer organizer =
new TestSplitOrganizer(mAtm, mActivity.getDisplayContent());
// Unresizable landscape-only activity.
prepareUnresizable(mActivity, 1.1f, SCREEN_ORIENTATION_LANDSCAPE);
// Move activity to split screen which takes half of the screen.
mTask.reparent(organizer.mPrimary, POSITION_TOP, /* moveParents= */ false , "test");
organizer.mPrimary.setBounds(0, 0, 1000, 1400);
assertEquals(WINDOWING_MODE_MULTI_WINDOW, mTask.getWindowingMode());
assertEquals(WINDOWING_MODE_MULTI_WINDOW, mActivity.getWindowingMode());
// Vertical reachability is disabled because the app is in split screen.
assertFalse(mActivity.mLetterboxUiController.isVerticalReachabilityEnabled());
}
@Test
public void testIsVerticalReachabilityEnabled_doesNotMatchParentWidth_false() {
setUpDisplaySizeWithApp(1000, 2800);
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
mWm.mLetterboxConfiguration.setIsVerticalReachabilityEnabled(true);
// Unresizable landscape-only activity.
prepareUnresizable(mActivity, 1.1f, SCREEN_ORIENTATION_LANDSCAPE);
// Rotate to put activity in size compat mode.
rotateDisplay(mActivity.mDisplayContent, ROTATION_90);
// Activity now in size compat mode.
assertTrue(mActivity.inSizeCompatMode());
// Vertical reachability is disabled because the app does not match parent width
assertNotEquals(mActivity.getBounds().width(), mActivity.mDisplayContent.getBounds()
.width());
assertFalse(mActivity.mLetterboxUiController.isVerticalReachabilityEnabled());
}
@Test
public void testIsHorizontalReachabilityEnabled_doesNotMatchParentHeight_false() {
setUpDisplaySizeWithApp(2800, 1000);
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
mWm.mLetterboxConfiguration.setIsHorizontalReachabilityEnabled(true);
// Unresizable portrait-only activity.
prepareUnresizable(mActivity, 1.1f, SCREEN_ORIENTATION_PORTRAIT);
// Rotate to put activity in size compat mode.
rotateDisplay(mActivity.mDisplayContent, ROTATION_90);
// Activity now in size compat mode.
assertTrue(mActivity.inSizeCompatMode());
// Horizontal reachability is disabled because the app does not match parent height
assertNotEquals(mActivity.getBounds().height(), mActivity.mDisplayContent.getBounds()
.height());
assertFalse(mActivity.mLetterboxUiController.isHorizontalReachabilityEnabled());
}
@Test
public void testIsHorizontalReachabilityEnabled_inSizeCompatMode_matchesParentHeight_true() {
setUpDisplaySizeWithApp(1800, 2200);
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
mWm.mLetterboxConfiguration.setIsHorizontalReachabilityEnabled(true);
// Unresizable portrait-only activity.
prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);
// Rotate to put activity in size compat mode.
rotateDisplay(mActivity.mDisplayContent, ROTATION_90);
// Activity now in size compat mode.
assertTrue(mActivity.inSizeCompatMode());
// Horizontal reachability is enabled because the app matches parent height
assertEquals(mActivity.getBounds().height(), mActivity.mDisplayContent.getBounds()
.height());
assertTrue(mActivity.mLetterboxUiController.isHorizontalReachabilityEnabled());
}
@Test
public void testIsVerticalReachabilityEnabled_inSizeCompatMode_matchesParentWidth_true() {
setUpDisplaySizeWithApp(2200, 1800);
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
mWm.mLetterboxConfiguration.setIsVerticalReachabilityEnabled(true);
// Unresizable landscape-only activity.
prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE);
// Rotate to put activity in size compat mode.
rotateDisplay(mActivity.mDisplayContent, ROTATION_90);
// Activity now in size compat mode.
assertTrue(mActivity.inSizeCompatMode());
// Vertical reachability is enabled because the app matches parent width
assertEquals(mActivity.getBounds().width(), mActivity.mDisplayContent.getBounds().width());
assertTrue(mActivity.mLetterboxUiController.isVerticalReachabilityEnabled());
}
@Test @Test
public void testLetterboxDetailsForStatusBar_noLetterbox() { public void testLetterboxDetailsForStatusBar_noLetterbox() {
setUpDisplaySizeWithApp(2800, 1000); setUpDisplaySizeWithApp(2800, 1000);