Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7a222c4b authored by Ben Murdoch's avatar Ben Murdoch
Browse files

Output trace counter for desktop windowing active tasks.

When desktop windows are added or removed, log a counter for the
number of active tasks.

Bug: 358369221
Flag: EXEMPT, trivial change
Test: Manual - add/remove some windows with tracing on and check trace.
Change-Id: I83346ad3b926ffad60e1ede0d3ea490e9b5c2160
parent cc76d06b
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.app.TaskInfo
import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM
import android.content.Context
import android.os.IBinder
import android.os.Trace
import android.util.SparseArray
import android.view.SurfaceControl
import android.view.WindowManager
@@ -51,6 +52,8 @@ import com.android.wm.shell.shared.TransitionUtil
import com.android.wm.shell.sysui.ShellInit
import com.android.wm.shell.transition.Transitions

const val VISIBLE_TASKS_COUNTER_NAME = "DESKTOP_MODE_VISIBLE_TASKS"

/**
 * A [Transitions.TransitionObserver] that observes transitions and the proposed changes to log
 * appropriate desktop mode session log events. This observes transitions related to desktop mode
@@ -292,8 +295,14 @@ class DesktopModeLoggerTransitionObserver(
            val previousTaskInfo = preTransitionVisibleFreeformTasks[taskId]
            when {
                // new tasks added
                previousTaskInfo == null ->
                previousTaskInfo == null -> {
                    desktopModeEventLogger.logTaskAdded(sessionId, currentTaskUpdate)
                    Trace.setCounter(
                        Trace.TRACE_TAG_WINDOW_MANAGER,
                        VISIBLE_TASKS_COUNTER_NAME,
                        postTransitionVisibleFreeformTasks.size().toLong()
                    )
                }
                // old tasks that were resized or repositioned
                // TODO(b/347935387): Log changes only once they are stable.
                buildTaskUpdateForTask(previousTaskInfo) != currentTaskUpdate ->
@@ -305,6 +314,11 @@ class DesktopModeLoggerTransitionObserver(
        preTransitionVisibleFreeformTasks.forEach { taskId, taskInfo ->
            if (!postTransitionVisibleFreeformTasks.containsKey(taskId)) {
                desktopModeEventLogger.logTaskRemoved(sessionId, buildTaskUpdateForTask(taskInfo))
                Trace.setCounter(
                    Trace.TRACE_TAG_WINDOW_MANAGER,
                    VISIBLE_TASKS_COUNTER_NAME,
                    postTransitionVisibleFreeformTasks.size().toLong()
                )
            }
        }
    }