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

Commit 8c9b5dfc authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "No-op when deactivating non-existent desk roots instead of throwing" into main

parents 5d61faac 21da8120
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -240,7 +240,17 @@ class RootTaskDesksOrganizer(
            "RootTaskDesksOrganizer#deactivateDesk: $deskId",
        )
        logV("deactivateDesk %d", deskId)
        val root = checkNotNull(deskRootsByDeskId[deskId]) { "Root not found for desk: $deskId" }
        val root = deskRootsByDeskId[deskId]
        if (root == null) {
            // This is possible because a deactivation might be requested soon after a removal as
            // part of the same two-part recents transition (so not the same WCT), so if the
            // removal (all the way through onTaskVanish) is faster than the second part of the
            // transition, the desk root will have been removed already. See b/427563407.
            // No-op in this case, since the desk is already gone anyway it doesn't matter whether
            // it is deactivated.
            logW("Attempted to deactivate non-existent desk=%d", deskId)
            return
        }
        if (!skipReorder) wct.reorder(root.taskInfo.token, /* onTop= */ false)
        updateLaunchRoot(wct, deskId, enabled = false)
        updateTaskMoveAllowed(wct, deskId, allowed = false)
+16 −0
Original line number Diff line number Diff line
@@ -752,6 +752,22 @@ class RootTaskDesksOrganizerTest : ShellTestCase() {
            .isFalse()
    }

    @Test
    fun testDeactivateDesk_deskWasRemoved_skipsInsteadOfThrowing() = runTest {
        val desk = createDeskSuspending(userId = PRIMARY_USER_ID)
        organizer.removeDesk(
            wct = WindowContainerTransaction(),
            deskId = desk.deskRoot.deskId,
            userId = PRIMARY_USER_ID,
        )
        organizer.onTaskVanished(desk.deskRoot.taskInfo)

        val wct = WindowContainerTransaction()
        organizer.deactivateDesk(wct, desk.deskRoot.deskId)

        assertThat(wct.isEmpty).isTrue()
    }

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