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

Commit ba51ca2c authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Fixed some test failure and log warnings.

- Make DisplayContent.attachStack and moveStack use the same code
path for adding child stack so they both account for the presence
of pinnded stack.
- Don't call DC.attachStack on a stack that is already on the
display. Use DC.removeStack instead to just make sure it is at the
right z-order on the display.
- Use WindowContainer.getName() when for exception messages to have
a more concise print-out for the error.
- Only try to remove a task from a stack when positioning if the task
is contained in the stack.
- Throw an exception if we try to remove a task that isn't contained
in a stack.
- Skip checking of exiting or waiting for replacement when rebuilding
window list for app tokens that are exiting.
- Properly display and intent output from WC.dumpChildrenNames().
- Have DisplayContent WindowContainer type always return true for
fillsParent() and isVisible() as displays always fill their parent
and always visible for now.

Bug: 31624623
Test: Failing test passes.
Change-Id: I8a84770feb1fd278716755cdec2900fddb9940de
parent 4d44f2da
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -1100,12 +1100,16 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        }
    }

    int rebuildWindowListUnchecked(DisplayContent dc, int addIndex) {
        return super.rebuildWindowList(dc, addIndex);
    }

    @Override
    int rebuildWindowList(DisplayContent dc, int addIndex) {
        if (mIsExiting && !waitingForReplacement()) {
            return addIndex;
        }
        return super.rebuildWindowList(dc, addIndex);
        return rebuildWindowListUnchecked(dc, addIndex);
    }

    @Override
