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

Commit d88421cf authored by Ben Lin's avatar Ben Lin Committed by Android (Google) Code Review
Browse files

Merge "Add ActivityOptions.displayId when launching home intent." into main

parents 65cb1de7 1e893ffd
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1745,6 +1745,9 @@ class DesktopTasksController(
                launchWindowingMode = WINDOWING_MODE_FULLSCREEN
                pendingIntentBackgroundActivityStartMode =
                    ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS
                if (Flags.enablePerDisplayDesktopWallpaperActivity()) {
                    launchDisplayId = displayId
                }
            }
        val pendingIntent =
            PendingIntent.getActivityAsUser(
+17 −0
Original line number Diff line number Diff line
@@ -2809,6 +2809,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()

        // Should launch home
        wct.assertPendingIntentAt(0, launchHomeIntent(DEFAULT_DISPLAY))
        wct.assertPendingIntentActivityOptionsLaunchDisplayIdAt(0, DEFAULT_DISPLAY)
    }

    @Test
@@ -3931,6 +3932,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        // Should launch home
        assertNotNull(result, "Should handle request")
            .assertPendingIntentAt(0, launchHomeIntent(DEFAULT_DISPLAY))
        result!!.assertPendingIntentActivityOptionsLaunchDisplayIdAt(0, DEFAULT_DISPLAY)
    }

    @Test
@@ -3957,6 +3959,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        // Should launch home
        assertNotNull(result, "Should handle request")
            .assertPendingIntentAt(0, launchHomeIntent(DEFAULT_DISPLAY))
        result!!.assertPendingIntentActivityOptionsLaunchDisplayIdAt(0, DEFAULT_DISPLAY)
    }

    @Test
@@ -4089,6 +4092,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        // Should launch home
        assertNotNull(result, "Should handle request")
            .assertPendingIntentAt(0, launchHomeIntent(DEFAULT_DISPLAY))
        result!!.assertPendingIntentActivityOptionsLaunchDisplayIdAt(0, DEFAULT_DISPLAY)
    }

    @Test
@@ -4105,6 +4109,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        // Should launch home
        assertNotNull(result, "Should handle request")
            .assertPendingIntentAt(0, launchHomeIntent(SECOND_DISPLAY))
        result!!.assertPendingIntentActivityOptionsLaunchDisplayIdAt(0, SECOND_DISPLAY)
    }

    @Test
@@ -6898,6 +6903,18 @@ private fun WindowContainerTransaction.assertPendingIntentAt(index: Int, intent:
    assertThat(op.pendingIntent?.intent?.categories).isEqualTo(intent.categories)
}

private fun WindowContainerTransaction.assertPendingIntentActivityOptionsLaunchDisplayIdAt(
    index: Int,
    displayId: Int,
) {
    assertIndexInBounds(index)
    val op = hierarchyOps[index]
    if (op.launchOptions != null) {
        val options = ActivityOptions(op.launchOptions)
        assertThat(options.launchDisplayId).isEqualTo(displayId)
    }
}

private fun WindowContainerTransaction.assertLaunchTask(taskId: Int, windowingMode: Int) {
    val keyLaunchWindowingMode = "android.activity.windowingMode"