Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc71fc04 authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "Compute config based on original override for inherited letterbox" into...

Merge "Compute config based on original override for inherited letterbox" into udc-dev am: db387438

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22510222



Change-Id: I523aa42fdf97a5366653588a4078024baaf90aa6
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 8e499dbb db387438
Loading
Loading
Loading
Loading
+12 −17
Original line number Diff line number Diff line
@@ -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) {
+1 −1
Original line number Diff line number Diff line
@@ -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);
            }
+12 −7
Original line number Diff line number Diff line
@@ -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