summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Naomi Musgrave <nmusgrave@google.com> 2021-04-19 22:02:36 +0100
committer Naomi Musgrave <nmusgrave@google.com> 2021-04-20 19:41:36 +0100
commitc95c242f023b43dd0bd5ac62eeae040f6db54731 (patch)
treec15b3293cd73c4869d4b7e3115dd128fa6612106
parent0cd1de22269c7be1de3ea17509f04a51486eece0 (diff)
Sandbox only if an activity may enter size compat mode.
The check shouldCreateCompatDisplayInsets will catch any apps that are eligible for size compat mode, and apply sandboxing to them. If an app is in letterbox only - and is never eligible for size compat mode- then the app handles resizing and multiwindow mode. We can assume, since it has explicitly declared it is resizable, that it will use the Display size APIs correctly. This decision is consistent with test results, as well, which only shows apps in size compat mode benefiting from sandboxing. Bug: 185456980 Test: atest WmTests:SizeCompatTests Change-Id: I4b66454b3515738554c63cffe73e2f0500889cf6
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java10
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java95
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 131ba12bb3c2..b510a20c7fd3 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -7326,11 +7326,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.
@@ -7338,8 +7333,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() {