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

Commit 9339b8d0 authored by Ben Murdoch's avatar Ben Murdoch Committed by Android (Google) Code Review
Browse files

Merge "Output trace counter for desktop windowing active tasks." into main

parents 35cc5931 7a222c4b
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()
                )
            }
        }
    }