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

Commit 5ce57237 authored by Toshiki Kikuchi's avatar Toshiki Kikuchi
Browse files

Fix NPE in updateDisplayWindowingMode

This CL fixes the crash issue in CTS which uses non-trusted overlay
displays.
Such a display is not “organized” by the DisplayOrganizer so
DisplayAreaInfo can be null.

Bug: 406106717
Flag: com.android.window.flags.enable_display_windowing_mode_switching
Flag: com.android.server.display.feature.flags.enable_display_content_mode_management
Test: android.server.wm.multidisplay.MultiDisplaySystemDecorationTests
Change-Id: I2dd81510a73736eeb0392256349f9619e5a764a1
parent a867d0e5
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -97,9 +97,16 @@ class DesktopDisplayModeController(
    }

    private fun updateDisplayWindowingMode(displayId: Int, targetDisplayWindowingMode: Int) {
        val tdaInfo =
            requireNotNull(rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId)) {
                "DisplayAreaInfo of display#$displayId must be non-null."
        val tdaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId)
        // A non-organized display (e.g., non-trusted virtual displays used in CTS) doesn't have
        // TDA.
        if (tdaInfo == null) {
            logW(
                "updateDisplayWindowingMode cannot find DisplayAreaInfo for displayId=%d. This " +
                    " could happen when the display is a non-trusted virtual display.",
                displayId,
            )
            return
        }
        val currentDisplayWindowingMode = tdaInfo.configuration.windowConfiguration.windowingMode
        if (currentDisplayWindowingMode == targetDisplayWindowingMode) {
@@ -220,6 +227,10 @@ class DesktopDisplayModeController(
        ProtoLog.v(WM_SHELL_DESKTOP_MODE, "%s: $msg", TAG, *arguments)
    }

    private fun logW(msg: String, vararg arguments: Any?) {
        ProtoLog.w(WM_SHELL_DESKTOP_MODE, "%s: $msg", TAG, *arguments)
    }

    companion object {
        private const val TAG = "DesktopDisplayModeController"
    }