Merge "[7/n] Camera Compat: Split screen aspect ratio for resizeable activities" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e3ae617c5a
@@ -5422,6 +5422,10 @@
|
|||||||
split screen. -->
|
split screen. -->
|
||||||
<bool name="config_isWindowManagerCameraCompatTreatmentEnabled">false</bool>
|
<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
|
<!-- Whether a camera compat controller is enabled to allow the user to apply or revert
|
||||||
treatment for stretched issues in camera viewfinder. -->
|
treatment for stretched issues in camera viewfinder. -->
|
||||||
<bool name="config_isCameraCompatControlForStretchedIssuesEnabled">false</bool>
|
<bool name="config_isCameraCompatControlForStretchedIssuesEnabled">false</bool>
|
||||||
|
|||||||
@@ -4489,6 +4489,7 @@
|
|||||||
<java-symbol type="bool" name="config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled" />
|
<java-symbol type="bool" name="config_letterboxIsDisplayAspectRatioForFixedOrientationLetterboxEnabled" />
|
||||||
<java-symbol type="bool" name="config_isCompatFakeFocusEnabled" />
|
<java-symbol type="bool" name="config_isCompatFakeFocusEnabled" />
|
||||||
<java-symbol type="bool" name="config_isWindowManagerCameraCompatTreatmentEnabled" />
|
<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_isCameraCompatControlForStretchedIssuesEnabled" />
|
||||||
|
|
||||||
<java-symbol type="bool" name="config_hideDisplayCutoutWithDisplayArea" />
|
<java-symbol type="bool" name="config_hideDisplayCutoutWithDisplayArea" />
|
||||||
|
|||||||
@@ -378,10 +378,7 @@ final class DisplayRotationCompatPolicy {
|
|||||||
// Checking whether an activity in fullscreen rather than the task as this camera
|
// Checking whether an activity in fullscreen rather than the task as this camera
|
||||||
// compat treatment doesn't cover activity embedding.
|
// compat treatment doesn't cover activity embedding.
|
||||||
if (topActivity.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
|
if (topActivity.getWindowingMode() == WINDOWING_MODE_FULLSCREEN) {
|
||||||
if (topActivity.mLetterboxUiController
|
topActivity.mLetterboxUiController.recomputeConfigurationForCameraCompatIfNeeded();
|
||||||
.isOverrideOrientationOnlyForCameraEnabled()) {
|
|
||||||
topActivity.recomputeConfiguration();
|
|
||||||
}
|
|
||||||
mDisplayContent.updateOrientation();
|
mDisplayContent.updateOrientation();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -447,9 +444,7 @@ final class DisplayRotationCompatPolicy {
|
|||||||
|| topActivity.getWindowingMode() != WINDOWING_MODE_FULLSCREEN) {
|
|| topActivity.getWindowingMode() != WINDOWING_MODE_FULLSCREEN) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (topActivity.mLetterboxUiController.isOverrideOrientationOnlyForCameraEnabled()) {
|
topActivity.mLetterboxUiController.recomputeConfigurationForCameraCompatIfNeeded();
|
||||||
topActivity.recomputeConfiguration();
|
|
||||||
}
|
|
||||||
mDisplayContent.updateOrientation();
|
mDisplayContent.updateOrientation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,6 +212,10 @@ final class LetterboxConfiguration {
|
|||||||
// otherwise the apps get blacked out when they are resumed and do not have focus yet.
|
// otherwise the apps get blacked out when they are resumed and do not have focus yet.
|
||||||
private boolean mIsCompatFakeFocusEnabled;
|
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.
|
// Whether camera compatibility treatment is enabled.
|
||||||
// See DisplayRotationCompatPolicy for context.
|
// See DisplayRotationCompatPolicy for context.
|
||||||
private final boolean mIsCameraCompatTreatmentEnabled;
|
private final boolean mIsCameraCompatTreatmentEnabled;
|
||||||
@@ -300,6 +304,8 @@ final class LetterboxConfiguration {
|
|||||||
R.bool.config_letterboxIsEnabledForTranslucentActivities);
|
R.bool.config_letterboxIsEnabledForTranslucentActivities);
|
||||||
mIsCameraCompatTreatmentEnabled = mContext.getResources().getBoolean(
|
mIsCameraCompatTreatmentEnabled = mContext.getResources().getBoolean(
|
||||||
R.bool.config_isWindowManagerCameraCompatTreatmentEnabled);
|
R.bool.config_isWindowManagerCameraCompatTreatmentEnabled);
|
||||||
|
mIsCameraCompatSplitScreenAspectRatioEnabled = mContext.getResources().getBoolean(
|
||||||
|
R.bool.config_isWindowManagerCameraCompatSplitScreenAspectRatioEnabled);
|
||||||
mIsCompatFakeFocusEnabled = mContext.getResources().getBoolean(
|
mIsCompatFakeFocusEnabled = mContext.getResources().getBoolean(
|
||||||
R.bool.config_isCompatFakeFocusEnabled);
|
R.bool.config_isCompatFakeFocusEnabled);
|
||||||
mIsPolicyForIgnoringRequestedOrientationEnabled = mContext.getResources().getBoolean(
|
mIsPolicyForIgnoringRequestedOrientationEnabled = mContext.getResources().getBoolean(
|
||||||
@@ -1122,6 +1128,14 @@ final class LetterboxConfiguration {
|
|||||||
return mIsPolicyForIgnoringRequestedOrientationEnabled;
|
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. */
|
/** Whether camera compatibility treatment is enabled. */
|
||||||
boolean isCameraCompatTreatmentEnabled(boolean checkDeviceConfig) {
|
boolean isCameraCompatTreatmentEnabled(boolean checkDeviceConfig) {
|
||||||
return mIsCameraCompatTreatmentEnabled && (!checkDeviceConfig
|
return mIsCameraCompatTreatmentEnabled && (!checkDeviceConfig
|
||||||
|
|||||||
@@ -398,13 +398,7 @@ final class LetterboxUiController {
|
|||||||
+ mActivityRecord);
|
+ mActivityRecord);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
DisplayContent displayContent = mActivityRecord.mDisplayContent;
|
if (isCameraCompatTreatmentActive()) {
|
||||||
if (displayContent == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (displayContent.mDisplayRotationCompatPolicy != null
|
|
||||||
&& displayContent.mDisplayRotationCompatPolicy
|
|
||||||
.isTreatmentEnabledForActivity(mActivityRecord)) {
|
|
||||||
Slog.w(TAG, "Ignoring orientation update to "
|
Slog.w(TAG, "Ignoring orientation update to "
|
||||||
+ screenOrientationToString(requestedOrientation)
|
+ screenOrientationToString(requestedOrientation)
|
||||||
+ " due to camera compat treatment for " + mActivityRecord);
|
+ " due to camera compat treatment for " + mActivityRecord);
|
||||||
@@ -642,6 +636,16 @@ final class LetterboxUiController {
|
|||||||
mBooleanPropertyCameraCompatAllowForceRotation);
|
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) {
|
private boolean isCompatChangeEnabled(long overrideChangeId) {
|
||||||
return mActivityRecord.info.isChangeEnabled(overrideChangeId);
|
return mActivityRecord.info.isChangeEnabled(overrideChangeId);
|
||||||
}
|
}
|
||||||
@@ -904,13 +908,35 @@ final class LetterboxUiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float getFixedOrientationLetterboxAspectRatio(@NonNull Configuration parentConfiguration) {
|
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()
|
return isDisplayFullScreenAndSeparatingHinge()
|
||||||
&& getHorizontalPositionMultiplier(parentConfiguration) != 0.5f
|
// Don't resize to split screen size when half folded and centered
|
||||||
? getSplitScreenAspectRatio()
|
&& getHorizontalPositionMultiplier(parentConfiguration) != 0.5f
|
||||||
: mActivityRecord.shouldCreateCompatDisplayInsets()
|
|| isCameraCompatSplitScreenAspectRatioAllowed()
|
||||||
? getDefaultMinAspectRatioForUnresizableApps()
|
&& isCameraCompatTreatmentActive();
|
||||||
: getDefaultMinAspectRatio();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getDefaultMinAspectRatioForUnresizableApps() {
|
private float getDefaultMinAspectRatioForUnresizableApps() {
|
||||||
|
|||||||
@@ -820,6 +820,33 @@ public class LetterboxUiControllerTest extends WindowTestsBase {
|
|||||||
assertTrue(mController.shouldSendFakeFocus());
|
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 {
|
private void mockThatProperty(String propertyName, boolean value) throws Exception {
|
||||||
Property property = new Property(propertyName, /* value */ value, /* packageName */ "",
|
Property property = new Property(propertyName, /* value */ value, /* packageName */ "",
|
||||||
/* className */ "");
|
/* className */ "");
|
||||||
|
|||||||
Reference in New Issue
Block a user