summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/wm/LetterboxUiController.java27
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java28
2 files changed, 52 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/wm/LetterboxUiController.java b/services/core/java/com/android/server/wm/LetterboxUiController.java
index 6bffc4c95e64..a36b8c0e5d6a 100644
--- a/services/core/java/com/android/server/wm/LetterboxUiController.java
+++ b/services/core/java/com/android/server/wm/LetterboxUiController.java
@@ -38,6 +38,10 @@ import static android.content.pm.ActivityInfo.isFixedOrientationLandscape;
import static android.content.pm.ActivityInfo.screenOrientationToString;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
+import static android.content.res.Configuration.ORIENTATION_UNDEFINED;
+import static android.content.res.Configuration.SCREEN_HEIGHT_DP_UNDEFINED;
+import static android.content.res.Configuration.SCREEN_WIDTH_DP_UNDEFINED;
+import static android.content.res.Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
import static android.view.WindowManager.PROPERTY_CAMERA_COMPAT_ALLOW_FORCE_ROTATION;
import static android.view.WindowManager.PROPERTY_CAMERA_COMPAT_ALLOW_REFRESH;
@@ -188,7 +192,7 @@ final class LetterboxUiController {
private float mInheritedMaxAspectRatio = UNDEFINED_ASPECT_RATIO;
@Configuration.Orientation
- private int mInheritedOrientation = Configuration.ORIENTATION_UNDEFINED;
+ private int mInheritedOrientation = ORIENTATION_UNDEFINED;
// The app compat state for the opaque activity if any
private int mInheritedAppCompatState = APP_COMPAT_STATE_CHANGED__STATE__UNKNOWN;
@@ -1415,7 +1419,8 @@ final class LetterboxUiController {
mLetterboxConfigListener = WindowContainer.overrideConfigurationPropagation(
mActivityRecord, firstOpaqueActivityBeneath,
(opaqueConfig, transparentConfig) -> {
- final Configuration mutatedConfiguration = new Configuration();
+ final Configuration mutatedConfiguration =
+ fromOriginalTranslucentConfig(transparentConfig);
final Rect parentBounds = parent.getWindowConfiguration().getBounds();
final Rect bounds = mutatedConfiguration.windowConfiguration.getBounds();
final Rect letterboxBounds = opaqueConfig.windowConfiguration.getBounds();
@@ -1503,6 +1508,22 @@ final class LetterboxUiController {
true /* traverseTopToBottom */));
}
+ // When overriding translucent activities configuration we need to keep some of the
+ // original properties
+ private Configuration fromOriginalTranslucentConfig(Configuration translucentConfig) {
+ final Configuration configuration = new Configuration(translucentConfig);
+ // The values for the following properties will be defined during the configuration
+ // resolution in {@link ActivityRecord#resolveOverrideConfiguration} using the
+ // properties inherited from the first not finishing opaque activity beneath.
+ configuration.orientation = ORIENTATION_UNDEFINED;
+ configuration.screenWidthDp = configuration.compatScreenWidthDp = SCREEN_WIDTH_DP_UNDEFINED;
+ configuration.screenHeightDp =
+ configuration.compatScreenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED;
+ configuration.smallestScreenWidthDp =
+ configuration.compatSmallestScreenWidthDp = SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
+ return configuration;
+ }
+
private void inheritConfiguration(ActivityRecord firstOpaque) {
// To avoid wrong behaviour, we're not forcing a specific aspect ratio to activities
// which are not already providing one (e.g. permission dialogs) and presumably also
@@ -1522,7 +1543,7 @@ final class LetterboxUiController {
mLetterboxConfigListener = null;
mInheritedMinAspectRatio = UNDEFINED_ASPECT_RATIO;
mInheritedMaxAspectRatio = UNDEFINED_ASPECT_RATIO;
- mInheritedOrientation = Configuration.ORIENTATION_UNDEFINED;
+ mInheritedOrientation = ORIENTATION_UNDEFINED;
mInheritedAppCompatState = APP_COMPAT_STATE_CHANGED__STATE__UNKNOWN;
mInheritedCompatDisplayInsets = null;
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index 75d65b3a3f8f..671b27584fcc 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -16,6 +16,7 @@
package com.android.server.wm;
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
@@ -349,6 +350,33 @@ public class SizeCompatTests extends WindowTestsBase {
}
@Test
+ public void testApplyStrategyToTranslucentActivitiesRetainsWindowConfigurationProperties() {
+ mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true);
+ setUpDisplaySizeWithApp(2000, 1000);
+ prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);
+ mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ // Translucent Activity
+ final ActivityRecord translucentActivity = new ActivityBuilder(mAtm)
+ .setLaunchedFromUid(mActivity.getUid())
+ .build();
+ doReturn(false).when(translucentActivity).fillsParent();
+ WindowConfiguration translucentWinConf = translucentActivity.getWindowConfiguration();
+ translucentActivity.setActivityType(ACTIVITY_TYPE_STANDARD);
+ translucentActivity.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
+ translucentActivity.setDisplayWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
+ translucentActivity.setAlwaysOnTop(true);
+
+ mTask.addChild(translucentActivity);
+
+ // We check the WIndowConfiguration properties
+ translucentWinConf = translucentActivity.getWindowConfiguration();
+ assertEquals(ACTIVITY_TYPE_STANDARD, translucentActivity.getActivityType());
+ assertEquals(WINDOWING_MODE_MULTI_WINDOW, translucentWinConf.getWindowingMode());
+ assertEquals(WINDOWING_MODE_MULTI_WINDOW, translucentWinConf.getDisplayWindowingMode());
+ assertTrue(translucentWinConf.isAlwaysOnTop());
+ }
+
+ @Test
public void testApplyStrategyToMultipleTranslucentActivities() {
mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true);
setUpDisplaySizeWithApp(2000, 1000);