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

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

Merge "Don't return null in WS.getTopParentWindow on child detach"

parents 5b4b66d5 ea92d977
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -2883,7 +2883,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        mShowToOwnerOnly = showToOwnerOnly;
    }

    boolean isHiddenFromUserLocked() {
    private boolean isHiddenFromUserLocked() {
        // Child windows are evaluated based on their parent window.
        final WindowState win = getTopParentWindow();
        if (win.mAttrs.type < FIRST_SYSTEM_WINDOW
@@ -3552,16 +3552,23 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP

    /** Returns the topmost parent window if this is a child of another window, else this. */
    WindowState getTopParentWindow() {
        WindowState w = this;
        while (w != null && w.mIsChildWindow) {
            w = w.getParentWindow();
        WindowState current = this;
        WindowState topParent = current;
        while (current != null && current.mIsChildWindow) {
            current = current.getParentWindow();
            // Parent window can be null if the child is detached from it's parent already, but
            // someone still has a reference to access it. So, we return the top parent value we
            // already have instead of null.
            if (current != null) {
                topParent = current;
            }
        return w;
        }
        return topParent;
    }

    boolean isParentWindowHidden() {
        final WindowState parent = getParentWindow();
        return (parent == null) ? false : parent.mHidden;
        return parent != null && parent.mHidden;
    }

    void setWillReplaceWindow(boolean animate) {
+5 −0
Original line number Diff line number Diff line
@@ -116,6 +116,11 @@ public class WindowStateTests extends WindowTestsBase {
        assertEquals(root, child1.getTopParentWindow());
        assertEquals(child1, child2.getParentWindow());
        assertEquals(root, child2.getTopParentWindow());

        // Test case were child is detached from parent.
        root.removeChild(child1);
        assertEquals(child1, child1.getTopParentWindow());
        assertEquals(child1, child2.getParentWindow());
    }

    @Test