diff --git a/services/core/java/com/android/server/wm/LetterboxUiController.java b/services/core/java/com/android/server/wm/LetterboxUiController.java index 67e188fa90454..d2f62da0b26f5 100644 --- a/services/core/java/com/android/server/wm/LetterboxUiController.java +++ b/services/core/java/com/android/server/wm/LetterboxUiController.java @@ -724,6 +724,7 @@ final class LetterboxUiController { *
  • Activity is portrait-only. *
  • Fullscreen window in landscape device orientation. *
  • Horizontal Reachability is enabled. + *
  • Activity fills parent vertically. * */ private boolean isHorizontalReachabilityEnabled(Configuration parentConfiguration) { @@ -731,10 +732,14 @@ final class LetterboxUiController { && parentConfiguration.windowConfiguration.getWindowingMode() == WINDOWING_MODE_FULLSCREEN && (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()); } @@ -746,6 +751,7 @@ final class LetterboxUiController { *
  • Activity is landscape-only. *
  • Fullscreen window in portrait device orientation. *
  • Vertical Reachability is enabled. + *
  • Activity fills parent horizontally. * */ private boolean isVerticalReachabilityEnabled(Configuration parentConfiguration) { @@ -753,10 +759,14 @@ final class LetterboxUiController { && parentConfiguration.windowConfiguration.getWindowingMode() == WINDOWING_MODE_FULLSCREEN && (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()); } diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java index e5ff91f1ba373..de0999f7e8981 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -2583,6 +2583,133 @@ public class SizeCompatTests extends WindowTestsBase { 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 public void testLetterboxDetailsForStatusBar_noLetterbox() { setUpDisplaySizeWithApp(2800, 1000);