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

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

Merge "Add override and merged config to WindowContainer"

parents 94f524dc 441e4494
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -729,9 +729,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree

        if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) {
            // We didn't call prepareFreezingBounds on the task, so use the current value.
            final Configuration config = new Configuration(mService.mGlobalConfiguration);
            config.updateFrom(mTask.mOverrideConfig);
            mFrozenMergedConfig.offer(config);
            mFrozenMergedConfig.offer(new Configuration(mTask.getConfiguration()));
        } else {
            mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig));
        }
+13 −4
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import static com.android.server.wm.WindowState.RESIZE_HANDLE_WIDTH_IN_DP;

import android.annotation.NonNull;
import android.app.ActivityManager.StackId;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.Region.Op;
@@ -210,18 +211,26 @@ class DisplayContent extends WindowContainer<TaskStack> {
        return null;
    }

    /** Callback used to notify about configuration changes. */
    void onConfigurationChanged(@NonNull List<Integer> changedStackList) {
    @Override
    void onConfigurationChanged(Configuration newParentConfig) {
        super.onConfigurationChanged(newParentConfig);

        // The display size information is heavily dependent on the resources in the current
        // configuration, so we need to reconfigure it every time the configuration changes.
        // See {@link PhoneWindowManager#setInitialDisplaySize}...sigh...
        mService.reconfigureDisplayLocked(this);

        getDockedDividerController().onConfigurationChanged();
    }

        for (int i = 0; i < mChildren.size(); i++) {
    /**
     * Callback used to trigger bounds update after configuration change and get ids of stacks whose
     * bounds were updated.
     */
    void updateStackBoundsAfterConfigChange(@NonNull List<Integer> changedStackList) {
        for (int i = mChildren.size() - 1; i >= 0; --i) {
            final TaskStack stack = mChildren.get(i);
            if (stack.onConfigurationChanged()) {
            if (stack.updateBoundsAfterConfigChange()) {
                changedStackList.add(stack.mStackId);
            }
        }
+2 −2
Original line number Diff line number Diff line
@@ -153,7 +153,7 @@ public class DockedStackDividerController implements DimLayerUser {
        // If the bounds are fullscreen, return the value of the fullscreen configuration
        if (bounds == null || (bounds.left == 0 && bounds.top == 0
                && bounds.right == di.logicalWidth && bounds.bottom == di.logicalHeight)) {
            return mService.mGlobalConfiguration.smallestScreenWidthDp;
            return mDisplayContent.getConfiguration().smallestScreenWidthDp;
        }
        final int baseDisplayWidth = mDisplayContent.mBaseDisplayWidth;
        final int baseDisplayHeight = mDisplayContent.mBaseDisplayHeight;
@@ -190,7 +190,7 @@ public class DockedStackDividerController implements DimLayerUser {
    }

    private void initSnapAlgorithmForRotations() {
        final Configuration baseConfig = mService.mGlobalConfiguration;
        final Configuration baseConfig = mDisplayContent.getConfiguration();

        // Initialize the snap algorithms for all 4 screen orientations.
        final Configuration config = new Configuration();
+20 −3
Original line number Diff line number Diff line
@@ -346,18 +346,35 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
        }
    }

    int[] onConfigurationChanged(Configuration config) {
    /** Set new config and return array of ids of stacks that were changed during update. */
    int[] setGlobalConfigurationIfNeeded(Configuration newConfiguration) {
        final boolean configChanged = getConfiguration().diff(newConfiguration) != 0;
        if (!configChanged) {
            return null;
        }
        onConfigurationChanged(newConfiguration);
        return updateStackBoundsAfterConfigChange();
    }

    @Override
    void onConfigurationChanged(Configuration newParentConfig) {
        prepareFreezingTaskBounds();
        mService.mGlobalConfiguration = new Configuration(config);
        super.onConfigurationChanged(newParentConfig);

        mService.mPolicy.onConfigurationChanged();
    }

    /**
     * Callback used to trigger bounds update after configuration change and get ids of stacks whose
     * bounds were updated.
     */
    int[] updateStackBoundsAfterConfigChange() {
        mChangedStackList.clear();

        final int numDisplays = mChildren.size();
        for (int i = 0; i < numDisplays; ++i) {
            final DisplayContent dc = mChildren.get(i);
            dc.onConfigurationChanged(mChangedStackList);
            dc.updateStackBoundsAfterConfigChange(mChangedStackList);
        }

        return mChangedStackList.isEmpty() ? null : ArrayUtils.convertToIntArray(mChangedStackList);
+13 −19
Original line number Diff line number Diff line
@@ -70,12 +70,6 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU
    // Whether mBounds is fullscreen
    private boolean mFillsParent = true;

    /**
     * Contains configurations settings that are different from the parent configuration due to
     * stack specific operations. E.g. {@link #setBounds}.
     */
    Configuration mOverrideConfig = Configuration.EMPTY;

    // For comparison with DisplayContent bounds.
    private Rect mTmpRect = new Rect();
    // For handling display rotations.
@@ -120,8 +114,9 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU
            }
        }

        if (wtoken.mParent != null) {
            wtoken.mParent.removeChild(wtoken);
        final WindowContainer parent = wtoken.getParent();
        if (parent != null) {
            parent.removeChild(wtoken);
        }
        addChild(wtoken, addPos);
        wtoken.mTask = this;
@@ -153,7 +148,7 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU
        if (content != null) {
            content.mDimLayerController.removeDimLayerUser(this);
        }
        mParent.removeChild(this);
        getParent().removeChild(this);
        mService.mTaskIdToTask.delete(mTaskId);
    }

@@ -165,7 +160,7 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU
        if (DEBUG_STACK) Slog.i(TAG, "moveTaskToStack: removing taskId=" + mTaskId
                + " from stack=" + mStack);
        EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, mTaskId, "moveTask");
        mParent.removeChild(this);
        getParent().removeChild(this);
        stack.addTask(this, toTop);
    }

@@ -254,7 +249,7 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU
        if (displayContent != null) {
            displayContent.mDimLayerController.updateDimLayer(this);
        }
        mOverrideConfig = mFillsParent ? Configuration.EMPTY : overrideConfig;
        onOverrideConfigurationChanged(mFillsParent ? Configuration.EMPTY : overrideConfig);
        return boundsChange;
    }

@@ -321,8 +316,7 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU
     */
    void prepareFreezingBounds() {
        mPreparedFrozenBounds.set(mBounds);
        mPreparedFrozenMergedConfig.setTo(mService.mGlobalConfiguration);
        mPreparedFrozenMergedConfig.updateFrom(mOverrideConfig);
        mPreparedFrozenMergedConfig.setTo(getConfiguration());
    }

    /**
@@ -334,9 +328,9 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU
     *                    bounds's bottom; false if the task's top should be aligned
     *                    the adjusted bounds's top.
     */
    void alignToAdjustedBounds(
            Rect adjustedBounds, Rect tempInsetBounds, boolean alignBottom) {
        if (!isResizeable() || mOverrideConfig == Configuration.EMPTY) {
    void alignToAdjustedBounds(Rect adjustedBounds, Rect tempInsetBounds, boolean alignBottom) {
        final Configuration overrideConfig = getOverrideConfiguration();
        if (!isResizeable() || Configuration.EMPTY.equals(overrideConfig)) {
            return;
        }

@@ -348,7 +342,7 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU
            mTmpRect2.offsetTo(adjustedBounds.left, adjustedBounds.top);
        }
        setTempInsetBounds(tempInsetBounds);
        resizeLocked(mTmpRect2, mOverrideConfig, false /* forced */);
        resizeLocked(mTmpRect2, overrideConfig, false /* forced */);
    }

    /** Return true if the current bound can get outputted to the rest of the system as-is. */
@@ -500,12 +494,12 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU
        mTmpRect2.set(mBounds);

        if (!StackId.isTaskResizeAllowed(mStack.mStackId)) {
            setBounds(mTmpRect2, mOverrideConfig);
            setBounds(mTmpRect2, getOverrideConfiguration());
            return;
        }

        displayContent.rotateBounds(mRotation, newRotation, mTmpRect2);
        if (setBounds(mTmpRect2, mOverrideConfig) != BOUNDS_CHANGE_NONE) {
        if (setBounds(mTmpRect2, getOverrideConfiguration()) != BOUNDS_CHANGE_NONE) {
            // Post message to inform activity manager of the bounds change simulating a one-way
            // call. We do this to prevent a deadlock between window manager lock and activity
            // manager lock been held.
Loading