1. Rename desktopModeTaskRepository to taskRepository in DesktopTasksController
2. Update log utils to reduce verbosity in the code.
Change-Id: I6dcb4d66dd3fc7aa8aa4aedc6c5554fb63ee94cf
Bug: 332682201
Flag: EXEMPT (no-op for functionality)
Test: atest DesktopTasksControllerTest
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 84d2aad..5f838d3 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
@@ -121,7 +121,7 @@
private val exitDesktopTaskTransitionHandler: ExitDesktopTaskTransitionHandler,
private val toggleResizeDesktopTaskTransitionHandler: ToggleResizeDesktopTaskTransitionHandler,
private val dragToDesktopTransitionHandler: DragToDesktopTransitionHandler,
- private val desktopModeTaskRepository: DesktopModeTaskRepository,
+ private val taskRepository: DesktopModeTaskRepository,
private val desktopModeLoggerTransitionObserver: DesktopModeLoggerTransitionObserver,
private val launchAdjacentController: LaunchAdjacentController,
private val recentsTransitionHandler: RecentsTransitionHandler,
@@ -181,7 +181,7 @@
}
private fun onInit() {
- ProtoLog.d(WM_SHELL_DESKTOP_MODE, "Initialize DesktopTasksController")
+ logD("onInit")
shellCommandHandler.addDumpCallback(this::dump, this)
shellCommandHandler.addCommandCallback("desktopmode", desktopModeShellCommandHandler, this)
shellController.addExternalInterface(
@@ -190,16 +190,12 @@
this
)
transitions.addHandler(this)
- desktopModeTaskRepository.addVisibleTasksListener(taskVisibilityListener, mainExecutor)
+ taskRepository.addVisibleTasksListener(taskVisibilityListener, mainExecutor)
dragToDesktopTransitionHandler.setDragToDesktopStateListener(dragToDesktopStateListener)
recentsTransitionHandler.addTransitionStateListener(
object : RecentsTransitionStateListener {
override fun onAnimationStateChanged(running: Boolean) {
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: recents animation state changed running=%b",
- running
- )
+ logV("Recents animation state changed running=%b", running)
recentsAnimationRunning = running
}
}
@@ -227,7 +223,7 @@
/** Returns the transition type for the given remote transition. */
private fun transitionType(remoteTransition: RemoteTransition?): Int {
if (remoteTransition == null) {
- ProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: remoteTransition is null")
+ logV("RemoteTransition is null")
return TRANSIT_NONE
}
return TRANSIT_TO_FRONT
@@ -235,7 +231,7 @@
/** Show all tasks, that are part of the desktop, on top of launcher */
fun showDesktopApps(displayId: Int, remoteTransition: RemoteTransition? = null) {
- ProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: showDesktopApps")
+ logV("showDesktopApps")
val wct = WindowContainerTransaction()
bringDesktopAppsToFront(displayId, wct)
@@ -255,7 +251,7 @@
/** Gets number of visible tasks in [displayId]. */
fun visibleTaskCount(displayId: Int): Int =
- desktopModeTaskRepository.getVisibleTaskCount(displayId)
+ taskRepository.getVisibleTaskCount(displayId)
/** Returns true if any tasks are visible in Desktop Mode. */
fun isDesktopModeShowing(displayId: Int): Boolean = visibleTaskCount(displayId) > 0
@@ -286,14 +282,8 @@
// Fullscreen case where we move the current focused task.
moveToDesktop(allFocusedTasks[0].taskId, transitionSource = transitionSource)
}
- else -> {
- ProtoLog.w(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: Cannot enter desktop, expected less " +
- "than 3 focused tasks but found %d",
- allFocusedTasks.size
- )
- }
+ else -> logW("Cannot enter desktop, expected < 3 focused tasks, found %d",
+ allFocusedTasks.size)
}
}
}
@@ -317,11 +307,7 @@
transitionSource: DesktopModeTransitionSource,
): Boolean {
recentTasksController?.findTaskInBackground(taskId)?.let {
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: moveToDesktopFromNonRunningTask taskId=%d",
- taskId
- )
+ logV("moveToDesktopFromNonRunningTask with taskId=%d, displayId=%d", taskId)
// TODO(342378842): Instead of using default display, support multiple displays
val taskToMinimize =
bringDesktopAppsToFrontBeforeShowingNewTask(DEFAULT_DISPLAY, wct, taskId)
@@ -351,18 +337,10 @@
) {
if (DesktopModeFlags.MODALS_POLICY.isEnabled(context)
&& isTopActivityExemptFromDesktopWindowing(context, task)) {
- ProtoLog.w(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: Cannot enter desktop, " +
- "ineligible top activity found."
- )
+ logW("Cannot enter desktop for taskId %d, ineligible top activity found", task.taskId)
return
}
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: moveToDesktop taskId=%d",
- task.taskId
- )
+ logV("moveToDesktop taskId=%d", task.taskId)
exitSplitIfApplicable(wct, task)
// Bring other apps to front first
val taskToMinimize =
@@ -386,11 +364,7 @@
dragToDesktopValueAnimator: MoveToDesktopAnimator,
taskSurface: SurfaceControl,
) {
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: startDragToDesktop taskId=%d",
- taskInfo.taskId
- )
+ logV("startDragToDesktop taskId=%d", taskInfo.taskId)
interactionJankMonitor.begin(taskSurface, context,
CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD)
dragToDesktopTransitionHandler.startDragToDesktopTransition(
@@ -442,10 +416,10 @@
* @param taskId task id of the window that's being closed
*/
fun onDesktopWindowClose(wct: WindowContainerTransaction, displayId: Int, taskId: Int) {
- if (desktopModeTaskRepository.isOnlyVisibleNonClosingTask(taskId)) {
+ if (taskRepository.isOnlyVisibleNonClosingTask(taskId)) {
removeWallpaperActivity(wct)
}
- desktopModeTaskRepository.addClosingTask(displayId, taskId)
+ taskRepository.addClosingTask(displayId, taskId)
}
/** Move a task with given `taskId` to fullscreen */
@@ -464,11 +438,7 @@
/** Move a desktop app to split screen. */
fun moveToSplit(task: RunningTaskInfo) {
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: moveToSplit taskId=%d",
- task.taskId
- )
+ logV( "moveToSplit taskId=%s", task.taskId)
val wct = WindowContainerTransaction()
wct.setBounds(task.token, Rect())
// Rather than set windowing mode to multi-window at task level, set it to
@@ -497,11 +467,7 @@
* [startDragToDesktop].
*/
fun cancelDragToDesktop(task: RunningTaskInfo) {
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: cancelDragToDesktop taskId=%d",
- task.taskId
- )
+ logV("cancelDragToDesktop taskId=%d", task.taskId)
dragToDesktopTransitionHandler.cancelDragToDesktopTransition(
DragToDesktopTransitionHandler.CancelState.STANDARD_CANCEL
)
@@ -512,11 +478,7 @@
position: Point,
transitionSource: DesktopModeTransitionSource
) {
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: moveToFullscreen with animation taskId=%d",
- task.taskId
- )
+ logV("moveToFullscreenWithAnimation taskId=%d", task.taskId)
val wct = WindowContainerTransaction()
addMoveToFullscreenChanges(wct, task)
@@ -540,12 +502,7 @@
/** Move a task to the front */
fun moveTaskToFront(taskInfo: RunningTaskInfo) {
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: moveTaskToFront taskId=%d",
- taskInfo.taskId
- )
-
+ logV("moveTaskToFront taskId=%s", taskInfo.taskId)
val wct = WindowContainerTransaction()
wct.reorder(taskInfo.token, true)
val taskToMinimize = addAndGetMinimizeChangesIfNeeded(taskInfo.displayId, wct, taskInfo)
@@ -571,15 +528,10 @@
fun moveToNextDisplay(taskId: Int) {
val task = shellTaskOrganizer.getRunningTaskInfo(taskId)
if (task == null) {
- ProtoLog.w(WM_SHELL_DESKTOP_MODE, "moveToNextDisplay: taskId=%d not found", taskId)
+ logW("moveToNextDisplay: taskId=%d not found", taskId)
return
}
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "moveToNextDisplay: taskId=%d taskDisplayId=%d",
- taskId,
- task.displayId
- )
+ logV("moveToNextDisplay: taskId=%d displayId=%d", taskId, task.displayId)
val displayIds = rootTaskDisplayAreaOrganizer.displayIds.sorted()
// Get the first display id that is higher than current task display id
@@ -589,7 +541,7 @@
newDisplayId = displayIds.firstOrNull { displayId -> displayId < task.displayId }
}
if (newDisplayId == null) {
- ProtoLog.w(WM_SHELL_DESKTOP_MODE, "moveToNextDisplay: next display not found")
+ logW("moveToNextDisplay: next display not found")
return
}
moveToDisplay(task, newDisplayId)
@@ -601,21 +553,15 @@
* No-op if task is already on that display per [RunningTaskInfo.displayId].
*/
private fun moveToDisplay(task: RunningTaskInfo, displayId: Int) {
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "moveToDisplay: taskId=%d displayId=%d",
- task.taskId,
- displayId
- )
-
+ logV("moveToDisplay: taskId=%d displayId=%d", task.taskId, displayId)
if (task.displayId == displayId) {
- ProtoLog.d(WM_SHELL_DESKTOP_MODE, "moveToDisplay: task already on display")
+ logD("moveToDisplay: task already on display %d", displayId)
return
}
val displayAreaInfo = rootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId)
if (displayAreaInfo == null) {
- ProtoLog.w(WM_SHELL_DESKTOP_MODE, "moveToDisplay: display not found")
+ logW("moveToDisplay: display not found")
return
}
@@ -652,7 +598,7 @@
// If the task's pre-maximize stable bounds were saved, toggle the task to those bounds.
// Otherwise, toggle to the default bounds.
val taskBoundsBeforeMaximize =
- desktopModeTaskRepository.removeBoundsBeforeMaximize(taskInfo.taskId)
+ taskRepository.removeBoundsBeforeMaximize(taskInfo.taskId)
if (taskBoundsBeforeMaximize != null) {
destinationBounds.set(taskBoundsBeforeMaximize)
} else {
@@ -665,7 +611,7 @@
} else {
// Save current bounds so that task can be restored back to original bounds if necessary
// and toggle to the stable bounds.
- desktopModeTaskRepository.saveBoundsBeforeMaximize(taskInfo.taskId, currentTaskBounds)
+ taskRepository.saveBoundsBeforeMaximize(taskInfo.taskId, currentTaskBounds)
if (taskInfo.isResizeable) {
// if resizable then expand to entire stable bounds (full display minus insets)
@@ -770,12 +716,7 @@
wct: WindowContainerTransaction,
newTaskIdInFront: Int? = null
): RunningTaskInfo? {
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: bringDesktopAppsToFront, newTaskIdInFront=%s",
- newTaskIdInFront ?: "null"
- )
-
+ logV("bringDesktopAppsToFront, newTaskId=%d", newTaskIdInFront)
// Move home to front, ensures that we go back home when all desktop windows are closed
moveHomeTask(wct, toTop = true)
@@ -786,7 +727,7 @@
}
val nonMinimizedTasksOrderedFrontToBack =
- desktopModeTaskRepository.getActiveNonMinimizedOrderedTasks(displayId)
+ taskRepository.getActiveNonMinimizedOrderedTasks(displayId)
// If we're adding a new Task we might need to minimize an old one
val taskToMinimize: RunningTaskInfo? =
if (newTaskIdInFront != null && desktopTasksLimiter.isPresent) {
@@ -816,7 +757,7 @@
}
private fun addWallpaperActivity(wct: WindowContainerTransaction) {
- ProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: addWallpaper")
+ logV("addWallpaperActivity")
val intent = Intent(context, DesktopWallpaperActivity::class.java)
val options =
ActivityOptions.makeBasic().apply {
@@ -834,8 +775,8 @@
}
private fun removeWallpaperActivity(wct: WindowContainerTransaction) {
- desktopModeTaskRepository.wallpaperActivityToken?.let { token ->
- ProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: removeWallpaper")
+ taskRepository.wallpaperActivityToken?.let { token ->
+ logV("removeWallpaperActivity")
wct.removeTask(token)
}
}
@@ -873,11 +814,7 @@
transition: IBinder,
request: TransitionRequestInfo
): WindowContainerTransaction? {
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: handleRequest request=%s",
- request
- )
+ logV("handleRequest request=%s", request)
// Check if we should skip handling this transition
var reason = ""
val triggerTask = request.triggerTask
@@ -915,11 +852,7 @@
}
if (!shouldHandleRequest) {
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: skipping handleRequest reason=%s",
- reason
- )
+ logV("skipping handleRequest reason=%s", reason)
return null
}
@@ -939,11 +872,7 @@
}
}
}
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: handleRequest result=%s",
- result ?: "null"
- )
+ logV("handleRequest result=%s", result)
return result
}
@@ -977,25 +906,20 @@
task: RunningTaskInfo,
transition: IBinder
): WindowContainerTransaction? {
- ProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: handleFreeformTaskLaunch")
+ logV("handleFreeformTaskLaunch")
if (keyguardManager.isKeyguardLocked) {
// Do NOT handle freeform task launch when locked.
// It will be launched in fullscreen windowing mode (Details: b/160925539)
- ProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: skip keyguard is locked")
+ logV("skip keyguard is locked")
return null
}
val wct = WindowContainerTransaction()
if (!isDesktopModeShowing(task.displayId)) {
- ProtoLog.d(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: bring desktop tasks to front on transition" +
- " taskId=%d",
- task.taskId
- )
+ logD("Bring desktop tasks to front on transition=taskId=%d", task.taskId)
// We are outside of desktop mode and already existing desktop task is being launched.
// We should make this task go to fullscreen instead of freeform. Note that this means
// any re-launch of a freeform window outside of desktop will be in fullscreen.
- if (desktopModeTaskRepository.isActiveTask(task.taskId)) {
+ if (taskRepository.isActiveTask(task.taskId)) {
addMoveToFullscreenChanges(wct, task)
return wct
}
@@ -1020,14 +944,9 @@
task: RunningTaskInfo,
transition: IBinder
): WindowContainerTransaction? {
- ProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: handleFullscreenTaskLaunch")
+ logV("handleFullscreenTaskLaunch")
if (isDesktopModeShowing(task.displayId)) {
- ProtoLog.d(
- WM_SHELL_DESKTOP_MODE,
- "DesktopTasksController: switch fullscreen task to freeform on transition" +
- " taskId=%d",
- task.taskId
- )
+ logD("Switch fullscreen task to freeform on transition: taskId=%d", task.taskId)
return WindowContainerTransaction().also { wct ->
addMoveToDesktopChanges(wct, task)
// In some launches home task is moved behind new task being launched. Make sure
@@ -1054,17 +973,17 @@
/** Handle task closing by removing wallpaper activity if it's the last active task */
private fun handleTaskClosing(task: RunningTaskInfo): WindowContainerTransaction? {
- ProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: handleTaskClosing")
+ logV("handleTaskClosing")
val wct = WindowContainerTransaction()
- if (desktopModeTaskRepository.isOnlyVisibleNonClosingTask(task.taskId)
- && desktopModeTaskRepository.wallpaperActivityToken != null) {
+ if (taskRepository.isOnlyVisibleNonClosingTask(task.taskId)
+ && taskRepository.wallpaperActivityToken != null) {
// Remove wallpaper activity when the last active task is removed
removeWallpaperActivity(wct)
}
- desktopModeTaskRepository.addClosingTask(task.displayId, task.taskId)
+ taskRepository.addClosingTask(task.displayId, task.taskId)
// If a CLOSE or TO_BACK is triggered on a desktop task, remove the task.
if (Flags.enableDesktopWindowingBackNavigation() &&
- desktopModeTaskRepository.isVisibleTask(task.taskId)) {
+ taskRepository.isVisibleTask(task.taskId)) {
wct.removeTask(task.token)
}
return if (wct.isEmpty) null else wct
@@ -1095,7 +1014,7 @@
val stableBounds = Rect()
displayLayout.getStableBoundsForDesktopMode(stableBounds)
- val activeTasks = desktopModeTaskRepository
+ val activeTasks = taskRepository
.getActiveNonMinimizedOrderedTasks(taskInfo.displayId)
activeTasks.firstOrNull()?.let { activeTask ->
shellTaskOrganizer.getRunningTaskInfo(activeTask)?.let {
@@ -1132,7 +1051,7 @@
if (useDesktopOverrideDensity()) {
wct.setDensityDpi(taskInfo.token, getDefaultDensityDpi())
}
- if (desktopModeTaskRepository.isOnlyVisibleNonClosingTask(taskInfo.taskId)) {
+ if (taskRepository.isOnlyVisibleNonClosingTask(taskInfo.taskId)) {
// Remove wallpaper activity when leaving desktop mode
removeWallpaperActivity(wct)
}
@@ -1151,7 +1070,7 @@
// The task's density may have been overridden in freeform; revert it here as we don't
// want it overridden in multi-window.
wct.setDensityDpi(taskInfo.token, getDefaultDensityDpi())
- if (desktopModeTaskRepository.isOnlyVisibleNonClosingTask(taskInfo.taskId)) {
+ if (taskRepository.isOnlyVisibleNonClosingTask(taskInfo.taskId)) {
// Remove wallpaper activity when leaving desktop mode
removeWallpaperActivity(wct)
}
@@ -1387,12 +1306,12 @@
/** Update the exclusion region for a specified task */
fun onExclusionRegionChanged(taskId: Int, exclusionRegion: Region) {
- desktopModeTaskRepository.updateTaskExclusionRegions(taskId, exclusionRegion)
+ taskRepository.updateTaskExclusionRegions(taskId, exclusionRegion)
}
/** Remove a previously tracked exclusion region for a specified task. */
fun removeExclusionRegionForTask(taskId: Int) {
- desktopModeTaskRepository.removeExclusionRegion(taskId)
+ taskRepository.removeExclusionRegion(taskId)
}
/**
@@ -1402,7 +1321,7 @@
* @param callbackExecutor the executor to call the listener on.
*/
fun addVisibleTasksListener(listener: VisibleTasksListener, callbackExecutor: Executor) {
- desktopModeTaskRepository.addVisibleTasksListener(listener, callbackExecutor)
+ taskRepository.addVisibleTasksListener(listener, callbackExecutor)
}
/**
@@ -1412,7 +1331,7 @@
* @param callbackExecutor the executor to call the listener on.
*/
fun setTaskRegionListener(listener: Consumer<Region>, callbackExecutor: Executor) {
- desktopModeTaskRepository.setExclusionRegionListener(listener, callbackExecutor)
+ taskRepository.setExclusionRegionListener(listener, callbackExecutor)
}
override fun onUnhandledDrag(
@@ -1430,7 +1349,7 @@
if (!multiInstanceHelper.supportsMultiInstanceSplit(launchComponent)) {
// TODO(b/320797628): Should only return early if there is an existing running task, and
// notify the user as well. But for now, just ignore the drop.
- ProtoLog.v(WM_SHELL_DESKTOP_MODE, "Dropped intent does not support multi-instance")
+ logV("Dropped intent does not support multi-instance")
return false
}
@@ -1462,7 +1381,7 @@
private fun dump(pw: PrintWriter, prefix: String) {
val innerPrefix = "$prefix "
pw.println("${prefix}DesktopTasksController")
- desktopModeTaskRepository.dump(pw, innerPrefix)
+ taskRepository.dump(pw, innerPrefix)
}
/** The interface for calls from outside the shell, within the host process. */
@@ -1537,12 +1456,12 @@
SingleInstanceRemoteListener<DesktopTasksController, IDesktopTaskListener>(
controller,
{ c ->
- c.desktopModeTaskRepository.addVisibleTasksListener(
+ c.taskRepository.addVisibleTasksListener(
listener,
c.mainExecutor
)
},
- { c -> c.desktopModeTaskRepository.removeVisibleTasksListener(listener) }
+ { c -> c.taskRepository.removeVisibleTasksListener(listener) }
)
}
@@ -1569,10 +1488,7 @@
}
override fun hideStashedDesktopApps(displayId: Int) {
- ProtoLog.w(
- WM_SHELL_DESKTOP_MODE,
- "IDesktopModeImpl: hideStashedDesktopApps is deprecated"
- )
+ ProtoLog.w(WM_SHELL_DESKTOP_MODE, "IDesktopModeImpl: hideStashedDesktopApps is deprecated")
}
override fun getVisibleTaskCount(displayId: Int): Int {
@@ -1596,11 +1512,7 @@
}
override fun setTaskListener(listener: IDesktopTaskListener?) {
- ProtoLog.v(
- WM_SHELL_DESKTOP_MODE,
- "IDesktopModeImpl: set task listener=%s",
- listener ?: "null"
- )
+ ProtoLog.v(WM_SHELL_DESKTOP_MODE, "IDesktopModeImpl: set task listener=%s", listener)
executeRemoteCallWithTaskPermission(controller, "setTaskListener") { _ ->
listener?.let { remoteListener.register(it) } ?: remoteListener.unregister()
}
@@ -1613,10 +1525,22 @@
}
}
+ private fun logV(msg: String, vararg arguments: Any?) {
+ ProtoLog.v(WM_SHELL_DESKTOP_MODE, "%s: $msg", TAG, *arguments)
+ }
+ private fun logD(msg: String, vararg arguments: Any?) {
+ ProtoLog.d(WM_SHELL_DESKTOP_MODE, "%s: $msg", TAG, *arguments)
+ }
+ private fun logW(msg: String, vararg arguments: Any?) {
+ ProtoLog.w(WM_SHELL_DESKTOP_MODE, "%s: $msg", TAG, *arguments)
+ }
+
companion object {
@JvmField
val DESKTOP_MODE_INITIAL_BOUNDS_SCALE =
SystemProperties.getInt("persist.wm.debug.desktop_mode_initial_bounds_scale", 75) / 100f
+
+ private const val TAG = "DesktopTasksController"
}
/** The positions on a screen that a task can snap to. */