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

Commit 63157f31 authored by Jorge Gil's avatar Jorge Gil Committed by Android (Google) Code Review
Browse files

Merge "Desks: Add more logs for activation with task across displays" into main

parents 7c7d2efa aa346fd3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.os.Parcelable

/** Transition source types for Desktop Mode. */
enum class DesktopModeTransitionSource : Parcelable {
    /** Transitions that originated from an adb command. */
    ADB_COMMAND,
    /** Transitions that originated as a consequence of task dragging. */
    TASK_DRAG,
    /** Transitions that originated from an app from Overview. */
+2 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.wm.shell.desktopmode
import android.app.ActivityTaskManager.INVALID_TASK_ID
import android.window.DesktopExperienceFlags
import com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.UnminimizeReason
import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource.ADB_COMMAND
import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource.UNKNOWN
import com.android.wm.shell.sysui.ShellCommandHandler
import com.android.wm.shell.transition.FocusTransitionObserver
@@ -85,8 +86,7 @@ class DesktopModeShellCommandHandler(
                pw.println("Error: desk id should be an integer")
                return false
            }
        controller.moveTaskToDesk(taskId = taskId, deskId = deskId, transitionSource = UNKNOWN)
        pw.println("Not implemented.")
        controller.moveTaskToDesk(taskId = taskId, deskId = deskId, transitionSource = ADB_COMMAND)
        return true
    }

+15 −3
Original line number Diff line number Diff line
@@ -618,6 +618,7 @@ class DesktopTasksController(
        remoteTransition: RemoteTransition? = null,
        callback: IMoveToDesktopCallback? = null,
    ): Boolean {
        logV("moveTaskToDesk taskId=%d deskId=%d source=%s", taskId, deskId, transitionSource)
        val runningTask = shellTaskOrganizer.getRunningTaskInfo(taskId)
        if (runningTask != null) {
            return moveRunningTaskToDesk(
@@ -2789,6 +2790,12 @@ class DesktopTasksController(
    ) {
        val targetDisplayId = taskRepository.getDisplayForDesk(deskId)
        val displayLayout = displayController.getDisplayLayout(targetDisplayId) ?: return
        logV(
            "addMoveToDeskTaskChanges taskId=%d deskId=%d displayId=%d",
            task.taskId,
            deskId,
            targetDisplayId,
        )
        val inheritedTaskBounds =
            getInheritedExistingTaskBounds(taskRepository, shellTaskOrganizer, task, deskId)
        if (inheritedTaskBounds != null) {
@@ -3075,10 +3082,15 @@ class DesktopTasksController(
        // TODO: b/362720497 - should this be true in other places? Can it be calculated locally
        //  without having to specify the value?
        addPendingLaunchTransition: Boolean = false,
    ): RunOnTransitStart? {
        logV("addDeskActivationChanges newTaskId=%d deskId=%d", newTask?.taskId, deskId)
    ): RunOnTransitStart {
        val newTaskIdInFront = newTask?.taskId
        val displayId = taskRepository.getDisplayForDesk(deskId)
        logV(
            "addDeskActivationChanges newTaskId=%d deskId=%d displayId=%d",
            newTask?.taskId,
            deskId,
            displayId,
        )
        if (!DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue) {
            val taskIdToMinimize = bringDesktopAppsToFront(displayId, wct, newTask?.taskId)
            return { transition ->
@@ -3131,7 +3143,7 @@ class DesktopTasksController(
        return { transition ->
            val activateDeskTransition =
                if (newTaskIdInFront != null) {
                    DeskTransition.ActiveDeskWithTask(
                    DeskTransition.ActivateDeskWithTask(
                        token = transition,
                        displayId = displayId,
                        deskId = deskId,
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ sealed interface DeskTransition {
    }

    /** A transition to activate a desk by moving an outside task to it. */
    data class ActiveDeskWithTask(
    data class ActivateDeskWithTask(
        override val token: IBinder,
        val displayId: Int,
        val deskId: Int,
+21 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.wm.shell.desktopmode.multidesks

import android.os.IBinder
import android.view.Display.INVALID_DISPLAY
import android.view.WindowManager.TRANSIT_CHANGE
import android.view.WindowManager.TRANSIT_CLOSE
import android.window.DesktopExperienceFlags
@@ -175,14 +176,29 @@ class DesksTransitionObserver(
                    deskId = deskTransition.deskId,
                )
            }
            is DeskTransition.ActiveDeskWithTask -> {
                val withTask =
            is DeskTransition.ActivateDeskWithTask -> {
                val deskId = deskTransition.deskId
                val deskChange =
                    info.changes.find { change -> desksOrganizer.isDeskChange(change, deskId) }
                if (deskChange != null) {
                    val deskChangeDisplayId = deskChange.taskInfo?.displayId ?: INVALID_DISPLAY
                    if (deskChangeDisplayId != deskTransition.displayId) {
                        logW(
                            "ActivateDeskWithTask: expected displayId=%d but got displayId=%d",
                            deskTransition.displayId,
                            deskChangeDisplayId,
                        )
                    }
                } else {
                    logW("ActivateDeskWithTask: did not find desk change")
                }
                val taskChange =
                    info.changes.find { change ->
                        change.taskInfo?.taskId == deskTransition.enterTaskId &&
                            change.taskInfo?.isVisibleRequested == true &&
                            desksOrganizer.getDeskAtEnd(change) == deskTransition.deskId
                    }
                withTask?.let {
                if (taskChange != null) {
                    desktopRepository.setActiveDesk(
                        displayId = deskTransition.displayId,
                        deskId = deskTransition.deskId,
@@ -193,6 +209,8 @@ class DesksTransitionObserver(
                        taskId = deskTransition.enterTaskId,
                        isVisible = true,
                    )
                } else {
                    logW("ActivateDeskWithTask: did not find task change")
                }
            }
            is DeskTransition.DeactivateDesk -> handleDeactivateDeskTransition(info, deskTransition)
Loading