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

Commit e7b2078f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Consolidate onDisplayChange() and updateDisplayInfo()"

parents 3ab40f18 2f145f22
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -2011,9 +2011,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        mDisplay.getDisplayInfo(mDisplayInfo);
        mDisplay.getMetrics(mDisplayMetrics);

        for (int i = mTaskStackContainers.getChildCount() - 1; i >= 0; --i) {
            mTaskStackContainers.getChildAt(i).updateDisplayInfo(null);
        }
        onDisplayChanged(this);
    }

    void initializeDisplayBaseInfo() {
+3 −2
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ class Task extends WindowContainer<AppWindowToken> {
        super.onParentSet();

        // Update task bounds if needed.
        updateDisplayInfo(getDisplayContent());
        adjustBoundsForDisplayChangeIfNeeded(getDisplayContent());

        if (getWindowConfiguration().windowsAreScaleable()) {
            // We force windows out of SCALING_MODE_FREEZE so that we can continue to animate them
@@ -303,6 +303,7 @@ class Task extends WindowContainer<AppWindowToken> {
    @Override
    void onDisplayChanged(DisplayContent dc) {
        updateSurfaceSize(dc);
        adjustBoundsForDisplayChangeIfNeeded(dc);
        super.onDisplayChanged(dc);
    }

@@ -501,7 +502,7 @@ class Task extends WindowContainer<AppWindowToken> {
        return mDragResizeMode;
    }

    void updateDisplayInfo(final DisplayContent displayContent) {
    private void adjustBoundsForDisplayChangeIfNeeded(final DisplayContent displayContent) {
        if (displayContent == null) {
            return;
        }
+45 −32
Original line number Diff line number Diff line
@@ -418,32 +418,6 @@ public class TaskStack extends WindowContainer<Task> implements
        getBounds(out);
    }

    void updateDisplayInfo(Rect bounds) {
        if (mDisplayContent == null) {
            return;
        }

        for (int taskNdx = mChildren.size() - 1; taskNdx >= 0; --taskNdx) {
            mChildren.get(taskNdx).updateDisplayInfo(mDisplayContent);
        }
        if (bounds != null) {
            setBounds(bounds);
            return;
        } else if (matchParentBounds()) {
            setBounds(null);
            return;
        }

        mTmpRect2.set(getRawBounds());
        final int newRotation = mDisplayContent.getDisplayInfo().rotation;
        final int newDensity = mDisplayContent.getDisplayInfo().logicalDensityDpi;
        if (mRotation == newRotation && mDensity == newDensity) {
            setBounds(mTmpRect2);
        }

        // If the rotation or density didn't match, we'll update it in onConfigurationChanged.
    }

    /**
     * Updates the passed-in {@code inOutBounds} based on how it would change when this container's
     * override configuration is applied to the specified {@code parentConfig} and
@@ -820,16 +794,24 @@ public class TaskStack extends WindowContainer<Task> implements

    @Override
    void onDisplayChanged(DisplayContent dc) {
        if (mDisplayContent != null) {
        if (mDisplayContent != null && mDisplayContent != dc) {
            throw new IllegalStateException("onDisplayChanged: Already attached");
        }

        final boolean movedToNewDisplay = mDisplayContent == null;
        mDisplayContent = dc;

        if (movedToNewDisplay) {
            updateBoundsForWindowModeChange();
        } else {
            updateBoundsForDisplayChanges();
        }

        if (mAnimationBackgroundSurface != null) {
            mAnimationBackgroundSurface = makeChildSurface(null).setColorLayer(true)
                    .setName("animation background stackId=" + mStackId)
                    .build();
        }

        super.onDisplayChanged(dc);
    }
@@ -845,10 +827,41 @@ public class TaskStack extends WindowContainer<Task> implements
            }, true);
        }

        updateDisplayInfo(bounds);
        setBoundsForWindowModeChange(bounds);
        updateSurfaceBounds();
    }

    private void setBoundsForWindowModeChange(Rect bounds) {
        if (mDisplayContent == null) {
            return;
        }

        if (bounds != null) {
            setBounds(bounds);
            return;
        }

        updateBoundsForDisplayChanges();
    }

    private void updateBoundsForDisplayChanges() {
        // Avoid setting override bounds to bounds inherited from parent if there was no override
        // bounds set.
        if (matchParentBounds()) {
            setBounds(null);
            return;
        }

        mTmpRect2.set(getRawBounds());
        final int newRotation = mDisplayContent.getDisplayInfo().rotation;
        final int newDensity = mDisplayContent.getDisplayInfo().logicalDensityDpi;
        if (mRotation == newRotation && mDensity == newDensity) {
            setBounds(mTmpRect2);
        }

        // If the rotation or density didn't match, we'll update it in onConfigurationChanged.
    }

    private Rect calculateBoundsForWindowModeChange() {
        final boolean inSplitScreenPrimary = inSplitScreenPrimaryWindowingMode();
        final TaskStack splitScreenStack =
+6 −2
Original line number Diff line number Diff line
@@ -42,8 +42,10 @@ import android.view.MagnificationSpec;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Builder;
import android.view.SurfaceSession;

import com.android.internal.util.ToBooleanFunction;
import com.android.server.wm.SurfaceAnimator.Animatable;

import java.io.PrintWriter;
import java.util.Comparator;
import java.util.LinkedList;
@@ -501,8 +503,10 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
    }

    /**
     * Notify that the display this container is on has changed.
     * @param dc The new display this container is on.
     * Notify that the display this container is on has changed. This could be either this container
     * is moved to a new display, or some configurations on the display it is on changes.
     *
     * @param dc The display this container is on after changes.
     */
    void onDisplayChanged(DisplayContent dc) {
        for (int i = mChildren.size() - 1; i >= 0; --i) {