From 213597270339d2ac33ff86d3660d527b2e9d3a6a Mon Sep 17 00:00:00 2001 From: Ats Jenk Date: Thu, 4 May 2023 16:18:01 -0700 Subject: [PATCH] Add and update log statements for desktop proto Add and update log statements in DesktopTasksController to include the controller name in log string. Simplifies tracking down the messages. Add log statements to DesktopModeTaskRepository to ease debugging. Bug: 280657549 Test: build wmshell Change-Id: I37579eba3b0a8b6883f2f2b745061028b42db369 --- .../desktopmode/DesktopModeTaskRepository.kt | 32 ++++++++++ .../desktopmode/DesktopTasksController.kt | 61 +++++++++++++------ 2 files changed, 75 insertions(+), 18 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeTaskRepository.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeTaskRepository.kt index 00cc57f0b99ce..3ab175d3b68a5 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeTaskRepository.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeTaskRepository.kt @@ -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 @@ -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 @@ -158,6 +166,9 @@ class DesktopModeTaskRepository { result = true } } + if (result) { + KtProtoLog.d(WM_SHELL_DESKTOP_MODE, "DesktopTaskRepo: remove active task=%d", taskId) + } return result } @@ -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) @@ -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) } @@ -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) } 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 9de9855720bc7..91bb155d9d01e 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 @@ -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) @@ -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) @@ -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()) @@ -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()) @@ -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) @@ -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) { @@ -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) @@ -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) { @@ -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 @@ -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 ) @@ -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 ) @@ -627,8 +654,6 @@ class DesktopTasksController( } } - - /** The interface for calls from outside the host process. */ @BinderThread private class IDesktopModeImpl(private var controller: DesktopTasksController?) :