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

Commit 37848f3f authored by Charles Chen's avatar Charles Chen
Browse files

Fix NPE in WMS

In RootWindowContainer#getTopFocusedDisplayContent(), there is a chance
which the external display is disconected but mTopFocusedDisplayId is
not yet updated, which cause NPE when trying to use DisplayContent field
returned by RootWindowContainer#getTopFocusedDisplayContent().

Reroute to default displayContent when top focused displayContent is
null.

fix: 124773022
Test: atest WmTests

Change-Id: I8c59fd4f43ac17a44f643e75829e546487a8d4ec
parent 01794b57
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -193,8 +193,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
    }

    DisplayContent getTopFocusedDisplayContent() {
        return getDisplayContent(mTopFocusedDisplayId == INVALID_DISPLAY
                ? DEFAULT_DISPLAY : mTopFocusedDisplayId);
        final DisplayContent dc = getDisplayContent(mTopFocusedDisplayId);
        return dc != null ? dc : getDisplayContent(DEFAULT_DISPLAY);
    }

    @Override
@@ -1045,6 +1045,15 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        mWmService.scheduleAnimationLocked();
    }

    @Override
    protected void removeChild(DisplayContent dc) {
        super.removeChild(dc);
        if (mTopFocusedDisplayId == dc.getDisplayId()) {
            mWmService.updateFocusedWindowLocked(
                    UPDATE_FOCUS_NORMAL, true /* updateInputWindows */);
        }
    }

    /**
     * For all display at or below this call the callback.
     *