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

Commit a75a9458 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Keep initial override configuration from display settings

During register configuration change listener, the override
configuration will update from the container to listener.
When linking ActivityDisplay to an existing DisplayConent,
the empty configuration will replace the applied override
configuration which should be kept.

Bug: 119919497
Test: Enable freeform, desktop mode and simulate secondary displays
      in developer options. Launch an resizable activity in that
      display and check if the activity is freeform style.

Change-Id: Ic7d38dc1b9a551b78f41de43c38fac2caeab33d4
parent 509d06a6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -179,6 +179,11 @@ class ActivityDisplay extends ConfigurationContainer<ActivityStack>
        mWindowContainerController.onDisplayChanged();
    }

    @Override
    public void onInitializeOverrideConfiguration(Configuration config) {
        getOverrideConfiguration().updateFrom(config);
    }

    void addChild(ActivityStack stack, int position) {
        if (position == POSITION_BOTTOM) {
            position = 0;
+15 −0
Original line number Diff line number Diff line
@@ -224,6 +224,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
        final DisplayContent existing = getDisplayContent(displayId);

        if (existing != null) {
            initializeDisplayOverrideConfiguration(controller, existing);
            existing.setController(controller);
            return existing;
        }
@@ -233,6 +234,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
        if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Adding display=" + display);

        mService.mDisplayWindowSettings.applySettingsToDisplayLocked(dc);
        initializeDisplayOverrideConfiguration(controller, dc);

        if (mService.mDisplayManagerInternal != null) {
            mService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(
@@ -245,6 +247,19 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
        return dc;
    }

    /**
     * The display content may have configuration set from {@link #DisplayWindowSettings}. This
     * callback let the owner of container know there is existing configuration to prevent the
     * values from being replaced by the initializing {@link #ActivityDisplay}.
     */
    private void initializeDisplayOverrideConfiguration(DisplayWindowController controller,
            DisplayContent displayContent) {
        if (controller != null && controller.mListener != null) {
            controller.mListener.onInitializeOverrideConfiguration(
                    displayContent.getOverrideConfiguration());
        }
    }

    boolean isLayoutNeeded() {
        final int numDisplays = mChildren.size();
        for (int displayNdx = 0; displayNdx < numDisplays; ++displayNdx) {
+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.wm;

import android.content.res.Configuration;

/**
 * Interface used by the owner/creator of the container to listen to changes with the container.
 * @see WindowContainerController
@@ -23,4 +25,5 @@ package com.android.server.wm;
public interface WindowContainerListener {
    void registerConfigurationChangeListener(ConfigurationContainerListener listener);
    void unregisterConfigurationChangeListener(ConfigurationContainerListener listener);
    default void onInitializeOverrideConfiguration(Configuration config) {}
}