From 8dd1f858efb07e5d57b762de915e37c564597b9d Mon Sep 17 00:00:00 2001 From: Massimo Carli Date: Wed, 14 Jun 2023 12:38:50 +0000 Subject: [PATCH] [3/n] Improve LetterboxConfiguration readability Improve readability of isCameraCompatTreatmentEnabled() and isDisplayRotationImmersiveAppCompatPolicyEnabled() in case we need to access their build time values. Fix: 287210791 Test: atest WmTests:DisplayRotationCompatPolicyTests atest WmTests:DisplayRotationImmersiveAppCompatPolicyTests atest WmTests:LetterboxUiControllerTest Change-Id: I0ae4494025e1a4ba46ef91c8d4f1920b03caf333 --- .../com/android/server/wm/DisplayContent.java | 3 +- .../wm/DisplayRotationCompatPolicy.java | 3 +- ...splayRotationImmersiveAppCompatPolicy.java | 5 +-- .../server/wm/LetterboxConfiguration.java | 44 +++++++++++------- .../server/wm/LetterboxUiController.java | 15 +++---- .../wm/DisplayRotationCompatPolicyTests.java | 12 ++--- ...RotationImmersiveAppCompatPolicyTests.java | 12 ++--- .../server/wm/LetterboxUiControllerTest.java | 45 +++++++++++-------- 8 files changed, 75 insertions(+), 64 deletions(-) diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index ef19eef227942..2dc133f060ff2 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -1214,8 +1214,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp mDisplayRotationCompatPolicy = // Not checking DeviceConfig value here to allow enabling via DeviceConfig // without the need to restart the device. - mWmService.mLetterboxConfiguration.isCameraCompatTreatmentEnabled( - /* checkDeviceConfig */ false) + mWmService.mLetterboxConfiguration.isCameraCompatTreatmentEnabledAtBuildTime() ? new DisplayRotationCompatPolicy(this) : null; mRotationReversionController = new DisplayRotationReversionController(this); diff --git a/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java b/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java index 2b34bb22729dc..f96f99d500533 100644 --- a/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java @@ -336,8 +336,7 @@ final class DisplayRotationCompatPolicy { * */ private boolean isTreatmentEnabledForDisplay() { - return mWmService.mLetterboxConfiguration.isCameraCompatTreatmentEnabled( - /* checkDeviceConfig */ true) + return mWmService.mLetterboxConfiguration.isCameraCompatTreatmentEnabled() && mDisplayContent.getIgnoreOrientationRequest() // TODO(b/225928882): Support camera compat rotation for external displays && mDisplayContent.getDisplay().getType() == TYPE_INTERNAL; diff --git a/services/core/java/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicy.java b/services/core/java/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicy.java index 74494ddd9f593..de70c4df7985b 100644 --- a/services/core/java/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicy.java @@ -44,7 +44,7 @@ final class DisplayRotationImmersiveAppCompatPolicy { @NonNull final DisplayRotation displayRotation, @NonNull final DisplayContent displayContent) { if (!letterboxConfiguration - .isDisplayRotationImmersiveAppCompatPolicyEnabled(/* checkDeviceConfig */ false)) { + .isDisplayRotationImmersiveAppCompatPolicyEnabledAtBuildTime()) { return null; } @@ -87,8 +87,7 @@ final class DisplayRotationImmersiveAppCompatPolicy { * @return {@code true}, if there is a need to lock screen rotation, {@code false} otherwise. */ boolean isRotationLockEnforced(@Surface.Rotation final int proposedRotation) { - if (!mLetterboxConfiguration.isDisplayRotationImmersiveAppCompatPolicyEnabled( - /* checkDeviceConfig */ true)) { + if (!mLetterboxConfiguration.isDisplayRotationImmersiveAppCompatPolicyEnabled()) { return false; } synchronized (mDisplayContent.mWmService.mGlobalLock) { diff --git a/services/core/java/com/android/server/wm/LetterboxConfiguration.java b/services/core/java/com/android/server/wm/LetterboxConfiguration.java index cfb9534b558ea..09cd6a5aa688d 100644 --- a/services/core/java/com/android/server/wm/LetterboxConfiguration.java +++ b/services/core/java/com/android/server/wm/LetterboxConfiguration.java @@ -1125,15 +1125,19 @@ final class LetterboxConfiguration { } /** - * Whether camera compatibility treatment is enabled. - * - * @param checkDeviceConfig whether it should check both build time flag and a dynamic property - * from {@link DeviceConfig} or only build time flag value. + * @return Whether camera compatibility treatment is currently enabled. */ - boolean isCameraCompatTreatmentEnabled(boolean checkDeviceConfig) { - return mDeviceConfig.isBuildTimeFlagEnabled(KEY_ENABLE_CAMERA_COMPAT_TREATMENT) - && (!checkDeviceConfig - || mDeviceConfig.getFlagValue(KEY_ENABLE_CAMERA_COMPAT_TREATMENT)); + boolean isCameraCompatTreatmentEnabled() { + return mDeviceConfig.getFlagValue(KEY_ENABLE_CAMERA_COMPAT_TREATMENT); + } + + /** + * @return Whether camera compatibility treatment is enabled at build time. This is used when + * we need to safely initialize a component before the {@link DeviceConfig} flag value is + * available. + */ + boolean isCameraCompatTreatmentEnabledAtBuildTime() { + return mDeviceConfig.isBuildTimeFlagEnabled(KEY_ENABLE_CAMERA_COMPAT_TREATMENT); } /** Whether camera compatibility refresh is enabled. */ @@ -1179,20 +1183,28 @@ final class LetterboxConfiguration { /** * Checks whether rotation compat policy for immersive apps that prevents auto rotation - * into non-optimal screen orientation while in fullscreen is enabled. + * into non-optimal screen orientation while in fullscreen is enabled at build time. This is + * used when we need to safely initialize a component before the {@link DeviceConfig} flag + * value is available. * *

