summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/res/res/values/config.xml4
-rw-r--r--core/res/res/values/symbols.xml1
-rw-r--r--services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java9
-rw-r--r--services/core/java/com/android/server/wm/LetterboxConfiguration.java14
-rw-r--r--services/core/java/com/android/server/wm/LetterboxUiController.java52
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java27
6 files changed, 87 insertions, 20 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 0eca3d093e52..4dbeb28aa843 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -5417,6 +5417,10 @@
split screen. -->
<bool name="config_isWindowManagerCameraCompatTreatmentEnabled">false</bool>
+ <!-- Whether should use split screen aspect ratio for the activity when camera compat treatment
+ is enabled and activity is connected to the camera in fullscreen. -->
+ <bool name="config_isWindowManagerCameraCompatSplitScreenAspectRatioEnabled">false</bool>
+
<!-- Whether a camera compat controller is enabled to allow the user to apply or revert
treatment for stretched issues in camera viewfinder. -->
<bool name="config_isCameraCompatControlForStretchedIssuesEnabled">false</bool>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 138bffe2d9d8..87f9769c0093 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -4488,6 +4488,7 @@
<java-symbol type="bool" name="config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled" />
<java-symbol type="bool" name="config_isCompatFakeFocusEnabled" />
<java-symbol type="bool" name="config_isWindowManagerCameraCompatTreatmentEnabled" />
+ <java-symbol type="bool" name="config_isWindowManagerCameraCompatSplitScreenAspectRatioEnabled" />
<java-symbol type="bool" name="config_isCameraCompatControlForStretchedIssuesEnabled" />
<java-symbol type="bool" name="config_hideDisplayCutoutWithDisplayArea" />
diff --git a/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java b/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java
index 41eb2c92923f..fb72d6c6b56d 100644
--- a/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java
@@ -378,10 +378,7 @@ final class DisplayRotationCompatPolicy {
// Checking whether an activity in fullscreen rather than the task as this camera
// compat treatment doesn't cover activity embedding.
if (topActivity.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
- if (topActivity.mLetterboxUiController
- .isOverrideOrientationOnlyForCameraEnabled()) {
- topActivity.recomputeConfiguration();
- }
+ topActivity.mLetterboxUiController.recomputeConfigurationForCameraCompatIfNeeded();
mDisplayContent.updateOrientation();
return;
}
@@ -447,9 +444,7 @@ final class DisplayRotationCompatPolicy {
|| topActivity.getWindowingMode() != WINDOWING_MODE_FULLSCREEN) {
return;
}
- if (topActivity.mLetterboxUiController.isOverrideOrientationOnlyForCameraEnabled()) {
- topActivity.recomputeConfiguration();
- }
+ topActivity.mLetterboxUiController.recomputeConfigurationForCameraCompatIfNeeded();
mDisplayContent.updateOrientation();
}
}
diff --git a/services/core/java/com/android/server/wm/LetterboxConfiguration.java b/services/core/java/com/android/server/wm/LetterboxConfiguration.java
index ec04894b1d42..611cbc78865d 100644
--- a/services/core/java/com/android/server/wm/LetterboxConfiguration.java
+++ b/services/core/java/com/android/server/wm/LetterboxConfiguration.java
@@ -212,6 +212,10 @@ final class LetterboxConfiguration {
// otherwise the apps get blacked out when they are resumed and do not have focus yet.
private boolean mIsCompatFakeFocusEnabled;
+ // Whether should use split screen aspect ratio for the activity when camera compat treatment
+ // is enabled and activity is connected to the camera in fullscreen.
+ private final boolean mIsCameraCompatSplitScreenAspectRatioEnabled;
+
// Whether camera compatibility treatment is enabled.
// See DisplayRotationCompatPolicy for context.
private final boolean mIsCameraCompatTreatmentEnabled;
@@ -300,6 +304,8 @@ final class LetterboxConfiguration {
R.bool.config_letterboxIsEnabledForTranslucentActivities);
mIsCameraCompatTreatmentEnabled = mContext.getResources().getBoolean(
R.bool.config_isWindowManagerCameraCompatTreatmentEnabled);
+ mIsCameraCompatSplitScreenAspectRatioEnabled = mContext.getResources().getBoolean(
+ R.bool.config_isWindowManagerCameraCompatSplitScreenAspectRatioEnabled);
mIsCompatFakeFocusEnabled = mContext.getResources().getBoolean(
R.bool.config_isCompatFakeFocusEnabled);
mIsPolicyForIgnoringRequestedOrientationEnabled = mContext.getResources().getBoolean(
@@ -1122,6 +1128,14 @@ final class LetterboxConfiguration {
return mIsPolicyForIgnoringRequestedOrientationEnabled;
}
+ /**
+ * Whether should use split screen aspect ratio for the activity when camera compat treatment
+ * is enabled and activity is connected to the camera in fullscreen.
+ */
+ boolean isCameraCompatSplitScreenAspectRatioEnabled() {
+ return mIsCameraCompatSplitScreenAspectRatioEnabled;
+ }
+
/** Whether camera compatibility treatment is enabled. */
boolean isCameraCompatTreatmentEnabled(boolean checkDeviceConfig) {
return mIsCameraCompatTreatmentEnabled && (!checkDeviceConfig
diff --git a/services/core/java/com/android/server/wm/LetterboxUiController.java b/services/core/java/com/android/server/wm/LetterboxUiController.java
index 4d0c7683d621..bf2f436b35eb 100644
--- a/services/core/java/com/android/server/wm/LetterboxUiController.java
+++ b/services/core/java/com/android/server/wm/LetterboxUiController.java
@@ -398,13 +398,7 @@ final class LetterboxUiController {
+ mActivityRecord);
return true;
}
- DisplayContent displayContent = mActivityRecord.mDisplayContent;
- if (displayContent == null) {
- return false;
- }
- if (displayContent.mDisplayRotationCompatPolicy != null
- && displayContent.mDisplayRotationCompatPolicy
- .isTreatmentEnabledForActivity(mActivityRecord)) {
+ if (isCameraCompatTreatmentActive()) {
Slog.w(TAG, "Ignoring orientation update to "
+ screenOrientationToString(requestedOrientation)
+ " due to camera compat treatment for " + mActivityRecord);
@@ -642,6 +636,16 @@ final class LetterboxUiController {
mBooleanPropertyCameraCompatAllowForceRotation);
}
+ private boolean isCameraCompatTreatmentActive() {
+ DisplayContent displayContent = mActivityRecord.mDisplayContent;
+ if (displayContent == null) {
+ return false;
+ }
+ return displayContent.mDisplayRotationCompatPolicy != null
+ && displayContent.mDisplayRotationCompatPolicy
+ .isTreatmentEnabledForActivity(mActivityRecord);
+ }
+
private boolean isCompatChangeEnabled(long overrideChangeId) {
return mActivityRecord.info.isChangeEnabled(overrideChangeId);
}
@@ -904,13 +908,35 @@ final class LetterboxUiController {
}
float getFixedOrientationLetterboxAspectRatio(@NonNull Configuration parentConfiguration) {
- // Don't resize to split screen size when half folded if letterbox position is centered
+ return shouldUseSplitScreenAspectRatio(parentConfiguration)
+ ? getSplitScreenAspectRatio()
+ : mActivityRecord.shouldCreateCompatDisplayInsets()
+ ? getDefaultMinAspectRatioForUnresizableApps()
+ : getDefaultMinAspectRatio();
+ }
+
+ void recomputeConfigurationForCameraCompatIfNeeded() {
+ if (isOverrideOrientationOnlyForCameraEnabled()
+ || isCameraCompatSplitScreenAspectRatioAllowed()) {
+ mActivityRecord.recomputeConfiguration();
+ }
+ }
+
+ /**
+ * Whether we use split screen aspect ratio for the activity when camera compat treatment
+ * is active because the corresponding config is enabled and activity supports resizing.
+ */
+ private boolean isCameraCompatSplitScreenAspectRatioAllowed() {
+ return mLetterboxConfiguration.isCameraCompatSplitScreenAspectRatioEnabled()
+ && !mActivityRecord.shouldCreateCompatDisplayInsets();
+ }
+
+ private boolean shouldUseSplitScreenAspectRatio(@NonNull Configuration parentConfiguration) {
return isDisplayFullScreenAndSeparatingHinge()
- && getHorizontalPositionMultiplier(parentConfiguration) != 0.5f
- ? getSplitScreenAspectRatio()
- : mActivityRecord.shouldCreateCompatDisplayInsets()
- ? getDefaultMinAspectRatioForUnresizableApps()
- : getDefaultMinAspectRatio();
+ // Don't resize to split screen size when half folded and centered
+ && getHorizontalPositionMultiplier(parentConfiguration) != 0.5f
+ || isCameraCompatSplitScreenAspectRatioAllowed()
+ && isCameraCompatTreatmentActive();
}
private float getDefaultMinAspectRatioForUnresizableApps() {
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 23a3d520ea3e..8f31641c66f4 100644
--- a/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/LetterboxUiControllerTest.java
@@ -820,6 +820,33 @@ public class LetterboxUiControllerTest extends WindowTestsBase {
assertTrue(mController.shouldSendFakeFocus());
}
+ @Test
+ public void testgetFixedOrientationLetterboxAspectRatio_splitScreenAspectEnabled() {
+ doReturn(true).when(mActivity.mWmService.mLetterboxConfiguration)
+ .isCameraCompatTreatmentEnabled(anyBoolean());
+ doReturn(true).when(mActivity.mWmService.mLetterboxConfiguration)
+ .isCameraCompatSplitScreenAspectRatioEnabled();
+ doReturn(false).when(mActivity.mWmService.mLetterboxConfiguration)
+ .getIsDisplayAspectRatioEnabledForFixedOrientationLetterbox();
+ doReturn(1.5f).when(mActivity.mWmService.mLetterboxConfiguration)
+ .getFixedOrientationLetterboxAspectRatio();
+
+ // Recreate DisplayContent with DisplayRotationCompatPolicy
+ mActivity = setUpActivityWithComponent();
+ mController = new LetterboxUiController(mWm, mActivity);
+
+ assertEquals(mController.getFixedOrientationLetterboxAspectRatio(
+ mActivity.getParent().getConfiguration()), 1.5f, /* delta */ 0.01);
+
+ spyOn(mDisplayContent.mDisplayRotationCompatPolicy);
+ doReturn(true).when(mDisplayContent.mDisplayRotationCompatPolicy)
+ .isTreatmentEnabledForActivity(eq(mActivity));
+
+ assertEquals(mController.getFixedOrientationLetterboxAspectRatio(
+ mActivity.getParent().getConfiguration()), mController.getSplitScreenAspectRatio(),
+ /* delta */ 0.01);
+ }
+
private void mockThatProperty(String propertyName, boolean value) throws Exception {
Property property = new Property(propertyName, /* value */ value, /* packageName */ "",
/* className */ "");