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

Commit a831b323 authored by Jorge Gil's avatar Jorge Gil Committed by Android (Google) Code Review
Browse files

Merge "Do not crash when root appears without matching request" into main

parents 94ef3b54 3d1b6a60
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -503,6 +503,13 @@ class RootTaskDesksOrganizer(
        }

        val appearingInDisplayId = taskInfo.displayId
        logV(
            "Task #%d appeared in display #%d, deskRootRequests=%s minimizationRootRequests=%s",
            taskInfo.taskId,
            appearingInDisplayId,
            createDeskRootRequests,
            createDeskMinimizationRootRequests,
        )
        // Check if there's any pending desk creation requests under this display.
        val deskRequest =
            createDeskRootRequests.firstOrNull { it.displayId == appearingInDisplayId }
@@ -538,7 +545,15 @@ class RootTaskDesksOrganizer(
        }
        // Check if there's any pending minimization container creation requests under this display.
        val deskMinimizationRootRequest =
            createDeskMinimizationRootRequests.first { it.displayId == appearingInDisplayId }
            createDeskMinimizationRootRequests.firstOrNull { it.displayId == appearingInDisplayId }
        if (deskMinimizationRootRequest == null) {
            logE(
                "Did not find a matching desk minimization root request for task#%d in display#%d",
                taskInfo.taskId,
                taskInfo.displayId,
            )
            return
        }
        val deskId = deskMinimizationRootRequest.deskId
        logV("Minimization container for desk #$deskId appeared with id=${taskInfo.taskId}")
        val deskMinimizationRoot = DeskMinimizationRoot(deskId, taskInfo, leash)
+0 −9
Original line number Diff line number Diff line
@@ -298,15 +298,6 @@ class RootTaskDesksOrganizerTest : ShellTestCase() {
            )
    }

    @Test
    fun testOnTaskAppeared_withoutRequest_throws() = runTest {
        val freeformRoot = createFreeformTask().apply { parentTaskId = -1 }

        assertThrows(Exception::class.java) {
            organizer.onTaskAppeared(freeformRoot, SurfaceControl())
        }
    }

    @Test
    fun testOnTaskAppeared_duplicateRoot_throws() = runTest {
        val desk = createDeskSuspending()