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

Commit 91c2838a authored by Michael Wright's avatar Michael Wright
Browse files

Protect against null Displays.

Because the display callbacks happen asynchronously, if a display is
added or changed and then immediately removed it may no longer exist by
the time we query DisplayManager about it. This results in an unexpected
null Display object, causing DisplayModeDirector to crash. We guard
against this case, ignoring the display until it gets re-attached.

Fixes: 127875518
Test: manual
Change-Id: I32acd77a095181155dbcb57922f616b2ac57192c
parent 2fbf90c6
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -664,6 +664,12 @@ public class DisplayModeDirector {

        private void updateDisplayModes(int displayId) {
            Display d = mContext.getSystemService(DisplayManager.class).getDisplay(displayId);
            if (d == null) {
                // We can occasionally get a display added or changed event for a display that was
                // subsequently removed, which means this returns null. Check this case and bail
                // out early; if it gets re-attached we'll eventually get another call back for it.
                return;
            }
            DisplayInfo info = new DisplayInfo();
            d.getDisplayInfo(info);
            boolean changed = false;