Loading services/core/java/com/android/server/wm/TransparentPolicy.java +3 −2 Original line number Diff line number Diff line Loading @@ -196,10 +196,11 @@ class TransparentPolicy { // We evaluate the case when the policy should not be applied. private boolean shouldSkipTransparentPolicy(@Nullable ActivityRecord opaqueActivity) { if (opaqueActivity == null || opaqueActivity.isEmbedded()) { if (opaqueActivity == null || opaqueActivity.isEmbedded() || !opaqueActivity.areBoundsLetterboxed()) { // We skip letterboxing if the translucent activity doesn't have any // opaque activities beneath or the activity below is embedded which // never has letterbox. // never has letterbox or the activity is not letterboxed at all. return true; } final AppCompatSizeCompatModePolicy scmPolicy = mActivityRecord.mAppCompatController Loading services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java +4 −0 Original line number Diff line number Diff line Loading @@ -259,6 +259,10 @@ class AppCompatActivityRobot { doReturn(embedded).when(mActivityStack.top()).isEmbedded(); } void setTopActivityHasLetterboxedBounds(boolean letterboxed) { doReturn(letterboxed).when(mActivityStack.top()).areBoundsLetterboxed(); } void setTopActivityVisible(boolean isVisible) { doReturn(isVisible).when(mActivityStack.top()).isVisible(); } Loading services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -217,6 +217,19 @@ public class TransparentPolicyTest extends WindowTestsBase { }); } @Test public void testNotApplyStrategyToTranslucentActivitiesOverNotLetterboxedActivities() { runTestScenario((robot) -> { robot.transparentActivity((ta) -> { ta.activity().setTopActivityHasLetterboxedBounds(false); ta.launchTransparentActivityInTask(); ta.checkTopActivityTransparentPolicyStartNotInvoked(); ta.checkTopActivityTransparentPolicyStateIsRunning(/* running */ false); }); }); } @EnableFlags(com.android.window.flags.Flags.FLAG_RESPECT_NON_TOP_VISIBLE_FIXED_ORIENTATION) @Test public void testNotRunStrategyToTranslucentActivitiesIfRespectOrientation() { Loading Loading @@ -388,6 +401,7 @@ public class TransparentPolicyTest extends WindowTestsBase { mTransparentActivityRobot = new AppCompatTransparentActivityRobot(activity()); // We always create at least an opaque activity in a Task activity().createNewTaskWithBaseActivity(); activity().setTopActivityHasLetterboxedBounds(true); } @Override Loading Loading
services/core/java/com/android/server/wm/TransparentPolicy.java +3 −2 Original line number Diff line number Diff line Loading @@ -196,10 +196,11 @@ class TransparentPolicy { // We evaluate the case when the policy should not be applied. private boolean shouldSkipTransparentPolicy(@Nullable ActivityRecord opaqueActivity) { if (opaqueActivity == null || opaqueActivity.isEmbedded()) { if (opaqueActivity == null || opaqueActivity.isEmbedded() || !opaqueActivity.areBoundsLetterboxed()) { // We skip letterboxing if the translucent activity doesn't have any // opaque activities beneath or the activity below is embedded which // never has letterbox. // never has letterbox or the activity is not letterboxed at all. return true; } final AppCompatSizeCompatModePolicy scmPolicy = mActivityRecord.mAppCompatController Loading
services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java +4 −0 Original line number Diff line number Diff line Loading @@ -259,6 +259,10 @@ class AppCompatActivityRobot { doReturn(embedded).when(mActivityStack.top()).isEmbedded(); } void setTopActivityHasLetterboxedBounds(boolean letterboxed) { doReturn(letterboxed).when(mActivityStack.top()).areBoundsLetterboxed(); } void setTopActivityVisible(boolean isVisible) { doReturn(isVisible).when(mActivityStack.top()).isVisible(); } Loading
services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -217,6 +217,19 @@ public class TransparentPolicyTest extends WindowTestsBase { }); } @Test public void testNotApplyStrategyToTranslucentActivitiesOverNotLetterboxedActivities() { runTestScenario((robot) -> { robot.transparentActivity((ta) -> { ta.activity().setTopActivityHasLetterboxedBounds(false); ta.launchTransparentActivityInTask(); ta.checkTopActivityTransparentPolicyStartNotInvoked(); ta.checkTopActivityTransparentPolicyStateIsRunning(/* running */ false); }); }); } @EnableFlags(com.android.window.flags.Flags.FLAG_RESPECT_NON_TOP_VISIBLE_FIXED_ORIENTATION) @Test public void testNotRunStrategyToTranslucentActivitiesIfRespectOrientation() { Loading Loading @@ -388,6 +401,7 @@ public class TransparentPolicyTest extends WindowTestsBase { mTransparentActivityRobot = new AppCompatTransparentActivityRobot(activity()); // We always create at least an opaque activity in a Task activity().createNewTaskWithBaseActivity(); activity().setTopActivityHasLetterboxedBounds(true); } @Override Loading