Loading services/core/java/com/android/server/wm/LetterboxUiController.java +24 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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(); Loading Loading @@ -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 Loading @@ -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; } Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +28 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -348,6 +349,33 @@ public class SizeCompatTests extends WindowTestsBase { assertEquals(1.5f, translucentActivity.getMaxAspectRatio(), 0.00001f); } @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); Loading Loading
services/core/java/com/android/server/wm/LetterboxUiController.java +24 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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(); Loading Loading @@ -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 Loading @@ -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; } Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +28 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -348,6 +349,33 @@ public class SizeCompatTests extends WindowTestsBase { assertEquals(1.5f, translucentActivity.getMaxAspectRatio(), 0.00001f); } @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); Loading