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

Commit bed4a065 authored by Jerry Chang's avatar Jerry Chang
Browse files

Don't override child task bounds when rotation changed

In multi-window splits(like app-pair or stage split), task bounds might
be set unexpectedly with override configuration after the device
rotated.

When Task#onConfigurationChanged detected override bounds and display
rotated, it will triverse to override all child tasks' bounds, which
making child won't inherit its parent bounds anymore.

Unify to use Task#setBounds instead of Task#resize when updating
override bounds for rotation and let child inherits its parent bounds
directly.

Also removed duplicate onRootTaskWindowingModeChanged call.

Fix: 178773517
Test: manual check
Test: atest WmTests:TaskTests WMShellUnitTests
Change-Id: I57c3493c6b7a4912ee5e6ed06bf55e976f99c40b
parent 081a843f
Loading
Loading
Loading
Loading
+3 −18
Original line number Diff line number Diff line
@@ -2315,12 +2315,9 @@ class Task extends WindowContainer<WindowContainer> {
            return;
        }

        final boolean windowingModeChanged = prevWindowingMode != getWindowingMode();
        final int overrideWindowingMode = getRequestedOverrideWindowingMode();
        // Update bounds if applicable
        boolean hasNewOverrideBounds = false;
        // Use override windowing mode to prevent extra bounds changes if inheriting the mode.
        if ((overrideWindowingMode != WINDOWING_MODE_PINNED)
        final int overrideWindowingMode = getRequestedOverrideWindowingMode();
        if (overrideWindowingMode != WINDOWING_MODE_PINNED
                && !getRequestedOverrideBounds().isEmpty()) {
            // If the parent (display) has rotated, rotate our bounds to best-fit where their
            // bounds were on the pre-rotated display.
@@ -2330,22 +2327,10 @@ class Task extends WindowContainer<WindowContainer> {
                mDisplayContent.rotateBounds(
                        newParentConfig.windowConfiguration.getBounds(), prevRotation, newRotation,
                        newBounds);
                hasNewOverrideBounds = true;
            }
        }

        if (windowingModeChanged) {
            taskDisplayArea.onRootTaskWindowingModeChanged(this);
        }
        if (hasNewOverrideBounds) {
            if (inSplitScreenWindowingMode()) {
                setBounds(newBounds);
            } else if (overrideWindowingMode != WINDOWING_MODE_PINNED) {
                // For root pinned task, resize is now part of the {@link
                // WindowContainerTransaction}
                resize(new Rect(newBounds), PRESERVE_WINDOWS, true /* deferResume */);
            }
        }

        if (prevIsAlwaysOnTop != isAlwaysOnTop()) {
            // Since always on top is only on when the root task is freeform or pinned, the state
            // can be toggled when the windowing mode changes. We must make sure the root task is
+0 −17
Original line number Diff line number Diff line
@@ -405,11 +405,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
                        new Configuration(container.getRequestedOverrideConfiguration());
                c.setTo(change.getConfiguration(), configMask, windowMask);
                container.onRequestedOverrideConfigurationChanged(c);
                // TODO(b/145675353): remove the following once we could apply new bounds to the
                // root pinned task together with its children.
            }
            resizeRootPinnedTaskIfNeeded(container, configMask, windowMask,
                    container.getRequestedOverrideConfiguration());
            effects |= TRANSACT_EFFECTS_CLIENT_CONFIG;
        }
        if ((change.getChangeMask() & WindowContainerTransaction.Change.CHANGE_FOCUSABLE) != 0) {
@@ -659,19 +655,6 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
        return effects;
    }

    private void resizeRootPinnedTaskIfNeeded(ConfigurationContainer container, int configMask,
            int windowMask, Configuration config) {
        if ((container instanceof Task)
                && ((configMask & ActivityInfo.CONFIG_WINDOW_CONFIGURATION) != 0)
                && ((windowMask & WindowConfiguration.WINDOW_CONFIG_BOUNDS) != 0)) {
            final Task rootTask = (Task) container;
            if (rootTask.inPinnedWindowingMode()) {
                rootTask.resize(config.windowConfiguration.getBounds(),
                        PRESERVE_WINDOWS, true /* deferResume */);
            }
        }
    }

    @Override
    public ITaskOrganizerController getTaskOrganizerController() {
        enforceTaskPermission("getTaskOrganizerController()");