Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeTaskRepository.kt +32 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import android.util.SparseArray import androidx.core.util.forEach import androidx.core.util.keyIterator import androidx.core.util.valueIterator import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE import com.android.wm.shell.util.KtProtoLog import java.util.concurrent.Executor import java.util.function.Consumer Loading Loading @@ -140,6 +142,12 @@ class DesktopModeTaskRepository { val added = displayData.getOrCreate(displayId).activeTasks.add(taskId) if (added) { KtProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTaskRepo: add active task=%d displayId=%d", taskId, displayId ) activeTasksListeners.onEach { it.onActiveTasksChanged(displayId) } } return added Loading @@ -158,6 +166,9 @@ class DesktopModeTaskRepository { result = true } } if (result) { KtProtoLog.d(WM_SHELL_DESKTOP_MODE, "DesktopTaskRepo: remove active task=%d", taskId) } return result } Loading Loading @@ -221,6 +232,17 @@ class DesktopModeTaskRepository { displayData[displayId]?.visibleTasks?.remove(taskId) } val newCount = getVisibleTaskCount(displayId) if (prevCount != newCount) { KtProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTaskRepo: update task visibility taskId=%d visible=%b displayId=%d", taskId, visible, displayId ) } // Check if count changed and if there was no tasks or this is the first task if (prevCount != newCount && (prevCount == 0 || newCount == 0)) { notifyVisibleTaskListeners(displayId, newCount > 0) Loading @@ -244,6 +266,11 @@ class DesktopModeTaskRepository { * Add (or move if it already exists) the task to the top of the ordered list. */ fun addOrMoveFreeformTaskToTop(taskId: Int) { KtProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTaskRepo: add or move task to top taskId=%d", taskId ) if (freeformTasksInZOrder.contains(taskId)) { freeformTasksInZOrder.remove(taskId) } Loading @@ -254,6 +281,11 @@ class DesktopModeTaskRepository { * Remove the task from the ordered list. */ fun removeFreeformTask(taskId: Int) { KtProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTaskRepo: remove freeform task from ordered list taskId=%d", taskId ) freeformTasksInZOrder.remove(taskId) } Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +43 −18 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ class DesktopTasksController( /** Show all tasks, that are part of the desktop, on top of launcher */ fun showDesktopApps(displayId: Int) { KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "showDesktopApps") KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: showDesktopApps") val wct = WindowContainerTransaction() // TODO(b/278084491): pass in display id bringDesktopAppsToFront(displayId, wct) Loading Loading @@ -130,8 +130,11 @@ class DesktopTasksController( /** Move a task to desktop */ fun moveToDesktop(task: RunningTaskInfo) { KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "moveToDesktop: %d", task.taskId) KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: moveToDesktop taskId=%d", task.taskId ) val wct = WindowContainerTransaction() // Bring other apps to front first bringDesktopAppsToFront(task.displayId, wct) Loading @@ -147,10 +150,12 @@ class DesktopTasksController( * Moves a single task to freeform and sets the taskBounds to the passed in bounds, * startBounds */ fun moveToFreeform( taskInfo: RunningTaskInfo, startBounds: Rect ) { fun moveToFreeform(taskInfo: RunningTaskInfo, startBounds: Rect) { KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: moveToFreeform with bounds taskId=%d", taskInfo.taskId ) val wct = WindowContainerTransaction() moveHomeTaskToFront(wct) addMoveToDesktopChanges(wct, taskInfo.getToken()) Loading @@ -165,10 +170,12 @@ class DesktopTasksController( } /** Brings apps to front and sets freeform task bounds */ private fun moveToDesktopWithAnimation( taskInfo: RunningTaskInfo, freeformBounds: Rect ) { private fun moveToDesktopWithAnimation(taskInfo: RunningTaskInfo, freeformBounds: Rect) { KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: moveToDesktop with animation taskId=%d", taskInfo.taskId ) val wct = WindowContainerTransaction() bringDesktopAppsToFront(taskInfo.displayId, wct) addMoveToDesktopChanges(wct, taskInfo.getToken()) Loading @@ -190,7 +197,11 @@ class DesktopTasksController( /** Move a task to fullscreen */ fun moveToFullscreen(task: RunningTaskInfo) { KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "moveToFullscreen: %d", task.taskId) KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: moveToFullscreen taskId=%d", task.taskId ) val wct = WindowContainerTransaction() addMoveToFullscreenChanges(wct, task.token) Loading @@ -206,6 +217,11 @@ class DesktopTasksController( * status bar area */ fun cancelMoveToFreeform(task: RunningTaskInfo, position: Point) { KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: cancelMoveToFreeform taskId=%d", task.taskId ) val wct = WindowContainerTransaction() addMoveToFullscreenChanges(wct, task.token) if (Transitions.ENABLE_SHELL_TRANSITIONS) { Loading @@ -218,6 +234,11 @@ class DesktopTasksController( } private fun moveToFullscreenWithAnimation(task: RunningTaskInfo, position: Point) { KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: moveToFullscreen with animation taskId=%d", task.taskId ) val wct = WindowContainerTransaction() addMoveToFullscreenChanges(wct, task.token) Loading @@ -230,8 +251,14 @@ class DesktopTasksController( } } /** Move a task to the front **/ /** Move a task to the front */ fun moveTaskToFront(taskInfo: RunningTaskInfo) { KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: moveTaskToFront taskId=%d", taskInfo.taskId ) val wct = WindowContainerTransaction() wct.reorder(taskInfo.token, true) if (Transitions.ENABLE_SHELL_TRANSITIONS) { Loading Loading @@ -316,7 +343,7 @@ class DesktopTasksController( } private fun bringDesktopAppsToFront(displayId: Int, wct: WindowContainerTransaction) { KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "bringDesktopAppsToFront") KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: bringDesktopAppsToFront") val activeTasks = desktopModeTaskRepository.getActiveTasks(displayId) // First move home to front and then other tasks on top of it Loading Loading @@ -399,7 +426,7 @@ class DesktopTasksController( if (activeTasks.any { desktopModeTaskRepository.isVisibleTask(it) }) { KtProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTasksController#handleRequest: switch fullscreen task to freeform," + "DesktopTasksController: switch fullscreen task to freeform on transition" + " taskId=%d", task.taskId ) Loading @@ -416,7 +443,7 @@ class DesktopTasksController( if (activeTasks.none { desktopModeTaskRepository.isVisibleTask(it) }) { KtProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTasksController#handleRequest: switch freeform task to fullscreen," + "DesktopTasksController: switch freeform task to fullscreen oon transition" + " taskId=%d", task.taskId ) Loading Loading @@ -627,8 +654,6 @@ class DesktopTasksController( } } /** The interface for calls from outside the host process. */ @BinderThread private class IDesktopModeImpl(private var controller: DesktopTasksController?) : Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeTaskRepository.kt +32 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import android.util.SparseArray import androidx.core.util.forEach import androidx.core.util.keyIterator import androidx.core.util.valueIterator import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE import com.android.wm.shell.util.KtProtoLog import java.util.concurrent.Executor import java.util.function.Consumer Loading Loading @@ -140,6 +142,12 @@ class DesktopModeTaskRepository { val added = displayData.getOrCreate(displayId).activeTasks.add(taskId) if (added) { KtProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTaskRepo: add active task=%d displayId=%d", taskId, displayId ) activeTasksListeners.onEach { it.onActiveTasksChanged(displayId) } } return added Loading @@ -158,6 +166,9 @@ class DesktopModeTaskRepository { result = true } } if (result) { KtProtoLog.d(WM_SHELL_DESKTOP_MODE, "DesktopTaskRepo: remove active task=%d", taskId) } return result } Loading Loading @@ -221,6 +232,17 @@ class DesktopModeTaskRepository { displayData[displayId]?.visibleTasks?.remove(taskId) } val newCount = getVisibleTaskCount(displayId) if (prevCount != newCount) { KtProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTaskRepo: update task visibility taskId=%d visible=%b displayId=%d", taskId, visible, displayId ) } // Check if count changed and if there was no tasks or this is the first task if (prevCount != newCount && (prevCount == 0 || newCount == 0)) { notifyVisibleTaskListeners(displayId, newCount > 0) Loading @@ -244,6 +266,11 @@ class DesktopModeTaskRepository { * Add (or move if it already exists) the task to the top of the ordered list. */ fun addOrMoveFreeformTaskToTop(taskId: Int) { KtProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTaskRepo: add or move task to top taskId=%d", taskId ) if (freeformTasksInZOrder.contains(taskId)) { freeformTasksInZOrder.remove(taskId) } Loading @@ -254,6 +281,11 @@ class DesktopModeTaskRepository { * Remove the task from the ordered list. */ fun removeFreeformTask(taskId: Int) { KtProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTaskRepo: remove freeform task from ordered list taskId=%d", taskId ) freeformTasksInZOrder.remove(taskId) } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +43 −18 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ class DesktopTasksController( /** Show all tasks, that are part of the desktop, on top of launcher */ fun showDesktopApps(displayId: Int) { KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "showDesktopApps") KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: showDesktopApps") val wct = WindowContainerTransaction() // TODO(b/278084491): pass in display id bringDesktopAppsToFront(displayId, wct) Loading Loading @@ -130,8 +130,11 @@ class DesktopTasksController( /** Move a task to desktop */ fun moveToDesktop(task: RunningTaskInfo) { KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "moveToDesktop: %d", task.taskId) KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: moveToDesktop taskId=%d", task.taskId ) val wct = WindowContainerTransaction() // Bring other apps to front first bringDesktopAppsToFront(task.displayId, wct) Loading @@ -147,10 +150,12 @@ class DesktopTasksController( * Moves a single task to freeform and sets the taskBounds to the passed in bounds, * startBounds */ fun moveToFreeform( taskInfo: RunningTaskInfo, startBounds: Rect ) { fun moveToFreeform(taskInfo: RunningTaskInfo, startBounds: Rect) { KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: moveToFreeform with bounds taskId=%d", taskInfo.taskId ) val wct = WindowContainerTransaction() moveHomeTaskToFront(wct) addMoveToDesktopChanges(wct, taskInfo.getToken()) Loading @@ -165,10 +170,12 @@ class DesktopTasksController( } /** Brings apps to front and sets freeform task bounds */ private fun moveToDesktopWithAnimation( taskInfo: RunningTaskInfo, freeformBounds: Rect ) { private fun moveToDesktopWithAnimation(taskInfo: RunningTaskInfo, freeformBounds: Rect) { KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: moveToDesktop with animation taskId=%d", taskInfo.taskId ) val wct = WindowContainerTransaction() bringDesktopAppsToFront(taskInfo.displayId, wct) addMoveToDesktopChanges(wct, taskInfo.getToken()) Loading @@ -190,7 +197,11 @@ class DesktopTasksController( /** Move a task to fullscreen */ fun moveToFullscreen(task: RunningTaskInfo) { KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "moveToFullscreen: %d", task.taskId) KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: moveToFullscreen taskId=%d", task.taskId ) val wct = WindowContainerTransaction() addMoveToFullscreenChanges(wct, task.token) Loading @@ -206,6 +217,11 @@ class DesktopTasksController( * status bar area */ fun cancelMoveToFreeform(task: RunningTaskInfo, position: Point) { KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: cancelMoveToFreeform taskId=%d", task.taskId ) val wct = WindowContainerTransaction() addMoveToFullscreenChanges(wct, task.token) if (Transitions.ENABLE_SHELL_TRANSITIONS) { Loading @@ -218,6 +234,11 @@ class DesktopTasksController( } private fun moveToFullscreenWithAnimation(task: RunningTaskInfo, position: Point) { KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: moveToFullscreen with animation taskId=%d", task.taskId ) val wct = WindowContainerTransaction() addMoveToFullscreenChanges(wct, task.token) Loading @@ -230,8 +251,14 @@ class DesktopTasksController( } } /** Move a task to the front **/ /** Move a task to the front */ fun moveTaskToFront(taskInfo: RunningTaskInfo) { KtProtoLog.v( WM_SHELL_DESKTOP_MODE, "DesktopTasksController: moveTaskToFront taskId=%d", taskInfo.taskId ) val wct = WindowContainerTransaction() wct.reorder(taskInfo.token, true) if (Transitions.ENABLE_SHELL_TRANSITIONS) { Loading Loading @@ -316,7 +343,7 @@ class DesktopTasksController( } private fun bringDesktopAppsToFront(displayId: Int, wct: WindowContainerTransaction) { KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "bringDesktopAppsToFront") KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: bringDesktopAppsToFront") val activeTasks = desktopModeTaskRepository.getActiveTasks(displayId) // First move home to front and then other tasks on top of it Loading Loading @@ -399,7 +426,7 @@ class DesktopTasksController( if (activeTasks.any { desktopModeTaskRepository.isVisibleTask(it) }) { KtProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTasksController#handleRequest: switch fullscreen task to freeform," + "DesktopTasksController: switch fullscreen task to freeform on transition" + " taskId=%d", task.taskId ) Loading @@ -416,7 +443,7 @@ class DesktopTasksController( if (activeTasks.none { desktopModeTaskRepository.isVisibleTask(it) }) { KtProtoLog.d( WM_SHELL_DESKTOP_MODE, "DesktopTasksController#handleRequest: switch freeform task to fullscreen," + "DesktopTasksController: switch freeform task to fullscreen oon transition" + " taskId=%d", task.taskId ) Loading Loading @@ -627,8 +654,6 @@ class DesktopTasksController( } } /** The interface for calls from outside the host process. */ @BinderThread private class IDesktopModeImpl(private var controller: DesktopTasksController?) : Loading