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

Commit b79009dd authored by mattsziklay's avatar mattsziklay
Browse files

Fall back to system DEFAULT_DISPLAY on disconnect if needed.

In some cases, user will not have a main display assigned, which causes
a crash in disconnectDisplay as we end up attempting to perform
disconnect on an invalid display.

Fixes this crash by falling back to DEFAULT_DISPLAY, similar to behavior
in TaskDisplayArea#getReparentToTaskDisplayArea

Bug: 433962634
Flag: com.android.window.flags.enable_display_disconnect_interaction
Test: Manual
Change-Id: I7de45beaa484d818acbc0d76a8636d1c3550dbaa
parent 2ec5f298
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -695,8 +695,12 @@ class DesktopTasksController(
    /** Start a disconnect transition directly in Shell. */
    fun disconnectDisplay(disconnectedDisplayId: Int) {
        logD("disconnectDisplay: disconnectedDisplayId=$disconnectedDisplayId")
        val disconnectReparentDisplay =
        var disconnectReparentDisplay =
            UserManager.get(userProfileContexts.userContext).mainDisplayIdAssignedToUser
        // If user has no default display configured, fall back to DEFAULT_DISPLAY
        if (disconnectReparentDisplay == INVALID_DISPLAY) {
            disconnectReparentDisplay = DEFAULT_DISPLAY
        }
        val wct = WindowContainerTransaction()
        val runOnTransitStart =
            addOnDisplayDisconnectChanges(wct, disconnectedDisplayId, disconnectReparentDisplay)