This is needed because immersive apps, such as games, are often not optimized for all * orientations and can have a poor UX when rotated. Additionally, some games rely on sensors * for the gameplay so users can trigger such rotations accidentally when auto rotation is on. - * - * @param checkDeviceConfig whether it should check both build time flag and a dynamic property - * from {@link DeviceConfig} or only build time flag value. */ - boolean isDisplayRotationImmersiveAppCompatPolicyEnabled(final boolean checkDeviceConfig) { + boolean isDisplayRotationImmersiveAppCompatPolicyEnabledAtBuildTime() { return mDeviceConfig.isBuildTimeFlagEnabled( - KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY) && (!checkDeviceConfig - || mDeviceConfig.getFlagValue( - KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY)); + KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY); } + /** + * Checks whether rotation compat policy for immersive apps that prevents auto rotation + * into non-optimal screen orientation while in fullscreen is currently enabled. + * + *

This is needed because immersive apps, such as games, are often not optimized for all + * orientations and can have a poor UX when rotated. Additionally, some games rely on sensors + * for the gameplay so users can trigger such rotations accidentally when auto rotation is on. + */ + boolean isDisplayRotationImmersiveAppCompatPolicyEnabled() { + return mDeviceConfig.getFlagValue(KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY); + } } diff --git a/services/core/java/com/android/server/wm/LetterboxUiController.java b/services/core/java/com/android/server/wm/LetterboxUiController.java index c2439888db435..a816838293961 100644 --- a/services/core/java/com/android/server/wm/LetterboxUiController.java +++ b/services/core/java/com/android/server/wm/LetterboxUiController.java @@ -294,18 +294,15 @@ final class LetterboxUiController { PROPERTY_COMPAT_ENABLE_FAKE_FOCUS); mBooleanPropertyCameraCompatAllowForceRotation = readComponentProperty(packageManager, mActivityRecord.packageName, - () -> mLetterboxConfiguration.isCameraCompatTreatmentEnabled( - /* checkDeviceConfig */ true), + () -> mLetterboxConfiguration.isCameraCompatTreatmentEnabled(), PROPERTY_CAMERA_COMPAT_ALLOW_FORCE_ROTATION); mBooleanPropertyCameraCompatAllowRefresh = readComponentProperty(packageManager, mActivityRecord.packageName, - () -> mLetterboxConfiguration.isCameraCompatTreatmentEnabled( - /* checkDeviceConfig */ true), + () -> mLetterboxConfiguration.isCameraCompatTreatmentEnabled(), PROPERTY_CAMERA_COMPAT_ALLOW_REFRESH); mBooleanPropertyCameraCompatEnableRefreshViaPause = readComponentProperty(packageManager, mActivityRecord.packageName, - () -> mLetterboxConfiguration.isCameraCompatTreatmentEnabled( - /* checkDeviceConfig */ true), + () -> mLetterboxConfiguration.isCameraCompatTreatmentEnabled(), PROPERTY_CAMERA_COMPAT_ENABLE_REFRESH_VIA_PAUSE); mBooleanPropertyAllowOrientationOverride = @@ -697,7 +694,7 @@ final class LetterboxUiController { boolean shouldRefreshActivityForCameraCompat() { return shouldEnableWithOptOutOverrideAndProperty( /* gatingCondition */ () -> mLetterboxConfiguration - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true), + .isCameraCompatTreatmentEnabled(), mIsOverrideCameraCompatDisableRefreshEnabled, mBooleanPropertyCameraCompatAllowRefresh); } @@ -719,7 +716,7 @@ final class LetterboxUiController { boolean shouldRefreshActivityViaPauseForCameraCompat() { return shouldEnableWithOverrideAndProperty( /* gatingCondition */ () -> mLetterboxConfiguration - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true), + .isCameraCompatTreatmentEnabled(), mIsOverrideCameraCompatEnableRefreshViaPauseEnabled, mBooleanPropertyCameraCompatEnableRefreshViaPause); } @@ -738,7 +735,7 @@ final class LetterboxUiController { boolean shouldForceRotateForCameraCompat() { return shouldEnableWithOptOutOverrideAndProperty( /* gatingCondition */ () -> mLetterboxConfiguration - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true), + .isCameraCompatTreatmentEnabled(), mIsOverrideCameraCompatDisableForceRotationEnabled, mBooleanPropertyCameraCompatAllowForceRotation); } diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationCompatPolicyTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationCompatPolicyTests.java index 8e015d4d228da..769a309cf5a7f 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationCompatPolicyTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationCompatPolicyTests.java @@ -103,8 +103,7 @@ public final class DisplayRotationCompatPolicyTests extends WindowTestsBase { public void setUp() throws Exception { mLetterboxConfiguration = mDisplayContent.mWmService.mLetterboxConfiguration; spyOn(mLetterboxConfiguration); - when(mLetterboxConfiguration.isCameraCompatTreatmentEnabled( - /* checkDeviceConfig */ anyBoolean())) + when(mLetterboxConfiguration.isCameraCompatTreatmentEnabled()) .thenReturn(true); when(mLetterboxConfiguration.isCameraCompatRefreshEnabled()) .thenReturn(true); @@ -177,8 +176,7 @@ public final class DisplayRotationCompatPolicyTests extends WindowTestsBase { @Test public void testOnScreenRotationAnimationFinished_treatmentNotEnabled_doNotShowToast() { - when(mLetterboxConfiguration.isCameraCompatTreatmentEnabled( - /* checkDeviceConfig */ anyBoolean())) + when(mLetterboxConfiguration.isCameraCompatTreatmentEnabled()) .thenReturn(false); spyOn(mDisplayRotationCompatPolicy); @@ -238,8 +236,7 @@ public final class DisplayRotationCompatPolicyTests extends WindowTestsBase { @Test public void testTreatmentNotEnabled_noForceRotationOrRefresh() throws Exception { - when(mLetterboxConfiguration.isCameraCompatTreatmentEnabled( - /* checkDeviceConfig */ anyBoolean())) + when(mLetterboxConfiguration.isCameraCompatTreatmentEnabled()) .thenReturn(false); configureActivity(SCREEN_ORIENTATION_PORTRAIT); @@ -253,8 +250,7 @@ public final class DisplayRotationCompatPolicyTests extends WindowTestsBase { @Test public void testTreatmentDisabledViaDeviceConfig_noForceRotationOrRefresh() throws Exception { - when(mLetterboxConfiguration.isCameraCompatTreatmentEnabled( - /* checkDeviceConfig */ true)) + when(mLetterboxConfiguration.isCameraCompatTreatmentEnabled()) .thenReturn(false); configureActivity(SCREEN_ORIENTATION_PORTRAIT); diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicyTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicyTests.java index d29b18f89f770..b1057032eb362 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicyTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicyTests.java @@ -31,7 +31,6 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.when; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.anyBoolean; import android.platform.test.annotations.Presubmit; import android.view.Surface; @@ -79,8 +78,11 @@ public class DisplayRotationImmersiveAppCompatPolicyTests extends WindowTestsBas when(mDisplayContent.getIgnoreOrientationRequest()).thenReturn(true); mMockLetterboxConfiguration = mock(LetterboxConfiguration.class); - when(mMockLetterboxConfiguration.isDisplayRotationImmersiveAppCompatPolicyEnabled( - /* checkDeviceConfig */ anyBoolean())).thenReturn(true); + when(mMockLetterboxConfiguration.isDisplayRotationImmersiveAppCompatPolicyEnabled()) + .thenReturn(true); + when(mMockLetterboxConfiguration + .isDisplayRotationImmersiveAppCompatPolicyEnabledAtBuildTime()) + .thenReturn(true); mPolicy = DisplayRotationImmersiveAppCompatPolicy.createIfNeeded( mMockLetterboxConfiguration, createDisplayRotationMock(), @@ -204,8 +206,8 @@ public class DisplayRotationImmersiveAppCompatPolicyTests extends WindowTestsBas @Test public void testRotationChoiceEnforcedOnly_featureFlagDisabled_lockNotEnforced() { - when(mMockLetterboxConfiguration.isDisplayRotationImmersiveAppCompatPolicyEnabled( - /* checkDeviceConfig */ true)).thenReturn(false); + when(mMockLetterboxConfiguration.isDisplayRotationImmersiveAppCompatPolicyEnabled()) + .thenReturn(false); assertIsRotationLockEnforcedReturnsFalseForAllRotations(); } diff --git a/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java index 34a13bfa855cc..81a37943505f2 100644 --- a/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java @@ -63,7 +63,6 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.verify; @@ -147,7 +146,9 @@ public class LetterboxUiControllerTest extends WindowTestsBase { @Test @EnableCompatChanges({OVERRIDE_ENABLE_COMPAT_IGNORE_REQUESTED_ORIENTATION}) public void testShouldIgnoreRequestedOrientation_cameraCompatTreatment_returnsTrue() { - doReturn(true).when(mLetterboxConfiguration).isCameraCompatTreatmentEnabled(anyBoolean()); + doReturn(true).when(mLetterboxConfiguration).isCameraCompatTreatmentEnabled(); + doReturn(true).when(mLetterboxConfiguration) + .isCameraCompatTreatmentEnabledAtBuildTime(); // Recreate DisplayContent with DisplayRotationCompatPolicy mActivity = setUpActivityWithComponent(); @@ -306,7 +307,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { @Test public void testShouldRefreshActivityForCameraCompat_flagIsDisabled_returnsFalse() { doReturn(false).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); assertFalse(mController.shouldRefreshActivityForCameraCompat()); } @@ -315,7 +316,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { @EnableCompatChanges({OVERRIDE_CAMERA_COMPAT_DISABLE_REFRESH}) public void testShouldRefreshActivityForCameraCompat_overrideEnabled_returnsFalse() { doReturn(true).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); assertFalse(mController.shouldRefreshActivityForCameraCompat()); } @@ -325,7 +326,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { public void testShouldRefreshActivityForCameraCompat_propertyIsTrueAndOverride_returnsFalse() throws Exception { doReturn(true).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); mockThatProperty(PROPERTY_CAMERA_COMPAT_ALLOW_REFRESH, /* value */ true); mController = new LetterboxUiController(mWm, mActivity); @@ -337,7 +338,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { public void testShouldRefreshActivityForCameraCompat_propertyIsFalse_returnsFalse() throws Exception { doReturn(true).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); mockThatProperty(PROPERTY_CAMERA_COMPAT_ALLOW_REFRESH, /* value */ false); mController = new LetterboxUiController(mWm, mActivity); @@ -349,7 +350,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { public void testShouldRefreshActivityForCameraCompat_propertyIsTrue_returnsTrue() throws Exception { doReturn(true).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); mockThatProperty(PROPERTY_CAMERA_COMPAT_ALLOW_REFRESH, /* value */ true); mController = new LetterboxUiController(mWm, mActivity); @@ -363,7 +364,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { @EnableCompatChanges({OVERRIDE_CAMERA_COMPAT_ENABLE_REFRESH_VIA_PAUSE}) public void testShouldRefreshActivityViaPauseForCameraCompat_flagIsDisabled_returnsFalse() { doReturn(false).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); assertFalse(mController.shouldRefreshActivityViaPauseForCameraCompat()); } @@ -372,7 +373,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { @EnableCompatChanges({OVERRIDE_CAMERA_COMPAT_ENABLE_REFRESH_VIA_PAUSE}) public void testShouldRefreshActivityViaPauseForCameraCompat_overrideEnabled_returnsTrue() { doReturn(true).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); assertTrue(mController.shouldRefreshActivityViaPauseForCameraCompat()); } @@ -382,7 +383,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { public void testShouldRefreshActivityViaPauseForCameraCompat_propertyIsFalseAndOverride_returnFalse() throws Exception { doReturn(true).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); mockThatProperty(PROPERTY_CAMERA_COMPAT_ENABLE_REFRESH_VIA_PAUSE, /* value */ false); mController = new LetterboxUiController(mWm, mActivity); @@ -394,7 +395,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { public void testShouldRefreshActivityViaPauseForCameraCompat_propertyIsTrue_returnsTrue() throws Exception { doReturn(true).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); mockThatProperty(PROPERTY_CAMERA_COMPAT_ENABLE_REFRESH_VIA_PAUSE, /* value */ true); mController = new LetterboxUiController(mWm, mActivity); @@ -407,7 +408,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { @Test public void testShouldForceRotateForCameraCompat_flagIsDisabled_returnsFalse() { doReturn(false).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); assertFalse(mController.shouldForceRotateForCameraCompat()); } @@ -416,7 +417,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { @EnableCompatChanges({OVERRIDE_CAMERA_COMPAT_DISABLE_FORCE_ROTATION}) public void testShouldForceRotateForCameraCompat_overrideEnabled_returnsFalse() { doReturn(true).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); assertFalse(mController.shouldForceRotateForCameraCompat()); } @@ -426,7 +427,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { public void testShouldForceRotateForCameraCompat_propertyIsTrueAndOverride_returnsFalse() throws Exception { doReturn(true).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); mockThatProperty(PROPERTY_CAMERA_COMPAT_ALLOW_FORCE_ROTATION, /* value */ true); mController = new LetterboxUiController(mWm, mActivity); @@ -438,7 +439,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { public void testShouldForceRotateForCameraCompat_propertyIsFalse_returnsFalse() throws Exception { doReturn(true).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); mockThatProperty(PROPERTY_CAMERA_COMPAT_ALLOW_FORCE_ROTATION, /* value */ false); mController = new LetterboxUiController(mWm, mActivity); @@ -450,7 +451,7 @@ public class LetterboxUiControllerTest extends WindowTestsBase { public void testShouldForceRotateForCameraCompat_propertyIsTrue_returnsTrue() throws Exception { doReturn(true).when(mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(/* checkDeviceConfig */ true); + .isCameraCompatTreatmentEnabled(); mockThatProperty(PROPERTY_CAMERA_COMPAT_ALLOW_FORCE_ROTATION, /* value */ true); mController = new LetterboxUiController(mWm, mActivity); @@ -741,7 +742,9 @@ public class LetterboxUiControllerTest extends WindowTestsBase { @EnableCompatChanges({OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT, OVERRIDE_ORIENTATION_ONLY_FOR_CAMERA}) public void testOverrideOrientationIfNeeded_whenCameraNotActive_returnsUnchanged() { - doReturn(true).when(mLetterboxConfiguration).isCameraCompatTreatmentEnabled(anyBoolean()); + doReturn(true).when(mLetterboxConfiguration).isCameraCompatTreatmentEnabled(); + doReturn(true).when(mLetterboxConfiguration) + .isCameraCompatTreatmentEnabledAtBuildTime(); // Recreate DisplayContent with DisplayRotationCompatPolicy mActivity = setUpActivityWithComponent(); @@ -759,7 +762,9 @@ public class LetterboxUiControllerTest extends WindowTestsBase { @EnableCompatChanges({OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT, OVERRIDE_ORIENTATION_ONLY_FOR_CAMERA}) public void testOverrideOrientationIfNeeded_whenCameraActive_returnsPortrait() { - doReturn(true).when(mLetterboxConfiguration).isCameraCompatTreatmentEnabled(anyBoolean()); + doReturn(true).when(mLetterboxConfiguration).isCameraCompatTreatmentEnabled(); + doReturn(true).when(mLetterboxConfiguration) + .isCameraCompatTreatmentEnabledAtBuildTime(); // Recreate DisplayContent with DisplayRotationCompatPolicy mActivity = setUpActivityWithComponent(); @@ -1060,7 +1065,9 @@ public class LetterboxUiControllerTest extends WindowTestsBase { @Test public void testgetFixedOrientationLetterboxAspectRatio_splitScreenAspectEnabled() { doReturn(true).when(mActivity.mWmService.mLetterboxConfiguration) - .isCameraCompatTreatmentEnabled(anyBoolean()); + .isCameraCompatTreatmentEnabled(); + doReturn(true).when(mActivity.mWmService.mLetterboxConfiguration) + .isCameraCompatTreatmentEnabledAtBuildTime(); doReturn(true).when(mActivity.mWmService.mLetterboxConfiguration) .isCameraCompatSplitScreenAspectRatioEnabled(); doReturn(false).when(mActivity.mWmService.mLetterboxConfiguration)