diff options
| author | 2021-04-21 09:16:07 +0000 | |
|---|---|---|
| committer | 2021-04-21 09:16:07 +0000 | |
| commit | c4c761c36cdef8a5919d5087ed9d6eb51992e9ad (patch) | |
| tree | f0034aa324d274fb9f8f24894d87b4e52b25fc5b | |
| parent | 062b61f2de442a876ddcee30b120b6bab18fb8f9 (diff) | |
| parent | c95c242f023b43dd0bd5ac62eeae040f6db54731 (diff) | |
Merge "Sandbox only if an activity may enter size compat mode." into sc-dev
| -rw-r--r-- | services/core/java/com/android/server/wm/ActivityRecord.java | 10 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java | 95 |
2 files changed, 93 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 3988043c0aef..5dd8f74e0570 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -7318,11 +7318,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (info != null && info.alwaysSandboxDisplayApis()) { return true; } - // Max bounds should be sandboxed where an activity is letterboxed (activity bounds will be - // smaller than task bounds). - if (!matchParentBounds()) { - return true; - } // Max bounds should be sandboxed when an activity should have compatDisplayInsets, and it // will keep the same bounds and screen configuration when it was first launched regardless // how its parent window changes, so that the sandbox API will provide a consistent result. @@ -7330,8 +7325,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return true; } - // No need to sandbox for resizable apps in multi-window because resizableActivity=true - // indicates that they support multi-window. + // No need to sandbox for resizable apps in (including in multi-window) because + // resizableActivity=true indicates that they support multi-window. Likewise, do not sandbox + // for activities in letterbox since the activity has declared it can handle resizing. return false; } 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 45818a2b3bbc..221c8b97238d 100644 --- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java @@ -1252,9 +1252,11 @@ public class SizeCompatTests extends WindowTestsBase { // Task and display bounds should be equal while activity should be letterboxed and // has 700x1400 bounds with the ratio as the display. - assertTrue(mActivity.isLetterboxedForFixedOrientationAndAspectRatio()); + assertTrue(newActivity.isLetterboxedForFixedOrientationAndAspectRatio()); assertFalse(newActivity.inSizeCompatMode()); - assertActivityMaxBoundsSandboxed(); + // Activity max bounds are sandboxed due to size compat mode. + assertThat(newActivity.getConfiguration().windowConfiguration.getMaxBounds()) + .isEqualTo(newActivity.getWindowConfiguration().getBounds()); assertEquals(taskBounds, displayBounds); assertEquals(displayBounds.height(), newActivityBounds.height()); assertEquals(displayBounds.height() * displayBounds.height() / displayBounds.width(), @@ -1412,7 +1414,7 @@ public class SizeCompatTests extends WindowTestsBase { } @Test - public void testSandboxDisplayApis_letterboxAppNotSandboxed() { + public void testSandboxDisplayApis_unresizableAppNotSandboxed() { // Set up a display in landscape with an unresizable app. setUpDisplaySizeWithApp(2500, 1000); mActivity.mDisplayContent.setSandboxDisplayApis(false /* sandboxDisplayApis */); @@ -1420,11 +1422,11 @@ public class SizeCompatTests extends WindowTestsBase { assertFitted(); // Activity max bounds not be sandboxed since sandboxing is disabled. - assertThat(mActivity.getMaxBounds()).isEqualTo(mActivity.mDisplayContent.getBounds()); + assertMaxBoundsInheritDisplayAreaBounds(); } @Test - public void testSandboxDisplayApis_letterboxAppSandboxed() { + public void testSandboxDisplayApis_unresizableAppSandboxed() { // Set up a display in landscape with an unresizable app. setUpDisplaySizeWithApp(2500, 1000); mActivity.mDisplayContent.setSandboxDisplayApis(true /* sandboxDisplayApis */); @@ -1435,6 +1437,89 @@ public class SizeCompatTests extends WindowTestsBase { assertActivityMaxBoundsSandboxed(); } + @Test + public void testResizableApp_notSandboxed() { + // Set up a display in landscape with a fully resizable app. + setUpDisplaySizeWithApp(2500, 1000); + prepareLimitedBounds(mActivity, /* maxAspect= */ -1, + SCREEN_ORIENTATION_UNSPECIFIED, /* isUnresizable= */ false); + assertFitted(); + + // Activity max bounds not be sandboxed since app is fully resizable. + assertMaxBoundsInheritDisplayAreaBounds(); + } + + @Test + public void testResizableMaxAspectApp_notSandboxed() { + // Set up a display in landscape with a fully resizable app. + setUpDisplaySizeWithApp(2500, 1000); + prepareLimitedBounds(mActivity, /* maxAspect= */ 1, + SCREEN_ORIENTATION_UNSPECIFIED, /* isUnresizable= */ false); + assertFitted(); + + // Activity max bounds not be sandboxed since app is fully resizable. + assertMaxBoundsInheritDisplayAreaBounds(); + } + + @Test + public void testResizableOrientationRequestApp_notSandboxed() { + // Set up a display in landscape with a fully resizable app. + setUpDisplaySizeWithApp(2500, 1000); + prepareLimitedBounds(mActivity, /* maxAspect= */ -1, + SCREEN_ORIENTATION_PORTRAIT, /* isUnresizable= */ false); + mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + assertFitted(); + + // Activity max bounds not be sandboxed since app is fully resizable. + assertMaxBoundsInheritDisplayAreaBounds(); + } + + @Test + public void testResizableMaxAspectOrientationRequestApp_notSandboxed() { + // Set up a display in landscape with a fully resizable app. + setUpDisplaySizeWithApp(2500, 1000); + prepareLimitedBounds(mActivity, /* maxAspect= */ 1, + SCREEN_ORIENTATION_PORTRAIT, /* isUnresizable= */ false); + mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */); + assertFitted(); + + // Activity max bounds not be sandboxed since app is fully resizable. + assertMaxBoundsInheritDisplayAreaBounds(); + } + + @Test + public void testUnresizableApp_isSandboxed() { + // Set up a display in landscape with a fully resizable app. + setUpDisplaySizeWithApp(2500, 1000); + prepareLimitedBounds(mActivity, /* maxAspect= */ -1, + SCREEN_ORIENTATION_UNSPECIFIED, /* isUnresizable= */ true); + assertFitted(); + + // Activity max bounds are sandboxed since app may enter size compat mode. + assertActivityMaxBoundsSandboxed(); + assertFalse(mActivity.inSizeCompatMode()); + } + + @Test + public void testUnresizableMaxAspectApp_isSandboxed() { + // Set up a display in landscape with a fully resizable app. + setUpDisplaySizeWithApp(2500, 1000); + prepareLimitedBounds(mActivity, /* maxAspect= */ 1, + SCREEN_ORIENTATION_UNSPECIFIED, /* isUnresizable= */ true); + assertFitted(); + + // Activity max bounds are sandboxed since app may enter size compat mode. + assertActivityMaxBoundsSandboxed(); + assertFalse(mActivity.inSizeCompatMode()); + assertTrue(mActivity.shouldCreateCompatDisplayInsets()); + + // Resize display to half the width. + resizeDisplay(mActivity.getDisplayContent(), 500, 1000); + + // Activity now in size compat mode. + assertActivityMaxBoundsSandboxed(); + assertTrue(mActivity.inSizeCompatMode()); + } @Test public void testTaskDisplayAreaNotFillDisplay() { |