summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Riddle Hsu <riddlehsu@google.com> 2024-08-20 10:39:54 +0800
committer Riddle Hsu <riddlehsu@google.com> 2024-08-20 10:40:45 +0800
commitb100b4a3989eac032b8a900e4fcadaf5c9cc58d1 (patch)
tree32a1e9a69d21b1c4273f129b372fe2c2b80f7c89
parentef5d30ac3f6bb08b686622484e67b82477ec2dbb (diff)
Fix missing test condition of TransparentPolicy
These code should be included in [1], but it was dropped accidentally when rebasing patchset. This simply restores the changes. Otherwise the tests will fail when enabling the flag. [1]: Id9861c908420961efb945e36fb50a13ea4de7e8f Bug: 278097747 Flag: com.android.window.flags.respect_non_top_visible_fixed_orientation Test: atest TransparentPolicyTest Change-Id: I168e72bfbe3727b0420ae5cb77c9ae63488bd387
-rw-r--r--services/core/java/com/android/server/wm/TransparentPolicy.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java5
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java20
3 files changed, 15 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/wm/TransparentPolicy.java b/services/core/java/com/android/server/wm/TransparentPolicy.java
index 36bc84635e94..f2615f7c533d 100644
--- a/services/core/java/com/android/server/wm/TransparentPolicy.java
+++ b/services/core/java/com/android/server/wm/TransparentPolicy.java
@@ -335,6 +335,8 @@ class TransparentPolicy {
// Do not enable the policy if the activity can affect display orientation.
final int orientation = mActivityRecord.getOverrideOrientation();
return orientation == SCREEN_ORIENTATION_UNSPECIFIED
+ // This "!condition" is true if the activity is multi-window mode or the
+ // display ignores requested orientation.
|| !mActivityRecord.handlesOrientationChangeFromDescendant(orientation);
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java b/services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java
index fee9c6c002c4..8d1ba5b0704d 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java
@@ -134,11 +134,6 @@ class AppCompatActivityRobot {
isUnresizable);
}
- void configureTopActivityIgnoreOrientationRequest(boolean ignoreOrientationRequest) {
- mActivityStack.top().mDisplayContent
- .setIgnoreOrientationRequest(ignoreOrientationRequest);
- }
-
void configureUnresizableTopActivity(@ActivityInfo.ScreenOrientation int screenOrientation) {
configureTopActivity(/* minAspect */ -1, /* maxAspect */ -1, screenOrientation,
/* isUnresizable */ true);
diff --git a/services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java
index a0641cd49018..29f63609a9ed 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java
@@ -73,6 +73,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
public void testPolicyRunningWhenTransparentIsUsed() {
runTestScenario((robot) -> {
robot.transparentActivity((ta) -> {
+ ta.activity().setIgnoreOrientationRequest(true);
ta.launchTransparentActivityInTask();
ta.checkTopActivityTransparentPolicyStartNotInvoked();
@@ -85,6 +86,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
public void testCleanLetterboxConfigListenerWhenTranslucentIsDestroyed() {
runTestScenario((robot) -> {
robot.transparentActivity((ta) -> {
+ ta.activity().setIgnoreOrientationRequest(true);
ta.launchTransparentActivityInTask();
ta.checkTopActivityTransparentPolicyStartNotInvoked();
ta.checkTopActivityTransparentPolicyStateIsRunning(/* running */ true);
@@ -102,6 +104,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
public void testApplyStrategyAgainWhenOpaqueIsDestroyed() {
runTestScenario((robot) -> {
robot.transparentActivity((ta) -> {
+ ta.activity().setIgnoreOrientationRequest(true);
ta.launchOpaqueActivityInTask();
ta.checkTopActivityTransparentPolicyStateIsRunning(/* running */ false);
@@ -133,6 +136,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
public void testNotApplyStrategyAgainWhenOpaqueIsNotDestroyed() {
runTestScenario((robot) -> {
robot.transparentActivity((ta) -> {
+ ta.activity().setIgnoreOrientationRequest(true);
ta.launchOpaqueActivityInTask();
ta.checkTopActivityTransparentPolicyStateIsRunning(/* running */ false);
@@ -152,7 +156,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
ta.applyOnActivity((a) -> {
a.configureTopActivity(/* minAspect */ 1.2f, /* maxAspect */ 1.5f,
SCREEN_ORIENTATION_PORTRAIT, /* isUnresizable */ true);
- a.configureTopActivityIgnoreOrientationRequest(true);
+ a.setIgnoreOrientationRequest(true);
a.launchActivity(/* minAspect */ 1.1f, /* maxAspect */ 3f,
SCREEN_ORIENTATION_LANDSCAPE, /* transparent */true,
/* withComponent */ false, /* addToTask */true);
@@ -172,6 +176,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
public void testApplyStrategyToTransparentActivitiesRetainsWindowConfigurationProperties() {
runTestScenario((robot) -> {
robot.transparentActivity((ta) -> {
+ ta.activity().setIgnoreOrientationRequest(true);
ta.launchTransparentActivity();
ta.forceChangeInTopActivityConfiguration();
@@ -186,6 +191,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
public void testApplyStrategyToMultipleTranslucentActivities() {
runTestScenario((robot) -> {
robot.transparentActivity((ta) -> {
+ ta.activity().setIgnoreOrientationRequest(true);
ta.launchTransparentActivityInTask();
ta.checkTopActivityTransparentPolicyStateIsRunning(/* running */ true);
ta.checkTopActivityHasInheritedBoundsFrom(/* fromTop */ 1);
@@ -214,7 +220,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
@Test
public void testNotRunStrategyToTranslucentActivitiesIfRespectOrientation() {
runTestScenario(robot -> robot.transparentActivity(ta -> ta.applyOnActivity((a) -> {
- a.configureTopActivityIgnoreOrientationRequest(false);
+ a.setIgnoreOrientationRequest(false);
// The translucent activity is SCREEN_ORIENTATION_PORTRAIT.
ta.launchTransparentActivityInTask();
// Though TransparentPolicyState will be started, it won't be considered as running.
@@ -222,7 +228,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
// If the display changes to ignore orientation request, e.g. unfold, the policy should
// take effect.
- a.configureTopActivityIgnoreOrientationRequest(true);
+ a.setIgnoreOrientationRequest(true);
ta.checkTopActivityTransparentPolicyStateIsRunning(/* running */ true);
ta.setDisplayContentBounds(0, 0, 900, 1800);
ta.checkTopActivityHasInheritedBoundsFrom(/* fromTop */ 1);
@@ -234,7 +240,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
runTestScenario((robot) -> {
robot.transparentActivity((ta) -> {
ta.applyOnActivity((a) -> {
- a.configureTopActivityIgnoreOrientationRequest(true);
+ a.setIgnoreOrientationRequest(true);
a.configureUnresizableTopActivity(SCREEN_ORIENTATION_PORTRAIT);
a.rotateDisplayForTopActivity(ROTATION_90);
a.checkTopActivityInSizeCompatMode(/* inScm */ true);
@@ -257,7 +263,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
robot.transparentActivity((ta) -> {
ta.applyOnActivity((a) -> {
a.configureUnresizableTopActivity(SCREEN_ORIENTATION_PORTRAIT);
- a.configureTopActivityIgnoreOrientationRequest(true);
+ a.setIgnoreOrientationRequest(true);
ta.launchTransparentActivity();
a.assertFalseOnTopActivity(ActivityRecord::fillsParent);
@@ -284,7 +290,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
.setLetterboxHorizontalPositionMultiplier(1.0f);
});
a.configureUnresizableTopActivity(SCREEN_ORIENTATION_PORTRAIT);
- a.configureTopActivityIgnoreOrientationRequest(true);
+ a.setIgnoreOrientationRequest(true);
ta.launchTransparentActivityInTask();
ta.checkTopActivityHasInheritedBoundsFrom(/* fromTop */ 1);
@@ -309,7 +315,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
runTestScenario((robot) -> {
robot.transparentActivity((ta) -> {
ta.applyOnActivity((a) -> {
- a.configureTopActivityIgnoreOrientationRequest(true);
+ a.setIgnoreOrientationRequest(true);
a.configureUnresizableTopActivity(SCREEN_ORIENTATION_PORTRAIT);
// Rotate to put activity in size compat mode.
a.rotateDisplayForTopActivity(ROTATION_90);