@@ -1187,6 +1191,6 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
            sb.append(" token="); sb.append(token); sb.append('}');
            stringName = sb.toString();
        }
        return stringName;
        return stringName + ((mIsExiting) ? " mIsExiting=" : "");
    }
}
+24 −9
Original line number Diff line number Diff line
@@ -183,11 +183,11 @@ class DisplayContent extends WindowContainer<TaskStack> {
    /**
     * Returns true if the specified UID has access to this display.
     */
    public boolean hasAccess(int uid) {
    boolean hasAccess(int uid) {
        return mDisplay.hasAccess(uid);
    }

    public boolean isPrivate() {
    boolean isPrivate() {
        return (mDisplay.getFlags() & Display.FLAG_PRIVATE) != 0;
    }

@@ -237,11 +237,23 @@ class DisplayContent extends WindowContainer<TaskStack> {
        super.stepAppWindowsAnimation(currentTime, mDisplayId);
    }

    @Override
    boolean fillsParent() {
        return true;
    }

    @Override
    boolean isVisible() {
        return true;
    }

    @Override
    void onAppTransitionDone() {
        super.onAppTransitionDone();
        rebuildAppWindowList();
    }

    @Override
    int getOrientation() {
        if (mService.isStackVisibleLocked(DOCKED_STACK_ID)
                || mService.isStackVisibleLocked(FREEFORM_WORKSPACE_STACK_ID)) {
@@ -322,8 +334,7 @@ class DisplayContent extends WindowContainer<TaskStack> {
            }
            mHomeStack = stack;
        }
        addChild(stack, onTop ? mChildren.size() : 0);
        layoutNeeded = true;
        addChild(stack, onTop);
    }

    void moveStack(TaskStack stack, boolean toTop) {
@@ -337,7 +348,10 @@ class DisplayContent extends WindowContainer<TaskStack> {
            Slog.wtf(TAG_WM, "moving stack that was not added: " + stack, new Throwable());
        }
        removeChild(stack);
        addChild(stack, toTop);
    }

    private void addChild(TaskStack stack, boolean toTop) {
        int addIndex = toTop ? mChildren.size() : 0;

        if (toTop
@@ -352,6 +366,7 @@ class DisplayContent extends WindowContainer<TaskStack> {
            }
        }
        addChild(stack, addIndex);
        layoutNeeded = true;
    }

    /**
@@ -1063,7 +1078,7 @@ class DisplayContent extends WindowContainer<TaskStack> {
            AppTokenList exitingAppTokens = mChildren.get(stackNdx).mExitingAppTokens;
            int NT = exitingAppTokens.size();
            for (int j = 0; j < NT; j++) {
                i = exitingAppTokens.get(j).rebuildWindowList(this, i);
                i = exitingAppTokens.get(j).rebuildWindowListUnchecked(this, i);
            }
        }

@@ -1090,7 +1105,7 @@ class DisplayContent extends WindowContainer<TaskStack> {
                    ws.mWinAnimator.destroySurfaceLocked();
                }
            }
            Slog.w(TAG_WM, "Current app token list:");
            Slog.w(TAG_WM, "Current window hierarchy:");
            dumpChildrenNames();
            Slog.w(TAG_WM, "Final window list:");
            dumpWindows();
@@ -1188,9 +1203,9 @@ class DisplayContent extends WindowContainer<TaskStack> {
    }

    private void dumpChildrenNames() {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new FastPrintWriter(sw, false, 1024);
        dumpChildrenNames(pw, "  ");
        StringBuilder output = new StringBuilder();
        dumpChildrenNames(output, " ");
        Slog.v(TAG_WM, output.toString());
    }

    private void dumpWindows() {
+12 −3
Original line number Diff line number Diff line
@@ -232,8 +232,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {

            stack = dc.getStackById(stackId);
            if (stack != null) {
                // It's already attached to the display...clear mDeferRemoval!
                // It's already attached to the display...clear mDeferRemoval and move stack to
                // appropriate z-order on display as needed.
                stack.mDeferRemoval = false;
                dc.moveStack(stack, onTop);
                attachedToDisplay = true;
            } else {
                stack = new TaskStack(mService, stackId);
@@ -245,14 +247,16 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
                        .notifyDockedStackExistsChanged(true);
            }
        }

        if (!attachedToDisplay) {
            stack.attachDisplayContent(dc);
        }
            dc.attachStack(stack, onTop);
        }

        if (stack.getRawFullscreen()) {
            return null;
        }
        Rect bounds = new Rect();
        final Rect bounds = new Rect();
        stack.getRawBounds(bounds);
        return bounds;
    }
@@ -1425,4 +1429,9 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
            }
        }
    }

    @Override
    String getName() {
        return "ROOT";
    }
}
+3 −5
Original line number Diff line number Diff line
@@ -493,7 +493,9 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
    void positionTask(Task task, int position, boolean showForAllUsers) {
        final boolean canShowTask =
                showForAllUsers || mService.isCurrentProfileLocked(task.mUserId);
        removeChild(task);
        if (mChildren.contains(task)) {
            super.removeChild(task);
        }
        int stackSize = mChildren.size();
        int minPosition = 0;
        int maxPosition = stackSize;
@@ -589,10 +591,6 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
    @Override
    void removeChild(Task task) {
        if (DEBUG_TASK_MOVEMENT) Slog.d(TAG_WM, "removeChild: task=" + task);
        if (!mChildren.contains(task)) {
            Slog.e(TAG_WM, "removeChild: task=" + this + " not found.");
            return;
        }

        super.removeChild(task);

+15 −14
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.server.wm;
import android.annotation.CallSuper;
import android.view.animation.Animation;

import java.io.PrintWriter;
import java.util.Comparator;
import java.util.LinkedList;

@@ -63,9 +62,9 @@ class WindowContainer<E extends WindowContainer> implements Comparable<WindowCon
    @CallSuper
    protected void addChild(E child, Comparator<E> comparator) {
        if (child.mParent != null) {
            throw new IllegalArgumentException("addChild: container=" + child
                    + " is already a child of container=" + child.mParent
                    + " can't add to container=" + this);
            throw new IllegalArgumentException("addChild: container=" + child.getName()
                    + " is already a child of container=" + child.mParent.getName()
                    + " can't add to container=" + getName());
        }
        child.mParent = this;

@@ -89,9 +88,9 @@ class WindowContainer<E extends WindowContainer> implements Comparable<WindowCon
    @CallSuper
    protected void addChild(E child, int index) {
        if (child.mParent != null) {
            throw new IllegalArgumentException("addChild: container=" + child
                    + " is already a child of container=" + child.mParent
                    + " can't add to container=" + this);
            throw new IllegalArgumentException("addChild: container=" + child.getName()
                    + " is already a child of container=" + child.mParent.getName()
                    + " can't add to container=" + getName());
        }
        child.mParent = this;
        mChildren.add(index, child);
@@ -107,8 +106,8 @@ class WindowContainer<E extends WindowContainer> implements Comparable<WindowCon
        if (mChildren.remove(child)) {
            child.mParent = null;
        } else {
            throw new IllegalArgumentException("removeChild: container=" + child
                    + " is not a child of container=" + this);
            throw new IllegalArgumentException("removeChild: container=" + child.getName()
                    + " is not a child of container=" + getName());
        }
    }

@@ -469,12 +468,14 @@ class WindowContainer<E extends WindowContainer> implements Comparable<WindowCon
     * Dumps the names of this container children in the input print writer indenting each
     * level with the input prefix.
     */
    void dumpChildrenNames(PrintWriter pw, String prefix) {
        final String childPrefix = prefix + prefix;
        for (int i = mChildren.size() - 1; i >= 0; --i) {
    void dumpChildrenNames(StringBuilder out, String prefix) {
        final String childPrefix = prefix + " ";
        out.append(getName() + "\n");
        final int count = mChildren.size();
        for (int i = 0; i < count; i++) {
            final WindowContainer wc = mChildren.get(i);
            pw.println("#" + i + " " + getName());
            wc.dumpChildrenNames(pw, childPrefix);
            out.append(childPrefix + "#" + i + " ");
            wc.dumpChildrenNames(out, childPrefix);
        }
    }

Loading