Merge "Compute config based on original override for inherited letterbox" into udc-dev
This commit is contained in:
@@ -1597,11 +1597,10 @@ final class LetterboxUiController {
|
||||
inheritConfiguration(firstOpaqueActivityBeneath);
|
||||
mLetterboxConfigListener = WindowContainer.overrideConfigurationPropagation(
|
||||
mActivityRecord, firstOpaqueActivityBeneath,
|
||||
(opaqueConfig, transparentConfig) -> {
|
||||
final Configuration mutatedConfiguration =
|
||||
fromOriginalTranslucentConfig(transparentConfig);
|
||||
(opaqueConfig, transparentOverrideConfig) -> {
|
||||
resetTranslucentOverrideConfig(transparentOverrideConfig);
|
||||
final Rect parentBounds = parent.getWindowConfiguration().getBounds();
|
||||
final Rect bounds = mutatedConfiguration.windowConfiguration.getBounds();
|
||||
final Rect bounds = transparentOverrideConfig.windowConfiguration.getBounds();
|
||||
final Rect letterboxBounds = opaqueConfig.windowConfiguration.getBounds();
|
||||
// We cannot use letterboxBounds directly here because the position relies on
|
||||
// letterboxing. Using letterboxBounds directly, would produce a double offset.
|
||||
@@ -1610,9 +1609,9 @@ final class LetterboxUiController {
|
||||
parentBounds.top + letterboxBounds.height());
|
||||
// We need to initialize appBounds to avoid NPE. The actual value will
|
||||
// be set ahead when resolving the Configuration for the activity.
|
||||
mutatedConfiguration.windowConfiguration.setAppBounds(new Rect());
|
||||
transparentOverrideConfig.windowConfiguration.setAppBounds(new Rect());
|
||||
inheritConfiguration(firstOpaqueActivityBeneath);
|
||||
return mutatedConfiguration;
|
||||
return transparentOverrideConfig;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1691,20 +1690,16 @@ 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);
|
||||
/** Resets the screen size related fields so they can be resolved by requested bounds later. */
|
||||
private static void resetTranslucentOverrideConfig(Configuration config) {
|
||||
// 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;
|
||||
config.orientation = ORIENTATION_UNDEFINED;
|
||||
config.screenWidthDp = config.compatScreenWidthDp = SCREEN_WIDTH_DP_UNDEFINED;
|
||||
config.screenHeightDp = config.compatScreenHeightDp = SCREEN_HEIGHT_DP_UNDEFINED;
|
||||
config.smallestScreenWidthDp = config.compatSmallestScreenWidthDp =
|
||||
SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
|
||||
}
|
||||
|
||||
private void inheritConfiguration(ActivityRecord firstOpaque) {
|
||||
|
||||
@@ -4047,7 +4047,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
|
||||
final Configuration mergedConfiguration =
|
||||
configurationMerger != null
|
||||
? configurationMerger.merge(mergedOverrideConfig,
|
||||
receiver.getConfiguration())
|
||||
receiver.getRequestedOverrideConfiguration())
|
||||
: supplier.getConfiguration();
|
||||
receiver.onRequestedOverrideConfigurationChanged(mergedConfiguration);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.server.wm;
|
||||
|
||||
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
|
||||
import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
|
||||
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;
|
||||
@@ -428,20 +429,24 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
.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);
|
||||
final Configuration requestedConfig =
|
||||
translucentActivity.getRequestedOverrideConfiguration();
|
||||
final WindowConfiguration translucentWinConf = requestedConfig.windowConfiguration;
|
||||
translucentWinConf.setActivityType(ACTIVITY_TYPE_STANDARD);
|
||||
translucentWinConf.setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
|
||||
translucentWinConf.setDisplayWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
|
||||
translucentWinConf.setAlwaysOnTop(true);
|
||||
translucentActivity.onRequestedOverrideConfigurationChanged(requestedConfig);
|
||||
|
||||
mTask.addChild(translucentActivity);
|
||||
|
||||
// We check the WIndowConfiguration properties
|
||||
translucentWinConf = translucentActivity.getWindowConfiguration();
|
||||
// The original override of WindowConfiguration should keep.
|
||||
assertEquals(ACTIVITY_TYPE_STANDARD, translucentActivity.getActivityType());
|
||||
assertEquals(WINDOWING_MODE_MULTI_WINDOW, translucentWinConf.getWindowingMode());
|
||||
assertEquals(WINDOWING_MODE_MULTI_WINDOW, translucentWinConf.getDisplayWindowingMode());
|
||||
assertTrue(translucentWinConf.isAlwaysOnTop());
|
||||
// Unless display is going to be rotated, it should always inherit from parent.
|
||||
assertEquals(ROTATION_UNDEFINED, translucentWinConf.getDisplayRotation());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user