Consider tasks with INVALID_DISPLAY as it's on DEFAULT_DISPLAY
- In the test environment, some main display tasks can have INVALID_DISPLAY (-1) as their displayId, we should consider them as main display tasks or else they'll be sorted to an unexpected section in RecentsView
Bug: 391311008
Test: TaplTestsQuickstep#testQuickSwitchFromHome
Flag: com.android.launcher3.enable_separate_external_display_tasks
Change-Id: I5a89d91e342557e114eae6796e153a160d729301
diff --git a/quickstep/src/com/android/quickstep/util/ExternalDisplays.kt b/quickstep/src/com/android/quickstep/util/ExternalDisplays.kt
index e1a8578..455b312 100644
--- a/quickstep/src/com/android/quickstep/util/ExternalDisplays.kt
+++ b/quickstep/src/com/android/quickstep/util/ExternalDisplays.kt
@@ -17,6 +17,7 @@
package com.android.quickstep.util
import android.view.Display.DEFAULT_DISPLAY
+import android.view.Display.INVALID_DISPLAY
import com.android.systemui.shared.recents.model.Task
/** Whether this displayId belongs to an external display */
@@ -25,7 +26,14 @@
/** Returns displayId of this [Task], default to [DEFAULT_DISPLAY] */
val Task?.displayId
- get() = this?.key?.displayId ?: DEFAULT_DISPLAY
+ get() =
+ this?.key?.displayId.let { displayId ->
+ when (displayId) {
+ null -> DEFAULT_DISPLAY
+ INVALID_DISPLAY -> DEFAULT_DISPLAY
+ else -> displayId
+ }
+ }
/** Returns if this task belongs tto [DEFAULT_DISPLAY] */
val Task?.isExternalDisplay