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

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

Merge "Allow DisplayContent children to be removed on display removal"

parents 03e09c17 601a3f08
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -165,6 +165,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    private final GetWindowOnDisplaySearchResult mTmpGetWindowOnDisplaySearchResult =
            new GetWindowOnDisplaySearchResult();

    // True if this display is in the process of being removed. Used to determine if the removal of
    // the display's direct children should be allowed.
    private boolean mRemovingDisplay = false;

    /**
     * @param display May not be null.
     * @param service You know.
@@ -433,6 +437,12 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

    @Override
    protected void removeChild(DisplayChildWindowContainer child) {
        // Only allow removal of direct children from this display if the display is in the process
        // of been removed.
        if (mRemovingDisplay) {
            super.removeChild(child);
            return;
        }
        throw new UnsupportedOperationException("See DisplayChildWindowContainer");
    }

@@ -565,6 +575,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo

    @Override
    void removeImmediately() {
        mRemovingDisplay = true;
        try {
            super.removeImmediately();
            if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Removing display=" + this);
            mDimLayerController.close();
@@ -572,6 +584,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
                mService.unregisterPointerEventListener(mTapDetector);
                mService.unregisterPointerEventListener(mService.mMousePositionTracker);
            }
        } finally {
            mRemovingDisplay = false;
        }
    }

    /** Returns true if a removal action is still being deferred. */