summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
author Ben Lin <linben@google.com> 2025-02-20 17:22:24 +0000
committer Ben Lin <linben@google.com> 2025-02-20 23:22:48 -0800
commit1e893ffddd1dd05cb2dab1fdfc19f2305d860869 (patch)
tree3a0c3228b66ea121e93117b1f26b6a6469af12e8 /libs
parent78b9ad54c3e631d698dec65b0b4ce7421342abc3 (diff)
Add ActivityOptions.displayId when launching home intent.
When we launch home intents, either primary or secondary, we also must supply a displayId, or else Core will end up launching all home launcher types on the default display (e.g. launching secondary_launcher on primary display/moving it, which is not wanted). Bug: 397236350 Test: atest Flag:com.android.window.flags.enable_per_display_desktop_wallpaper_activity Change-Id: I907cf3f38ef449a5f0550ef06fa2b86ed33b0cf1
Diffstat (limited to 'libs')
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt3
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt17
2 files changed, 20 insertions, 0 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
index ca870d2b6988..87d967427d88 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt
@@ -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(
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
index 785fb3e875b8..f8803e850ce3 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
@@ -2809,6 +2809,7 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
// Should launch home
wct.assertPendingIntentAt(0, launchHomeIntent(DEFAULT_DISPLAY))
+ wct.assertPendingIntentActivityOptionsLaunchDisplayIdAt(0, DEFAULT_DISPLAY)
}
@Test
@@ -3910,6 +3911,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
@@ -3936,6 +3938,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
@@ -4068,6 +4071,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
@@ -4084,6 +4088,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
@@ -6877,6 +6882,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"