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

Commit e47b941d authored by Omar Elmekkawy's avatar Omar Elmekkawy
Browse files

Add tiling logging.

Flag: com.android.window.flags.enable_tile_resizing
Test: EXEMPT, logging.
Bug: 429976590
Change-Id: I958238dbb581dbcc74971c4f6cda53798eb01f9c
parent eff6d198
Loading
Loading
Loading
Loading
+32 −2
Original line number Diff line number Diff line
@@ -43,7 +43,9 @@ import android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER
import android.view.WindowlessWindowManager
import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_TILE_RESIZING
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.protolog.ProtoLog
import com.android.wm.shell.R
import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE
import java.util.concurrent.TimeUnit
import java.util.function.Supplier

@@ -140,6 +142,7 @@ class DesktopTilingDividerWindowManager(
     * @param relativeLeash the task leash that the TilingDividerView should be shown on top of.
     */
    fun generateViewHost(relativeLeash: SurfaceControl) {
        logV("Generating tiling view host.")
        val surfaceControlViewHost =
            SurfaceControlViewHost(
                displayContext,
@@ -207,6 +210,7 @@ class DesktopTilingDividerWindowManager(
        if (!dividerShown) {
            return
        }
        logD("Hiding tiling divider bar.")
        cancelAnimation()
        val t = transactionSupplier.get()
        t.hide(leash)
@@ -223,6 +227,7 @@ class DesktopTilingDividerWindowManager(
    /** Shows the divider bar. */
    fun showDividerBar(isTilingVisibleAfterRecents: Boolean) {
        if (dividerShown || runningAnimator != null) return
        logD("Showing tiling divider bar.")
        val dividerAnimatorT = transactionSupplier.get()
        val dividerAnimDuration =
            if (isTilingVisibleAfterRecents) {
@@ -262,15 +267,26 @@ class DesktopTilingDividerWindowManager(
    }

    override fun onDividerMoveStart(pos: Int, motionEvent: MotionEvent) {
        logD("Tiling divider move start.")
        setSlippery(false)
        beginJankMonitoring()
        transitionHandler.onDividerHandleDragStart(motionEvent)
    }

    private fun beginJankMonitoring() {
        val dividerView = tilingDividerView ?: return
        val dividerView =
            tilingDividerView
                ?: run {
                    logE(
                        "Attempting to monitor tiling jank without a tiling divider is not possible."
                    )
                    return
                }
        interactionJankMonitor.begin(
            InteractionJankMonitor.Configuration.Builder.withView(CUJ_DESKTOP_MODE_TILE_RESIZING, dividerView)
            InteractionJankMonitor.Configuration.Builder.withView(
                    CUJ_DESKTOP_MODE_TILE_RESIZING,
                    dividerView,
                )
                .setTimeout(LONG_CUJ_TIMEOUT_MS)
        )
    }
@@ -296,6 +312,7 @@ class DesktopTilingDividerWindowManager(
     * WindowContainerTransactions if the sizes of the tiled tasks changed.
     */
    override fun onDividerMovedEnd(pos: Int, motionEvent: MotionEvent) {
        logD("Tiling divider move end.")
        setSlippery(true)
        endJankMonitoring()
        val t = transactionSupplier.get()
@@ -383,5 +400,18 @@ class DesktopTilingDividerWindowManager(
        // Timeout used for resize and drag CUJs, this is longer than the default timeout to avoid
        // timing out in the middle of a resize or drag action.
        private val LONG_CUJ_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(10L)
        private val TAG = DesktopTilingDividerWindowManager::class.java.simpleName
    }

    private fun logD(msg: String, vararg arguments: Any?) {
        ProtoLog.d(WM_SHELL_DESKTOP_MODE, "%s: $msg", TAG, *arguments)
    }

    private fun logV(msg: String, vararg arguments: Any?) {
        ProtoLog.v(WM_SHELL_DESKTOP_MODE, "%s: $msg", TAG, *arguments)
    }

    private fun logE(msg: String, vararg arguments: Any?) {
        ProtoLog.e(WM_SHELL_DESKTOP_MODE, "%s: $msg", TAG, *arguments)
    }
}
+36 −8
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.res.Resources
import android.graphics.Rect
import android.os.IBinder
import android.os.UserHandle
import android.util.Log
import android.view.MotionEvent
import android.view.SurfaceControl
import android.view.SurfaceControl.Transaction
@@ -39,6 +40,7 @@ import android.window.TransitionRequestInfo
import android.window.WindowContainerTransaction
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.protolog.ProtoLog
import com.android.launcher3.icons.BaseIconFactory
import com.android.wm.shell.R
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
@@ -53,6 +55,7 @@ import com.android.wm.shell.desktopmode.DesktopTasksController.SnapPosition
import com.android.wm.shell.desktopmode.DesktopUserRepositories
import com.android.wm.shell.desktopmode.ReturnToDragStartAnimator
import com.android.wm.shell.desktopmode.ToggleResizeDesktopTaskTransitionHandler
import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE
import com.android.wm.shell.shared.FocusTransitionListener
import com.android.wm.shell.shared.annotations.ShellBackgroundThread
import com.android.wm.shell.shared.annotations.ShellMainThread
@@ -63,12 +66,12 @@ import com.android.wm.shell.transition.FocusTransitionObserver
import com.android.wm.shell.transition.Transitions
import com.android.wm.shell.transition.Transitions.TRANSIT_MINIMIZE
import com.android.wm.shell.transition.Transitions.TRANSIT_START_RECENTS_TRANSITION
import com.android.wm.shell.windowdecor.WindowDecorationWrapper
import com.android.wm.shell.windowdecor.DragPositioningCallbackUtility
import com.android.wm.shell.windowdecor.DragPositioningCallbackUtility.DragEventListener
import com.android.wm.shell.windowdecor.DragResizeWindowGeometry
import com.android.wm.shell.windowdecor.DragResizeWindowGeometry.DisabledEdge.NONE
import com.android.wm.shell.windowdecor.ResizeVeil
import com.android.wm.shell.windowdecor.WindowDecorationWrapper
import com.android.wm.shell.windowdecor.common.WindowDecorTaskResourceLoader
import com.android.wm.shell.windowdecor.extension.isFullscreen
import java.util.function.Supplier
@@ -155,6 +158,12 @@ class DesktopTilingWindowDecoration(
            moveTiledPairToFront(taskInfo.taskId, taskInfo.isFocused)
        }
        updateDesktopRepository(taskInfo.taskId, snapPosition = position)
        logD(
            "Snapping taskId=%d on deskId=%d to the %s",
            taskInfo.taskId,
            deskId,
            position.toString(),
        )
        if (isTiled) {
            val wct = WindowContainerTransaction().setBounds(taskInfo.token, destinationBounds)
            toggleResizeDesktopTaskTransitionHandler.startTransition(wct, currentBounds, callback)
@@ -254,6 +263,7 @@ class DesktopTilingWindowDecoration(
        rootTdaOrganizer.attachToDisplayArea(displayId, builder)
        val leash = builder.setName(TILING_DIVIDER_TAG).setContainerLayer().build()
        val displayContext = displayController.getDisplayContext(displayId) ?: return null
        logD("initialising tiling manager for display=%d", displayId)
        val tilingManager =
            displayLayout?.let {
                dividerBounds = inflateDividerBounds(it)
@@ -485,6 +495,7 @@ class DesktopTilingWindowDecoration(
        }

        if (leftTaskBroughtToFront && rightTaskBroughtToFront) {
            logD("Tiled tasks brought to front")
            desktopTilingDividerWindowManager?.showDividerBar(hiddenByOverviewAnimation)
            hiddenByOverviewAnimation = false
        }
@@ -649,6 +660,8 @@ class DesktopTilingWindowDecoration(
        val taskRepository = desktopUserRepositories.current

        if (taskId == leftTaskResizingHelper?.taskInfo?.taskId) {
            logD("Removing left tiled task with id=%d", taskId)
            logV("Stack: ${Log.getStackTraceString(Throwable())}")
            removeLeftTiledTaskFromDesk()
            removeTask(leftTaskResizingHelper, taskVanished, shouldDelayUpdate)
            leftTaskResizingHelper = null
@@ -668,8 +681,8 @@ class DesktopTilingWindowDecoration(
        }

        if (taskId == rightTaskResizingHelper?.taskInfo?.taskId) {
            logD("Removing right tiled task with id=%d", taskId)
            removeRightTiledTaskFromDesk()

            removeTask(rightTaskResizingHelper, taskVanished, shouldDelayUpdate)
            rightTaskResizingHelper = null
            val taskId = leftTaskResizingHelper?.taskInfo?.taskId
@@ -689,6 +702,7 @@ class DesktopTilingWindowDecoration(
    }

    fun resetTilingSession(shouldPersistTilingData: Boolean = false) {
        logD("Resetting tiling session.")
        if (leftTaskResizingHelper != null) {
            if (!shouldPersistTilingData) removeLeftTiledTaskFromDesk()
            removeTask(leftTaskResizingHelper, taskVanished = false, shouldDelayUpdate = true)
@@ -718,10 +732,7 @@ class DesktopTilingWindowDecoration(
        if (appResizingHelper == null) return
        if (!taskVanished) {
            appResizingHelper.windowDecoration.removeDragResizeListener(this)
            appResizingHelper.windowDecoration.updateDisabledResizingEdge(
                NONE,
                shouldDelayUpdate,
            )
            appResizingHelper.windowDecoration.updateDisabledResizingEdge(NONE, shouldDelayUpdate)
        }
        appResizingHelper.dispose()
    }
@@ -755,7 +766,12 @@ class DesktopTilingWindowDecoration(
    }

    private fun checkForUiModeChange(config: Configuration?) {
        val uiMode = config?.uiMode ?: return
        val uiMode =
            config?.uiMode
                ?: run {
                    logW("Unexpected null UI mode when running tiling check.")
                    return
                }
        val isDeviceInDarkMode = isInDarkMode(uiMode)
        try {
            if (isDeviceInDarkMode == isDarkMode || !isTilingManagerInitialised) return
@@ -789,7 +805,7 @@ class DesktopTilingWindowDecoration(
            isTilingFocused = false
            return false
        }

        logD("Moving tiled pair to front.")
        val leftTiledTask = leftTaskResizingHelper ?: return false
        val rightTiledTask = rightTaskResizingHelper ?: return false
        if (!allTiledTasksVisible()) return false
@@ -922,4 +938,16 @@ class DesktopTilingWindowDecoration(
        desktopTilingDividerWindowManager?.release()
        desktopTilingDividerWindowManager = null
    }

    private fun logD(msg: String, vararg arguments: Any?) {
        ProtoLog.d(WM_SHELL_DESKTOP_MODE, "%s: $msg", TAG, *arguments)
    }

    private fun logW(msg: String, vararg arguments: Any?) {
        ProtoLog.w(WM_SHELL_DESKTOP_MODE, "%s: $msg", TAG, *arguments)
    }

    private fun logV(msg: String, vararg arguments: Any?) {
        ProtoLog.v(WM_SHELL_DESKTOP_MODE, "%s: $msg", TAG, *arguments)
    }
}