[1/N] Replace global userId with per-function argument
To allow reusing DesktopTasksController functions that build WCTs for
desktop operations for cases where the intended user is not current
(such as during user-switching), this change removes the |userId| member
variable from inner functions are replaces it with a |userId| argument
to be passed by callers. The source of |userId|s become the
TaskInfo.userId when available or ShellController.currentUserId when we
do really mean to use the current user. ShellController is the source of
truth for Shell, so use that instead of manually tracking user id
changes.
A follow up change will do the same for usages of |taskRepository|.
This is a refactor to prepare for a future change where a transition
request with user change info requires restoring the active desk of an
incoming user (which would not be "current" yet to SystemUI/Shell) and
deactivating the activate desk of the outgoing user.
Flag: EXEMPT refactor
Bug: 430988310
Bug: 406255019
Test: atest WMShellUnitTest
Change-Id: Id4e34724b5728d6739ce7ff56ed93a09494c6ad3
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopDisplayEventHandler.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopDisplayEventHandler.kt
index e1e9832..95eaa8b 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopDisplayEventHandler.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopDisplayEventHandler.kt
@@ -185,16 +185,20 @@
}
private fun handlePotentialReconnect(displayId: Int): Boolean {
- val uniqueDisplayId = displayController.getDisplay(displayId)?.uniqueId
- uniqueDisplayId?.let {
- uniqueIdByDisplayId[displayId] = it
- if (
- DesktopExperienceFlags.ENABLE_DISPLAY_RECONNECT_INTERACTION.isTrue &&
- desktopUserRepositories.current.hasPreservedDisplayForUniqueDisplayId(it)
- ) {
- desktopTasksController.restoreDisplay(displayId, it)
- return true
- }
+ val uniqueDisplayId = displayController.getDisplay(displayId)?.uniqueId ?: return false
+ uniqueIdByDisplayId[displayId] = uniqueDisplayId
+ if (
+ DesktopExperienceFlags.ENABLE_DISPLAY_RECONNECT_INTERACTION.isTrue &&
+ desktopUserRepositories.current.hasPreservedDisplayForUniqueDisplayId(
+ uniqueDisplayId
+ )
+ ) {
+ desktopTasksController.restoreDisplay(
+ displayId = displayId,
+ uniqueDisplayId = uniqueDisplayId,
+ userId = desktopUserRepositories.current.userId,
+ )
+ return true
}
return false
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeShellCommandHandler.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeShellCommandHandler.kt
index 1d91985..00ac30f 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeShellCommandHandler.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeShellCommandHandler.kt
@@ -203,9 +203,9 @@
return false
}
controller.moveTaskToFront(
- /* taskId= */ taskId,
- /* remoteTransition= */ null,
- /* unminimizeReason= */ UnminimizeReason.UNKNOWN,
+ taskId = taskId,
+ remoteTransition = null,
+ unminimizeReason = UnminimizeReason.UNKNOWN,
)
return true
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopPipTransitionController.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopPipTransitionController.kt
index 52f07aa..cff53a5 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopPipTransitionController.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopPipTransitionController.kt
@@ -316,6 +316,7 @@
wct = wct,
deskId = deskId,
displayId = displayId,
+ userId = taskInfo.userId,
willExitDesktop = true,
removingLastTaskId = taskId,
exitReason = ExitReason.ENTER_PIP,
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 15a395a..0d783b3 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
@@ -258,7 +258,6 @@
private val desktopMode: DesktopModeImpl
private var taskRepository: DesktopRepository
private var visualIndicator: DesktopModeVisualIndicator? = null
- private var userId: Int
private val desktopModeShellCommandHandler: DesktopModeShellCommandHandler =
DesktopModeShellCommandHandler(this, focusTransitionObserver)
private val latencyTracker: LatencyTracker
@@ -315,8 +314,7 @@
if (desktopState.canEnterDesktopMode) {
shellInit.addInitCallback({ onInit() }, this)
}
- userId = ActivityManager.getCurrentUser()
- taskRepository = userRepositories.getProfile(userId)
+ taskRepository = userRepositories.getProfile(ActivityManager.getCurrentUser())
latencyTracker = LatencyTracker.getInstance(context)
if (DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) {
@@ -402,11 +400,12 @@
@Deprecated("Use activateDesk() instead.", ReplaceWith("activateDesk()"))
fun showDesktopApps(
displayId: Int,
+ userId: Int = shellController.currentUserId,
remoteTransition: RemoteTransition? = null,
taskIdToReorderToFront: Int? = null,
) {
logV("showDesktopApps")
- activateDefaultDeskInDisplay(displayId, remoteTransition, taskIdToReorderToFront)
+ activateDefaultDeskInDisplay(displayId, userId, remoteTransition, taskIdToReorderToFront)
}
/** Returns whether the given display has an active desk. */
@@ -514,10 +513,12 @@
}
/** Called when the recents transition that started while in desktop is finishing. */
+ @JvmOverloads
fun onRecentsInDesktopAnimationFinishing(
transition: IBinder,
finishWct: WindowContainerTransaction,
returnToApp: Boolean,
+ userId: Int = shellController.currentUserId,
activeDeskIdOnRecentsStart: Int?,
) {
if (!DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) return
@@ -533,9 +534,10 @@
snapEventHandler.onRecentsAnimationEndedToSameDesk()
return
}
+ val repository = userRepositories.getProfile(userId)
if (
activeDeskIdOnRecentsStart == null ||
- !taskRepository.isDeskActive(activeDeskIdOnRecentsStart)
+ !repository.isDeskActive(activeDeskIdOnRecentsStart)
) {
// No desk was active or it is already inactive.
return
@@ -548,6 +550,7 @@
wct = finishWct,
deskId = activeDeskIdOnRecentsStart,
displayId = DEFAULT_DISPLAY,
+ userId = userId,
willExitDesktop = true,
removingLastTaskId = null,
// No need to clean up the wallpaper / home when coming from a recents transition.
@@ -571,7 +574,7 @@
*/
fun createDesk(
displayId: Int,
- userId: Int = this.userId,
+ userId: Int = shellController.currentUserId,
enforceDeskLimit: Boolean = true,
activateDesk: Boolean = false,
onResult: ((Int) -> Unit) = {},
@@ -607,7 +610,7 @@
}
@Deprecated("Use createDeskSuspending() instead.", ReplaceWith("createDeskSuspending()"))
- private fun createDeskImmediate(displayId: Int, userId: Int = this.userId): Int? {
+ private fun createDeskImmediate(displayId: Int, userId: Int): Int? {
logV("createDeskImmediate displayId=%d, userId=%d", displayId, userId)
val repository = userRepositories.getProfile(userId)
val deskId = createDeskRootImmediate(displayId, userId)
@@ -630,11 +633,7 @@
}
}
- private fun createDeskRoot(
- displayId: Int,
- userId: Int = this.userId,
- onResult: (Int?) -> Unit,
- ) {
+ private fun createDeskRoot(displayId: Int, userId: Int, onResult: (Int?) -> Unit) {
if (displayId == Display.INVALID_DISPLAY) {
logW("createDesk attempt with invalid displayId", displayId)
onResult(null)
@@ -691,7 +690,7 @@
return desksOrganizer.createDeskImmediate(displayId, userId)
}
- private suspend fun createDeskRootSuspending(displayId: Int, userId: Int = this.userId): Int? =
+ private suspend fun createDeskRootSuspending(displayId: Int, userId: Int): Int? =
suspendCoroutine { cont ->
createDeskRoot(displayId, userId) { deskId -> cont.resumeWith(Result.success(deskId)) }
}
@@ -860,24 +859,24 @@
*
* TODO: b/365873835 - Restore for all users, not just current.
*/
- fun restoreDisplay(displayId: Int, uniqueDisplayId: String) {
- logD("restoreDisplay: displayId=$displayId, uniqueDisplayId=$uniqueDisplayId")
+ fun restoreDisplay(displayId: Int, uniqueDisplayId: String, userId: Int) {
+ logD(
+ "restoreDisplay: displayId=%d, uniqueDisplayId=%d userId=%d",
+ displayId,
+ uniqueDisplayId,
+ userId,
+ )
// TODO: b/365873835 - Utilize DesktopTask data class once it is
// implemented in DesktopRepository.
- val preservedTaskIdsByDeskId =
- taskRepository.getPreservedTasksByDeskIdInZOrder(uniqueDisplayId)
- val boundsByTaskId = taskRepository.getPreservedTaskBounds(uniqueDisplayId)
- val activeDeskId = taskRepository.getPreservedActiveDesk(uniqueDisplayId)
+ val repository = userRepositories.getProfile(userId)
+ val preservedTaskIdsByDeskId = repository.getPreservedTasksByDeskIdInZOrder(uniqueDisplayId)
+ val boundsByTaskId = repository.getPreservedTaskBounds(uniqueDisplayId)
+ val activeDeskId = repository.getPreservedActiveDesk(uniqueDisplayId)
val wct = WindowContainerTransaction()
var runOnTransitStart: RunOnTransitStart? = null
val destDisplayLayout = displayController.getDisplayLayout(displayId) ?: return
val tilingReconnectHandler =
- TilingDisplayReconnectEventHandler(
- taskRepository,
- snapEventHandler,
- transitions,
- displayId,
- )
+ TilingDisplayReconnectEventHandler(repository, snapEventHandler, transitions, displayId)
mainScope.launch {
preservedTaskIdsByDeskId.forEach { (preservedDeskId, preservedTaskIds) ->
val newDeskId =
@@ -912,7 +911,7 @@
}
val preservedTilingData =
- taskRepository.getPreservedTilingData(uniqueDisplayId, preservedDeskId)
+ repository.getPreservedTilingData(uniqueDisplayId, preservedDeskId)
if (preservedTilingData != null) {
tilingReconnectHandler.addTilingDisplayReconnectSession(
TilingDisplayReconnectEventHandler.TilingDisplayReconnectSession(
@@ -927,7 +926,7 @@
val transition = transitions.startTransition(TRANSIT_CHANGE, wct, null)
tilingReconnectHandler.activationBinder = transition
runOnTransitStart?.invoke(transition)
- taskRepository.removePreservedDisplay(uniqueDisplayId)
+ repository.removePreservedDisplay(uniqueDisplayId)
}
}
@@ -1043,6 +1042,7 @@
return false
}
val displayId = getDisplayIdForTaskOrDefault(task)
+ val userId = task.userId
if (
DesktopExperienceFlags.ENABLE_PROJECTED_DISPLAY_DESKTOP_MODE.isTrue &&
!desktopState.isDesktopModeSupportedOnDisplay(displayId) &&
@@ -1056,7 +1056,7 @@
!DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue ||
!DesktopExperienceFlags.ENABLE_DEFAULT_DESK_WITHOUT_WARMUP_MIGRATION.isTrue
) {
- val deskId = getOrCreateDefaultDeskId(displayId) ?: return false
+ val deskId = getOrCreateDefaultDeskId(displayId, userId) ?: return false
return moveTaskToDesk(
taskId = taskId,
deskId = deskId,
@@ -1070,7 +1070,7 @@
try {
moveTaskToDesk(
taskId = taskId,
- deskId = getOrCreateDefaultDeskIdSuspending(displayId),
+ deskId = getOrCreateDefaultDeskIdSuspending(displayId, userId),
wct = wct,
transitionSource = transitionSource,
remoteTransition = remoteTransition,
@@ -1276,7 +1276,7 @@
* [startDragToDesktop].
*/
private fun finalizeDragToDesktop(taskInfo: RunningTaskInfo) {
- val deskId = getOrCreateDefaultDeskId(taskInfo.displayId) ?: return
+ val deskId = getOrCreateDefaultDeskId(taskInfo.displayId, taskInfo.userId) ?: return
ProtoLog.v(
WM_SHELL_DESKTOP_MODE,
"DesktopTasksController: finalizeDragToDesktop taskId=%d deskId=%d",
@@ -1356,7 +1356,9 @@
taskInfo: RunningTaskInfo,
): ((IBinder) -> Unit) {
val taskId = taskInfo.taskId
- val deskId = taskRepository.getDeskIdForTask(taskInfo.taskId)
+ val userId = taskInfo.userId
+ val repository = userRepositories.getProfile(userId)
+ val deskId = repository.getDeskIdForTask(taskInfo.taskId)
if (deskId == null && DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) {
error("Did not find desk for task: $taskId")
}
@@ -1370,11 +1372,12 @@
val desktopExitRunnable =
if (shouldExitDesktop) {
val isLastTask =
- deskId?.let { taskRepository.isOnlyTaskInDesk(taskInfo.taskId, it) } ?: false
+ deskId?.let { repository.isOnlyTaskInDesk(taskInfo.taskId, it) } ?: false
performDesktopExitCleanUp(
wct = wct,
deskId = deskId,
displayId = displayId,
+ userId = userId,
willExitDesktop = true,
removingLastTaskId = if (isLastTask) taskInfo.taskId else null,
shouldEndUpAtHome = true,
@@ -1384,7 +1387,7 @@
null
}
- taskRepository.addClosingTask(displayId = displayId, deskId = deskId, taskId = taskId)
+ repository.addClosingTask(displayId = displayId, deskId = deskId, taskId = taskId)
taskbarDesktopTaskListener?.onTaskbarCornerRoundingUpdate(
doesAnyTaskRequireTaskbarRounding(displayId, taskId)
)
@@ -1412,35 +1415,39 @@
* @return the taskId of the next focused task, or [INVALID_TASK_ID] if no task is found.
*/
fun getNextFocusedTask(taskInfo: RunningTaskInfo): Int {
- val deskId = getOrCreateDefaultDeskId(taskInfo.displayId) ?: return INVALID_TASK_ID
- return taskRepository
+ val deskId =
+ getOrCreateDefaultDeskId(taskInfo.displayId, taskInfo.userId) ?: return INVALID_TASK_ID
+ val repository = userRepositories.getProfile(taskInfo.userId)
+ return repository
.getExpandedTasksIdsInDeskOrdered(deskId)
// exclude current task since maximize/restore transition has not taken place yet.
.filterNot { it == taskInfo.taskId }
- .firstOrNull { !taskRepository.isClosingTask(it) } ?: INVALID_TASK_ID
+ .firstOrNull { !repository.isClosingTask(it) } ?: INVALID_TASK_ID
}
fun minimizeTask(taskInfo: RunningTaskInfo, minimizeReason: MinimizeReason) {
val wct = WindowContainerTransaction()
val taskId = taskInfo.taskId
val displayId = taskInfo.displayId
+ val userId = taskInfo.userId
+ val repository = userRepositories.getProfile(userId)
val deskId =
- taskRepository.getDeskIdForTask(taskInfo.taskId)
+ repository.getDeskIdForTask(taskId)
?: if (DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) {
- logW("minimizeTask: desk not found for task: ${taskInfo.taskId}")
+ logW("minimizeTask: desk not found for task: $taskId")
return
} else {
- getOrCreateDefaultDeskId(taskInfo.displayId)
+ getOrCreateDefaultDeskId(displayId, userId)
}
val isLastTask =
if (DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) {
- taskRepository.isOnlyVisibleNonClosingTaskInDesk(
+ repository.isOnlyVisibleNonClosingTaskInDesk(
taskId = taskId,
deskId = checkNotNull(deskId) { "Expected non-null deskId" },
displayId = displayId,
)
} else {
- taskRepository.isOnlyVisibleNonClosingTask(taskId = taskId, displayId = displayId)
+ repository.isOnlyVisibleNonClosingTask(taskId = taskId, displayId = displayId)
}
snapEventHandler.removeTaskIfTiled(displayId, taskId)
val isMinimizingToPip =
@@ -1486,6 +1493,7 @@
wct = wct,
deskId = deskId,
displayId = displayId,
+ userId = userId,
willExitDesktop = true,
removingLastTaskId = null,
exitReason = ExitReason.TASK_MINIMIZED,
@@ -1507,6 +1515,7 @@
wct = wct,
deskId = deskId,
displayId = displayId,
+ userId = userId,
willExitDesktop = willExitDesktop,
removingLastTaskId = null,
exitReason = ExitReason.TASK_MINIMIZED,
@@ -1598,7 +1607,11 @@
checkNotNull(context.getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager)
try {
val appInfo =
- context.packageManager.getApplicationInfoAsUser(packageName, /* flags= */ 0, userId)
+ context.packageManager.getApplicationInfoAsUser(
+ packageName,
+ /* flags= */ 0,
+ taskInfo.userId,
+ )
return appOpsManager.checkOpNoThrow(
AppOpsManager.OP_PICTURE_IN_PICTURE,
appInfo.uid,
@@ -1609,7 +1622,7 @@
"isPipAllowedInAppOps: Failed to find applicationInfo for packageName=%s " +
"and userId=%d",
packageName,
- userId,
+ taskInfo.userId,
)
}
return false
@@ -1758,12 +1771,18 @@
@JvmOverloads
fun moveTaskToFront(
taskId: Int,
+ userId: Int = shellController.currentUserId,
remoteTransition: RemoteTransition? = null,
unminimizeReason: UnminimizeReason,
) {
val task = shellTaskOrganizer.getRunningTaskInfo(taskId)
if (task == null) {
- moveBackgroundTaskToFront(taskId, remoteTransition, unminimizeReason)
+ moveBackgroundTaskToFront(
+ taskId = taskId,
+ userId = userId,
+ remoteTransition = remoteTransition,
+ unminimizeReason = unminimizeReason,
+ )
} else {
moveTaskToFront(task, remoteTransition, unminimizeReason)
}
@@ -1776,12 +1795,14 @@
*/
private fun moveBackgroundTaskToFront(
taskId: Int,
+ userId: Int,
remoteTransition: RemoteTransition?,
unminimizeReason: UnminimizeReason,
) {
logV("moveBackgroundTaskToFront taskId=%s unminimizeReason=%s", taskId, unminimizeReason)
+ val repository = userRepositories.getProfile(userId)
val wct = WindowContainerTransaction()
- val deskIdForTask = taskRepository.getDeskIdForTask(taskId)
+ val deskIdForTask = repository.getDeskIdForTask(taskId)
val deskId =
if (deskIdForTask != null) {
deskIdForTask
@@ -1794,11 +1815,10 @@
taskId,
displayId,
)
- getOrCreateDefaultDeskId(displayId) ?: return
+ getOrCreateDefaultDeskId(displayId, userId) ?: return
}
val displayId =
- if (ENABLE_BUG_FIXES_FOR_SECONDARY_DISPLAY.isTrue)
- taskRepository.getDisplayForDesk(deskId)
+ if (ENABLE_BUG_FIXES_FOR_SECONDARY_DISPLAY.isTrue) repository.getDisplayForDesk(deskId)
else DEFAULT_DISPLAY
wct.startTask(
taskId,
@@ -2065,17 +2085,23 @@
* Start an intent through a launch transition for starting tasks whose transition does not get
* handled by [handleRequest]
*/
- fun startLaunchIntentTransition(intent: Intent, options: Bundle, displayId: Int) {
+ fun startLaunchIntentTransition(
+ intent: Intent,
+ options: Bundle,
+ displayId: Int,
+ userId: Int = shellController.currentUserId,
+ ) {
+ val repository = userRepositories.getProfile(userId)
val wct = WindowContainerTransaction()
val displayLayout = displayController.getDisplayLayout(displayId) ?: return
val bounds = calculateDefaultDesktopTaskBounds(displayLayout)
- val deskId = getOrCreateDefaultDeskId(displayId) ?: return
+ val deskId = getOrCreateDefaultDeskId(displayId, userId) ?: return
if (DesktopModeFlags.ENABLE_CASCADING_WINDOWS.isTrue) {
val stableBounds = Rect().also { displayLayout.getStableBounds(it) }
cascadeWindow(
context,
recentTasksController,
- taskRepository,
+ repository,
shellTaskOrganizer,
bounds,
displayLayout,
@@ -2142,6 +2168,8 @@
return
}
+ val userId = task.userId
+ val repository = userRepositories.getProfile(userId)
val wct = WindowContainerTransaction()
val displayAreaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId)
if (displayAreaInfo == null) {
@@ -2171,7 +2199,7 @@
displayId,
)
} else {
- val destinationDeskId = taskRepository.getDefaultDeskId(displayId)
+ val destinationDeskId = repository.getDefaultDeskId(displayId)
if (destinationDeskId == null) {
logW("moveToDisplay: desk not found for display: $displayId")
return
@@ -2198,18 +2226,19 @@
activationRunnable =
addDeskActivationChanges(destinationDeskId, wct, task, enterReason = enterReason)
val sourceDisplayId = task.displayId
- val sourceDeskId = taskRepository.getDeskIdForTask(task.taskId)
+ val sourceDeskId = repository.getDeskIdForTask(task.taskId)
val shouldExitDesktopIfNeeded =
ENABLE_PER_DISPLAY_DESKTOP_WALLPAPER_ACTIVITY.isTrue ||
DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue
val isLastTask =
- sourceDeskId?.let { taskRepository.isOnlyTaskInDesk(task.taskId, it) } ?: false
+ sourceDeskId?.let { repository.isOnlyTaskInDesk(task.taskId, it) } ?: false
deactivationRunnable =
if (shouldExitDesktopIfNeeded) {
performDesktopExitCleanupIfNeeded(
taskId = task.taskId,
deskId = sourceDeskId,
displayId = sourceDisplayId,
+ userId = userId,
wct = wct,
removingLastTaskId = if (isLastTask) task.taskId else null,
forceToFullscreen = false,
@@ -2256,6 +2285,8 @@
return
}
+ val userId = task.userId
+ val repository = userRepositories.getProfile(userId)
val wct = WindowContainerTransaction()
val displayAreaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId)
if (displayAreaInfo == null) {
@@ -2263,7 +2294,7 @@
return
}
- val activeDeskId = taskRepository.getActiveDeskId(displayId)
+ val activeDeskId = repository.getActiveDeskId(displayId)
logV("moveSplitPairToDisplay: moving split root to displayId=%d", displayId)
val stageCoordinatorRootTaskToken =
@@ -2281,6 +2312,7 @@
wct = wct,
deskId = activeDeskId,
displayId = displayId,
+ userId = userId,
willExitDesktop = true,
removingLastTaskId = null,
shouldEndUpAtHome = false,
@@ -2726,7 +2758,11 @@
}
}
- private fun addLaunchHomePendingIntent(wct: WindowContainerTransaction, displayId: Int) {
+ private fun addLaunchHomePendingIntent(
+ wct: WindowContainerTransaction,
+ displayId: Int,
+ userId: Int,
+ ) {
homeIntentProvider.addLaunchHomePendingIntent(wct, displayId, userId)
}
@@ -2763,6 +2799,7 @@
)
wct.sendPendingIntent(pendingIntent, intent, options.toBundle())
} else {
+ val userId = shellController.currentUserId
val userHandle = UserHandle.of(userId)
val userContext = context.createContextAsUser(userHandle, /* flags= */ 0)
val intent = Intent(userContext, DesktopWallpaperActivity::class.java)
@@ -2835,6 +2872,7 @@
taskId: Int,
deskId: Int? = null,
displayId: Int,
+ userId: Int,
wct: WindowContainerTransaction,
removingLastTaskId: Int?,
forceToFullscreen: Boolean,
@@ -2849,6 +2887,7 @@
wct = wct,
deskId = deskId,
displayId = displayId,
+ userId = userId,
willExitDesktop = true,
removingLastTaskId = removingLastTaskId,
shouldEndUpAtHome = true,
@@ -2861,6 +2900,7 @@
wct: WindowContainerTransaction,
deskId: Int?,
displayId: Int,
+ userId: Int,
willExitDesktop: Boolean,
removingLastTaskId: Int?,
shouldEndUpAtHome: Boolean = true,
@@ -2891,7 +2931,7 @@
if (shouldEndUpAtHome) {
// If the transition should end up with user going to home, launch home with a
// pending intent.
- addLaunchHomePendingIntent(wct, displayId)
+ addLaunchHomePendingIntent(wct, displayId, userId)
}
}
val shouldRemoveDesk =
@@ -2900,9 +2940,10 @@
!rootTaskDisplayAreaOrganizer.isDisplayDesktopFirst(displayId)
return if (shouldRemoveDesk) {
addDeskRemovalChanges(
- wct,
- deskId,
- displayId,
+ wct = wct,
+ deskId = deskId,
+ displayId = displayId,
+ userId = userId,
excludingTaskId = removingLastTaskId,
exitReason = exitReason,
)
@@ -3176,13 +3217,14 @@
/** Open an existing instance of an app. */
fun openInstance(callingTask: RunningTaskInfo, requestedTaskId: Int) {
- val deskId = getOrCreateDefaultDeskId(callingTask.displayId) ?: return
+ val deskId = getOrCreateDefaultDeskId(callingTask.displayId, callingTask.userId) ?: return
if (callingTask.isFreeform) {
val requestedTaskInfo = shellTaskOrganizer.getRunningTaskInfo(requestedTaskId)
if (requestedTaskInfo?.isFreeform == true) {
// If requested task is an already open freeform task, just move it to front.
moveTaskToFront(
- requestedTaskId,
+ taskId = requestedTaskId,
+ userId = callingTask.userId,
unminimizeReason = UnminimizeReason.APP_HANDLE_MENU_BUTTON,
)
} else {
@@ -3231,7 +3273,7 @@
)
val deskId =
taskRepository.getDeskIdForTask(callingTaskInfo.taskId)
- ?: getOrCreateDefaultDeskId(callingTaskInfo.displayId)
+ ?: getOrCreateDefaultDeskId(callingTaskInfo.displayId, callingTaskInfo.userId)
?: return
val options = createNewWindowOptions(callingTaskInfo, deskId)
when (options.launchWindowingMode) {
@@ -3323,7 +3365,7 @@
"DesktopTasksController: handleHomeTaskLaunch taskId=%s userId=%s currentUserId=%d",
task.taskId,
task.userId,
- userId,
+ shellController.currentUserId,
)
// On user-switches, the home task is launched and the request is dispatched before the
// user-switch is known by SysUI/Shell, so don't use the "current" repository.
@@ -3338,6 +3380,7 @@
wct = wct,
deskId = activeDeskId,
displayId = task.displayId,
+ userId = task.userId,
willExitDesktop = true,
removingLastTaskId = null,
shouldEndUpAtHome = true,
@@ -3441,7 +3484,8 @@
requestedTaskBounds: Rect?,
@WindowManager.TransitionType requestType: Int,
): WindowContainerTransaction? {
- val repository = userRepositories.getProfile(task.userId)
+ val userId = task.userId
+ val repository = userRepositories.getProfile(userId)
val anyDeskActive = repository.isAnyDeskActive(targetDisplayId)
val sourceDisplayId = task.displayId
val sourceDeskId =
@@ -3451,7 +3495,7 @@
} else {
null
}
- val targetDeskId = getOrCreateDefaultDeskId(targetDisplayId)
+ val targetDeskId = getOrCreateDefaultDeskId(displayId = targetDisplayId, userId = userId)
val isKnownDesktopTask = repository.isActiveTask(task.taskId)
val bringTaskToFront = sourceDisplayId != targetDisplayId || requestedTaskBounds == null
@@ -3544,6 +3588,7 @@
taskId = task.taskId,
deskId = sourceDeskId,
displayId = sourceDisplayId,
+ userId = userId,
wct = wct,
removingLastTaskId = if (isLastTask) task.taskId else null,
forceToFullscreen = false,
@@ -3661,7 +3706,7 @@
if (shouldFullscreenTaskLaunchSwitchToDesktop(task, requestType)) {
logD("Switch fullscreen task to freeform on transition: taskId=%d", task.taskId)
return WindowContainerTransaction().also { wct ->
- val deskId = getOrCreateDefaultDeskId(task.displayId) ?: return@also
+ val deskId = getOrCreateDefaultDeskId(task.displayId, task.userId) ?: return@also
addMoveToDeskTaskChanges(wct = wct, task = task, deskId = deskId)
val runOnTransitStart: RunOnTransitStart? =
if (
@@ -3955,6 +4000,7 @@
taskId = task.taskId,
deskId = deskId,
displayId = task.displayId,
+ userId = task.userId,
wct = wct,
removingLastTaskId = if (isLastTask) task.taskId else null,
forceToFullscreen = false,
@@ -4168,21 +4214,18 @@
// if the task is not on top we can still switch to it using Alt+Tab.
wct.reorder(taskInfo.token, /* onTop= */ true)
}
-
+ val userId = taskInfo.userId
+ val repository = userRepositories.getProfile(userId)
val deskId =
- taskRepository.getDeskIdForTask(taskInfo.taskId)
+ repository.getDeskIdForTask(taskInfo.taskId)
?: if (enableAltTabKqsFlatenning.isTrue) {
- taskRepository.getActiveDeskId(displayId)
+ repository.getActiveDeskId(displayId)
} else {
null
}
if (willExitDesktop) {
val isLastTask =
- deskId?.let {
- userRepositories
- .getProfile(taskInfo.userId)
- .isOnlyTaskInDesk(taskInfo.taskId, it)
- } ?: false
+ deskId?.let { repository.isOnlyTaskInDesk(taskInfo.taskId, it) } ?: false
return performDesktopExitCleanUp(
wct = wct,
deskId = deskId,
@@ -4197,6 +4240,7 @@
// Before the bug fix, display move is not considered.
displayId
},
+ userId = userId,
willExitDesktop = true,
removingLastTaskId = if (isLastTask) taskInfo.taskId else null,
shouldEndUpAtHome =
@@ -4326,10 +4370,11 @@
private fun activateDefaultDeskInDisplay(
displayId: Int,
+ userId: Int,
remoteTransition: RemoteTransition? = null,
taskIdToReorderToFront: Int? = null,
) {
- val deskId = getOrCreateDefaultDeskId(displayId) ?: return
+ val deskId = getOrCreateDefaultDeskId(displayId, userId) ?: return
activateDesk(deskId, remoteTransition, taskIdToReorderToFront)
}
@@ -4639,11 +4684,12 @@
wct: WindowContainerTransaction,
deskId: Int?,
displayId: Int,
+ userId: Int,
excludingTaskId: Int? = null,
- repository: DesktopRepository = taskRepository,
exitReason: ExitReason,
): RunOnTransitStart? {
if (deskId == null) return null
+ val repository = userRepositories.getProfile(userId)
val tasksToRemove =
if (DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) {
val activeTaskIdsInDesk = repository.getActiveTaskIdsInDesk(deskId)
@@ -4708,11 +4754,12 @@
/** Removes the default desk in the given display. */
@Deprecated("Deprecated with multi-desks.", ReplaceWith("removeDesk()"))
- fun removeDefaultDeskInDisplay(displayId: Int) {
- val deskId = getOrCreateDefaultDeskId(displayId) ?: return
+ fun removeDefaultDeskInDisplay(displayId: Int, userId: Int = shellController.currentUserId) {
+ val deskId = getOrCreateDefaultDeskId(displayId, userId) ?: return
removeDesk(
displayId = displayId,
deskId = deskId,
+ userId = userId,
exitReason = ExitReason.RETURN_HOME_OR_OVERVIEW,
)
}
@@ -4732,8 +4779,9 @@
"Use getOrCreateDefaultDeskIdSuspending() instead",
ReplaceWith("getOrCreateDefaultDeskIdSuspending()"),
)
- private fun getOrCreateDefaultDeskId(displayId: Int): Int? {
- val existingDefaultDeskId = taskRepository.getDefaultDeskId(displayId)
+ private fun getOrCreateDefaultDeskId(displayId: Int, userId: Int): Int? {
+ val repository = userRepositories.getProfile(userId)
+ val existingDefaultDeskId = repository.getDefaultDeskId(displayId)
if (existingDefaultDeskId != null) {
return existingDefaultDeskId
}
@@ -4749,51 +4797,45 @@
return immediateDeskId
}
- private suspend fun getOrCreateDefaultDeskIdSuspending(displayId: Int): Int =
- taskRepository.getDefaultDeskId(displayId)
+ private suspend fun getOrCreateDefaultDeskIdSuspending(displayId: Int, userId: Int): Int {
+ val repository = userRepositories.getProfile(userId)
+ return repository.getDefaultDeskId(displayId)
?: createDeskSuspending(displayId, userId, enforceDeskLimit = false)
+ }
/** Removes the given desk. */
fun removeDesk(
deskId: Int,
- desktopRepository: DesktopRepository = taskRepository,
+ userId: Int = shellController.currentUserId,
exitReason: ExitReason,
) {
- if (!desktopRepository.getAllDeskIds().contains(deskId)) {
+ val repository = userRepositories.getProfile(userId)
+ if (!repository.getAllDeskIds().contains(deskId)) {
logW("Request to remove desk=%d but desk not found for user=%d", deskId, userId)
return
}
- val displayId = desktopRepository.getDisplayForDesk(deskId)
- removeDesk(
- displayId = displayId,
- deskId = deskId,
- desktopRepository = desktopRepository,
- exitReason = exitReason,
- )
+ val displayId = repository.getDisplayForDesk(deskId)
+ removeDesk(displayId = displayId, deskId = deskId, userId = userId, exitReason = exitReason)
}
/** Removes all the available desks on all displays. */
- fun removeAllDesks(exitReason: ExitReason) {
- taskRepository.getAllDeskIds().forEach { deskId ->
- removeDesk(deskId, exitReason = exitReason)
+ fun removeAllDesks(userId: Int = shellController.currentUserId, exitReason: ExitReason) {
+ val repository = userRepositories.getProfile(userId)
+ repository.getAllDeskIds().forEach { deskId ->
+ removeDesk(deskId = deskId, userId = userId, exitReason = exitReason)
}
}
- private fun removeDesk(
- displayId: Int,
- deskId: Int,
- desktopRepository: DesktopRepository = taskRepository,
- exitReason: ExitReason,
- ) {
+ private fun removeDesk(displayId: Int, deskId: Int, userId: Int, exitReason: ExitReason) {
if (!DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION.isTrue()) return
- logV("removeDesk deskId=%d from displayId=%d", deskId, displayId)
+ logV("removeDesk deskId=%d from displayId=%d of userId=%d", deskId, displayId, userId)
val wct = WindowContainerTransaction()
val runOnTransitStart =
addDeskRemovalChanges(
wct = wct,
deskId = deskId,
displayId = displayId,
- repository = desktopRepository,
+ userId = userId,
exitReason = exitReason,
)
if (!DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue && wct.isEmpty) return
@@ -5357,7 +5399,7 @@
DesktopModeFlags.ENABLE_DESKTOP_TAB_TEARING_MINIMIZE_ANIMATION_BUGFIX.isTrue ||
DesktopExperienceFlags.ENABLE_DESKTOP_TAB_TEARING_LAUNCH_ANIMATION.isTrue
) {
- val deskId = getOrCreateDefaultDeskId(destinationDisplay) ?: return false
+ val deskId = getOrCreateDefaultDeskId(destinationDisplay, userId) ?: return false
startLaunchTransition(
TRANSIT_OPEN,
wct,
@@ -5386,15 +5428,18 @@
// TODO(b/366397912): Support full multi-user mode in Windowing.
override fun onUserChanged(newUserId: Int, userContext: Context) {
- logV("onUserChanged previousUserId=%d, newUserId=%d", userId, newUserId)
+ logV(
+ "onUserChanged previousUserId=%d, newUserId=%d",
+ shellController.currentUserId,
+ newUserId,
+ )
updateCurrentUser(newUserId)
}
private fun updateCurrentUser(newUserId: Int) {
- userId = newUserId
- taskRepository = userRepositories.getProfile(userId)
+ taskRepository = userRepositories.getProfile(newUserId)
if (this::snapEventHandler.isInitialized) {
- snapEventHandler.onUserChange(userId)
+ snapEventHandler.onUserChange(newUserId)
}
}
@@ -5719,9 +5764,10 @@
) {
executeRemoteCallWithTaskPermission(controller, "showDesktopApps") { c ->
c.showDesktopApps(
- displayId,
- remoteTransition,
- if (taskIdInFront != INVALID_TASK_ID) taskIdInFront else null,
+ displayId = displayId,
+ remoteTransition = remoteTransition,
+ taskIdToReorderToFront =
+ if (taskIdInFront != INVALID_TASK_ID) taskIdInFront else null,
)
}
}
@@ -5732,7 +5778,11 @@
toFrontReason: DesktopTaskToFrontReason,
) {
executeRemoteCallWithTaskPermission(controller, "showDesktopApp") { c ->
- c.moveTaskToFront(taskId, remoteTransition, toFrontReason.toUnminimizeReason())
+ c.moveTaskToFront(
+ taskId = taskId,
+ remoteTransition = remoteTransition,
+ unminimizeReason = toFrontReason.toUnminimizeReason(),
+ )
}
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopDisplayEventHandlerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopDisplayEventHandlerTest.kt
index 7b45273..d7f92ac 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopDisplayEventHandlerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopDisplayEventHandlerTest.kt
@@ -342,7 +342,8 @@
handler.onDeskRemoved(DEFAULT_DISPLAY, deskId = 1)
runCurrent()
- verify(mockDesktopTasksController, never()).createDesk(DEFAULT_DISPLAY)
+ verify(mockDesktopTasksController, never())
+ .createDesk(eq(DEFAULT_DISPLAY), any(), any(), any(), any())
verify(mockDesksOrganizer, never())
.warmUpDefaultDesk(DEFAULT_DISPLAY, mockDesktopRepository.userId)
}
@@ -443,7 +444,7 @@
.thenReturn(true)
onDisplaysChangedListenerCaptor.lastValue.onDesktopModeEligibleChanged(externalDisplayId)
verify(mockDesktopTasksController)
- .restoreDisplay(eq(externalDisplayId), eq(UNIQUE_DISPLAY_ID))
+ .restoreDisplay(eq(externalDisplayId), eq(UNIQUE_DISPLAY_ID), eq(PRIMARY_USER_ID))
}
private fun addDisplay(displayId: Int, withTda: Boolean = false) {
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopPipTransitionControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopPipTransitionControllerTest.kt
index d7e760f..472e9e3 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopPipTransitionControllerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopPipTransitionControllerTest.kt
@@ -75,6 +75,7 @@
private val taskInfo =
createFreeformTask().apply {
lastParentTaskIdBeforePip = ActivityTaskManager.INVALID_TASK_ID
+ userId = mockDesktopRepository.userId
}
private val freeformParentTask =
createFreeformTask().apply { lastNonFullscreenBounds = FREEFORM_BOUNDS }
@@ -312,6 +313,7 @@
wct = wct,
deskId = DESK_ID,
displayId = DEFAULT_DISPLAY,
+ userId = taskInfo.userId,
willExitDesktop = true,
removingLastTaskId = taskInfo.taskId,
exitReason = ExitReason.ENTER_PIP,
@@ -322,6 +324,7 @@
wct = any(),
deskId = anyOrNull(),
displayId = any(),
+ userId = any(),
willExitDesktop = any(),
removingLastTaskId = anyOrNull(),
shouldEndUpAtHome = any(),
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 7da3d4a..5c49020 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
@@ -647,7 +647,10 @@
markTaskHidden(task1)
markTaskHidden(task2)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -668,7 +671,10 @@
markTaskHidden(task1)
markTaskHidden(task2)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -691,9 +697,9 @@
markTaskHidden(task2)
controller.showDesktopApps(
- DEFAULT_DISPLAY,
- RemoteTransition(TestRemoteTransition()),
- task1.taskId,
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ taskIdToReorderToFront = task1.taskId,
)
val wct =
@@ -723,9 +729,9 @@
freeformTasks.forEach { markTaskHidden(it) }
controller.showDesktopApps(
- DEFAULT_DISPLAY,
- RemoteTransition(TestRemoteTransition()),
- task1.taskId,
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ taskIdToReorderToFront = task1.taskId,
)
val wct =
@@ -817,7 +823,10 @@
assertThat(taskRepository.getExpandedTasksOrdered(SECOND_DISPLAY)).contains(task1.taskId)
assertThat(taskRepository.getExpandedTasksOrdered(SECOND_DISPLAY)).contains(task2.taskId)
- controller.showDesktopApps(SECOND_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = SECOND_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -837,7 +846,10 @@
taskRepository.addDesk(displayId = SECOND_DISPLAY, deskId = 2)
setUpHomeTask(SECOND_DISPLAY)
- controller.showDesktopApps(SECOND_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = SECOND_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -855,7 +867,10 @@
taskRepository.addDesk(displayId = SECOND_DISPLAY, deskId = SECOND_DISPLAY)
setUpHomeTask(SECOND_DISPLAY)
- controller.showDesktopApps(SECOND_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = SECOND_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -871,7 +886,10 @@
taskRepository.addDesk(displayId = SECOND_DISPLAY, deskId = SECOND_DISPLAY)
val homeTask = setUpHomeTask(SECOND_DISPLAY)
- controller.showDesktopApps(SECOND_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = SECOND_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -890,7 +908,10 @@
markTaskVisible(task1)
markTaskVisible(task2)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -914,7 +935,10 @@
markTaskHidden(task1)
markTaskHidden(task2)
- controller.showDesktopApps(SECOND_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = SECOND_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -935,7 +959,10 @@
markTaskVisible(task1)
markTaskVisible(task2)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -958,7 +985,10 @@
markTaskHidden(task1)
markTaskVisible(task2)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -979,7 +1009,10 @@
markTaskHidden(task1)
markTaskVisible(task2)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -997,7 +1030,10 @@
markTaskHidden(task1)
markTaskVisible(task2)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -1016,7 +1052,10 @@
fun showDesktopApps_noActiveTasks_reorderHomeToTop_desktopWallpaperDisabled() {
val homeTask = setUpHomeTask()
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -1029,8 +1068,10 @@
fun showDesktopApps_noActiveTasks_desktopWallpaperEnabled_addsDesktopWallpaper() {
whenever(desktopWallpaperActivityTokenProvider.getToken()).thenReturn(null)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
-
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
wct.assertPendingIntentAt(index = 0, desktopWallpaperIntent)
@@ -1040,7 +1081,10 @@
@DisableFlags(Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND)
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_WALLPAPER_ACTIVITY)
fun showDesktopApps_noActiveTasks_desktopWallpaperEnabled_reordersDesktopWallpaper() {
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -1061,7 +1105,10 @@
markTaskHidden(taskDefaultDisplay)
markTaskHidden(taskSecondDisplay)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -1085,7 +1132,10 @@
markTaskHidden(taskDefaultDisplay)
markTaskHidden(taskSecondDisplay)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -1109,7 +1159,10 @@
markTaskHidden(taskDefaultDisplay)
markTaskHidden(taskSecondDisplay)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -1133,7 +1186,10 @@
markTaskHidden(taskDefaultDisplay)
markTaskHidden(taskSecondDisplay)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -1154,7 +1210,10 @@
markTaskHidden(freeformTask)
markTaskHidden(minimizedTask)
taskRepository.minimizeTask(DEFAULT_DISPLAY, minimizedTask.taskId)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -1177,7 +1236,10 @@
markTaskHidden(freeformTask)
markTaskHidden(minimizedTask)
taskRepository.minimizeTask(DEFAULT_DISPLAY, minimizedTask.taskId)
- controller.showDesktopApps(DEFAULT_DISPLAY, RemoteTransition(TestRemoteTransition()))
+ controller.showDesktopApps(
+ displayId = DEFAULT_DISPLAY,
+ remoteTransition = RemoteTransition(TestRemoteTransition()),
+ )
val wct =
getLatestWct(type = TRANSIT_TO_FRONT, handlerClass = OneShotRemoteHandler::class.java)
@@ -10764,7 +10826,11 @@
)
}
- controller.restoreDisplay(SECOND_DISPLAY_ON_RECONNECT, SECOND_DISPLAY_UNIQUE_ID)
+ controller.restoreDisplay(
+ displayId = SECOND_DISPLAY_ON_RECONNECT,
+ uniqueDisplayId = SECOND_DISPLAY_UNIQUE_ID,
+ userId = taskRepository.userId,
+ )
runCurrent()
verify(transitions).startTransition(anyInt(), wctCaptor.capture(), anyOrNull())