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

Commit 4b04cb4f authored by Ats Jenk's avatar Ats Jenk
Browse files

Add more logging to debug desktop task launches

Adding more logging to handleRequest method to debug why a task would or
would not launch on the desktop.

Bug: 286929122
Test: m -j
Change-Id: I9cebe02d9e81ffb1e305df8ba15f4d0f0a1193ef
parent dd116a6f
Loading
Loading
Loading
Loading
+34 −6
Original line number Original line Diff line number Diff line
@@ -500,36 +500,62 @@ class DesktopTasksController(
            request
            request
        )
        )
        // Check if we should skip handling this transition
        // Check if we should skip handling this transition
        var reason = ""
        val shouldHandleRequest =
        val shouldHandleRequest =
            when {
            when {
                // Only handle open or to front transitions
                // Only handle open or to front transitions
                request.type != TRANSIT_OPEN && request.type != TRANSIT_TO_FRONT -> false
                request.type != TRANSIT_OPEN && request.type != TRANSIT_TO_FRONT -> {
                    reason = "transition type not handled (${request.type})"
                    false
                }
                // Only handle when it is a task transition
                // Only handle when it is a task transition
                request.triggerTask == null -> false
                request.triggerTask == null -> {
                    reason = "triggerTask is null"
                    false
                }
                // Only handle standard type tasks
                // Only handle standard type tasks
                request.triggerTask.activityType != ACTIVITY_TYPE_STANDARD -> false
                request.triggerTask.activityType != ACTIVITY_TYPE_STANDARD -> {
                    reason = "activityType not handled (${request.triggerTask.activityType})"
                    false
                }
                // Only handle fullscreen or freeform tasks
                // Only handle fullscreen or freeform tasks
                request.triggerTask.windowingMode != WINDOWING_MODE_FULLSCREEN &&
                request.triggerTask.windowingMode != WINDOWING_MODE_FULLSCREEN &&
                        request.triggerTask.windowingMode != WINDOWING_MODE_FREEFORM -> false
                        request.triggerTask.windowingMode != WINDOWING_MODE_FREEFORM -> {
                    reason = "windowingMode not handled (${request.triggerTask.windowingMode})"
                    false
                }
                // Otherwise process it
                // Otherwise process it
                else -> true
                else -> true
            }
            }


        if (!shouldHandleRequest) {
        if (!shouldHandleRequest) {
            KtProtoLog.v(
                    WM_SHELL_DESKTOP_MODE,
                    "DesktopTasksController: skipping handleRequest reason=%s",
                    reason
            )
            return null
            return null
        }
        }


        val task: RunningTaskInfo = request.triggerTask
        val task: RunningTaskInfo = request.triggerTask


        return when {
        val result = when {
            // If display has tasks stashed, handle as stashed launch
            // If display has tasks stashed, handle as stashed launch
            desktopModeTaskRepository.isStashed(task.displayId) -> handleStashedTaskLaunch(task)
            desktopModeTaskRepository.isStashed(task.displayId) -> handleStashedTaskLaunch(task)
            // Check if fullscreen task should be updated
            // Check if fullscreen task should be updated
            task.windowingMode == WINDOWING_MODE_FULLSCREEN -> handleFullscreenTaskLaunch(task)
            task.windowingMode == WINDOWING_MODE_FULLSCREEN -> handleFullscreenTaskLaunch(task)
            // Check if freeform task should be updated
            // Check if freeform task should be updated
            task.windowingMode == WINDOWING_MODE_FREEFORM -> handleFreeformTaskLaunch(task)
            task.windowingMode == WINDOWING_MODE_FREEFORM -> handleFreeformTaskLaunch(task)
            else -> null
            else -> {
                null
            }
        }
        }
        KtProtoLog.v(
                WM_SHELL_DESKTOP_MODE,
                "DesktopTasksController: handleRequest result=%s",
                result ?: "null"
        )
        return result
    }
    }


    /**
    /**
@@ -552,6 +578,7 @@ class DesktopTasksController(
    }
    }


    private fun handleFreeformTaskLaunch(task: RunningTaskInfo): WindowContainerTransaction? {
    private fun handleFreeformTaskLaunch(task: RunningTaskInfo): WindowContainerTransaction? {
        KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: handleFreeformTaskLaunch")
        val activeTasks = desktopModeTaskRepository.getActiveTasks(task.displayId)
        val activeTasks = desktopModeTaskRepository.getActiveTasks(task.displayId)
        if (activeTasks.none { desktopModeTaskRepository.isVisibleTask(it) }) {
        if (activeTasks.none { desktopModeTaskRepository.isVisibleTask(it) }) {
            KtProtoLog.d(
            KtProtoLog.d(
@@ -568,6 +595,7 @@ class DesktopTasksController(
    }
    }


    private fun handleFullscreenTaskLaunch(task: RunningTaskInfo): WindowContainerTransaction? {
    private fun handleFullscreenTaskLaunch(task: RunningTaskInfo): WindowContainerTransaction? {
        KtProtoLog.v(WM_SHELL_DESKTOP_MODE, "DesktopTasksController: handleFullscreenTaskLaunch")
        val activeTasks = desktopModeTaskRepository.getActiveTasks(task.displayId)
        val activeTasks = desktopModeTaskRepository.getActiveTasks(task.displayId)
        if (activeTasks.any { desktopModeTaskRepository.isVisibleTask(it) }) {
        if (activeTasks.any { desktopModeTaskRepository.isVisibleTask(it) }) {
            KtProtoLog.d(
            KtProtoLog.d(