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

Commit bd0534c6 authored by Devarshi Bhatt's avatar Devarshi Bhatt
Browse files

Add instrumentation for enter window mode with app handle drag CUJ.

See go/windowing-jank-coverage-one-pager for more details.

Bug: 339585205
Test: perfetto trace(https://screenshot.googleplex.com/AeiTJqrttW9J2Uz

)
Flag: NONE new perfetto instrumentation

Change-Id: I41611b16e2f716b2f66dc2840fbdb86d8dbc8029
Signed-off-by: default avatarDevarshi Bhatt <devarshimb@google.com>
parent 23cbe12b
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -534,7 +534,8 @@ public abstract class WMShellModule {
            MultiInstanceHelper multiInstanceHelper,
            @ShellMainThread ShellExecutor mainExecutor,
            Optional<DesktopTasksLimiter> desktopTasksLimiter,
            Optional<RecentTasksController> recentTasksController) {
            Optional<RecentTasksController> recentTasksController,
            InteractionJankMonitor interactionJankMonitor) {
        return new DesktopTasksController(context, shellInit, shellCommandHandler, shellController,
                displayController, shellTaskOrganizer, syncQueue, rootTaskDisplayAreaOrganizer,
                dragAndDropController, transitions, keyguardManager, enterDesktopTransitionHandler,
@@ -542,7 +543,8 @@ public abstract class WMShellModule {
                dragToDesktopTransitionHandler, desktopModeTaskRepository,
                desktopModeLoggerTransitionObserver, launchAdjacentController,
                recentsTransitionHandler, multiInstanceHelper,
                mainExecutor, desktopTasksLimiter, recentTasksController.orElse(null));
                mainExecutor, desktopTasksLimiter, recentTasksController.orElse(null),
                interactionJankMonitor);
    }

    @WMSingleton
@@ -568,9 +570,10 @@ public abstract class WMShellModule {
            Context context,
            Transitions transitions,
            RootTaskDisplayAreaOrganizer rootTaskDisplayAreaOrganizer,
            Optional<DesktopTasksLimiter> desktopTasksLimiter) {
            Optional<DesktopTasksLimiter> desktopTasksLimiter,
            InteractionJankMonitor interactionJankMonitor) {
        return new DragToDesktopTransitionHandler(context, transitions,
                rootTaskDisplayAreaOrganizer);
                rootTaskDisplayAreaOrganizer, interactionJankMonitor);
    }

    @WMSingleton
+14 −1
Original line number Diff line number Diff line
@@ -49,6 +49,9 @@ import android.window.TransitionRequestInfo
import android.window.WindowContainerTransaction
import androidx.annotation.BinderThread
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD
import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_RELEASE
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.policy.ScreenDecorationsUtils
import com.android.internal.protolog.ProtoLog
import com.android.window.flags.Flags
@@ -123,7 +126,8 @@ class DesktopTasksController(
    private val multiInstanceHelper: MultiInstanceHelper,
    @ShellMainThread private val mainExecutor: ShellExecutor,
    private val desktopTasksLimiter: Optional<DesktopTasksLimiter>,
    private val recentTasksController: RecentTasksController?
    private val recentTasksController: RecentTasksController?,
    private val interactionJankMonitor: InteractionJankMonitor
) :
    RemoteCallable<DesktopTasksController>,
    Transitions.TransitionHandler,
@@ -378,12 +382,15 @@ class DesktopTasksController(
    fun startDragToDesktop(
        taskInfo: RunningTaskInfo,
        dragToDesktopValueAnimator: MoveToDesktopAnimator,
        taskSurface: SurfaceControl,
    ) {
        ProtoLog.v(
            WM_SHELL_DESKTOP_MODE,
            "DesktopTasksController: startDragToDesktop taskId=%d",
            taskInfo.taskId
        )
        interactionJankMonitor.begin(taskSurface, context,
            CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD)
        dragToDesktopTransitionHandler.startDragToDesktopTransition(
            taskInfo.taskId,
            dragToDesktopValueAnimator
@@ -1340,13 +1347,19 @@ class DesktopTasksController(
    fun onDragPositioningEndThroughStatusBar(
        inputCoordinates: PointF,
        taskInfo: RunningTaskInfo,
        taskSurface: SurfaceControl,
    ): IndicatorType {
        // End the drag_hold CUJ interaction.
        interactionJankMonitor.end(CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD)
        val indicator = getVisualIndicator() ?: return IndicatorType.NO_INDICATOR
        val indicatorType = indicator.updateIndicatorType(inputCoordinates, taskInfo.windowingMode)
        when (indicatorType) {
            IndicatorType.TO_DESKTOP_INDICATOR -> {
                val displayLayout = displayController.getDisplayLayout(taskInfo.displayId)
                    ?: return IndicatorType.NO_INDICATOR
                // Start a new jank interaction for the drag release to desktop window animation.
                interactionJankMonitor.begin(taskSurface, context,
                    CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_RELEASE, "to_desktop")
                if (Flags.enableWindowingDynamicInitialBounds()) {
                    finalizeDragToDesktop(taskInfo, calculateInitialBounds(displayLayout, taskInfo))
                } else {
+14 −2
Original line number Diff line number Diff line
@@ -30,6 +30,9 @@ import android.window.TransitionRequestInfo
import android.window.WindowContainerToken
import android.window.WindowContainerTransaction
import com.android.internal.protolog.ProtoLog
import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD
import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_RELEASE
import com.android.internal.jank.InteractionJankMonitor
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
import com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT
import com.android.wm.shell.common.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT
@@ -57,17 +60,20 @@ class DragToDesktopTransitionHandler(
    private val context: Context,
    private val transitions: Transitions,
    private val taskDisplayAreaOrganizer: RootTaskDisplayAreaOrganizer,
    private val transactionSupplier: Supplier<SurfaceControl.Transaction>
    private val interactionJankMonitor: InteractionJankMonitor,
    private val transactionSupplier: Supplier<SurfaceControl.Transaction>,
) : TransitionHandler {

    constructor(
        context: Context,
        transitions: Transitions,
        rootTaskDisplayAreaOrganizer: RootTaskDisplayAreaOrganizer
        rootTaskDisplayAreaOrganizer: RootTaskDisplayAreaOrganizer,
        interactionJankMonitor: InteractionJankMonitor
    ) : this(
        context,
        transitions,
        rootTaskDisplayAreaOrganizer,
        interactionJankMonitor,
        Supplier { SurfaceControl.Transaction() }
    )

@@ -567,6 +573,8 @@ class DragToDesktopTransitionHandler(
                                onTaskResizeAnimationListener.onAnimationEnd(state.draggedTaskId)
                                startTransitionFinishCb.onTransitionFinished(null /* null */)
                                clearState()
                                interactionJankMonitor.end(
                                    CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_RELEASE)
                            }
                        }
                    )
@@ -604,6 +612,10 @@ class DragToDesktopTransitionHandler(
                "DragToDesktop: onTransitionConsumed() start transition aborted"
            )
            state.startAborted = true
            // Cancel CUJ interaction if the transition is aborted.
            interactionJankMonitor.cancel(CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD)
        } else if (state.cancelTransitionToken != transition) {
            interactionJankMonitor.cancel(CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_RELEASE)
        }
    }

+4 −2
Original line number Diff line number Diff line
@@ -970,7 +970,9 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                        relevantDecor.updateHoverAndPressStatus(ev);
                        DesktopModeVisualIndicator.IndicatorType resultType =
                                mDesktopTasksController.onDragPositioningEndThroughStatusBar(
                                new PointF(ev.getRawX(), ev.getRawY()), relevantDecor.mTaskInfo);
                                        new PointF(ev.getRawX(), ev.getRawY()),
                                        relevantDecor.mTaskInfo,
                                        relevantDecor.mTaskSurface);
                        // If we are entering split select, handle will no longer be visible and
                        // should not be receiving any input.
                        if (resultType == TO_SPLIT_LEFT_INDICATOR
@@ -1010,7 +1012,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
                                    mContext, mDragToDesktopAnimationStartBounds,
                                    relevantDecor.mTaskInfo, relevantDecor.mTaskSurface);
                            mDesktopTasksController.startDragToDesktop(relevantDecor.mTaskInfo,
                                    mMoveToDesktopAnimator);
                                    mMoveToDesktopAnimator, relevantDecor.mTaskSurface);
                        }
                    }
                    if (mMoveToDesktopAnimator != null) {
+16 −11
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn
import com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession
import com.android.dx.mockito.inline.extended.ExtendedMockito.never
import com.android.dx.mockito.inline.extended.StaticMockitoSession
import com.android.internal.jank.InteractionJankMonitor
import com.android.window.flags.Flags
import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE
import com.android.wm.shell.MockToken
@@ -166,6 +167,9 @@ class DesktopTasksControllerTest : ShellTestCase() {
  @Mock lateinit var desktopModeLoggerTransitionObserver: DesktopModeLoggerTransitionObserver
  @Mock lateinit var desktopModeVisualIndicator: DesktopModeVisualIndicator
  @Mock lateinit var recentTasksController: RecentTasksController
  @Mock
  private lateinit var mockInteractionJankMonitor: InteractionJankMonitor
  @Mock private lateinit var mockSurface: SurfaceControl

  private lateinit var mockitoSession: StaticMockitoSession
  private lateinit var controller: DesktopTasksController
@@ -248,7 +252,8 @@ class DesktopTasksControllerTest : ShellTestCase() {
        multiInstanceHelper,
        shellExecutor,
        Optional.of(desktopTasksLimiter),
        recentTasksController)
        recentTasksController,
        mockInteractionJankMonitor)
  }

  @After
@@ -2016,7 +2021,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
    val task = setUpFullscreenTask()
    setUpLandscapeDisplay()

    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task)
    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task, mockSurface)
    val wct = getLatestDragToDesktopWct()
    assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS)
  }
@@ -2032,7 +2037,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
    val task = setUpFullscreenTask(screenOrientation = SCREEN_ORIENTATION_LANDSCAPE)
    setUpLandscapeDisplay()

    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task)
    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task, mockSurface)
    val wct = getLatestDragToDesktopWct()
    assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS)
  }
@@ -2049,7 +2054,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
        setUpFullscreenTask(screenOrientation = SCREEN_ORIENTATION_PORTRAIT, shouldLetterbox = true)
    setUpLandscapeDisplay()

    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task)
    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task, mockSurface)
    val wct = getLatestDragToDesktopWct()
    assertThat(findBoundsChange(wct, task)).isEqualTo(RESIZABLE_PORTRAIT_BOUNDS)
  }
@@ -2066,7 +2071,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
        setUpFullscreenTask(isResizable = false, screenOrientation = SCREEN_ORIENTATION_LANDSCAPE)
    setUpLandscapeDisplay()

    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task)
    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task, mockSurface)
    val wct = getLatestDragToDesktopWct()
    assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_LANDSCAPE_BOUNDS)
  }
@@ -2086,7 +2091,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
            shouldLetterbox = true)
    setUpLandscapeDisplay()

    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task)
    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task, mockSurface)
    val wct = getLatestDragToDesktopWct()
    assertThat(findBoundsChange(wct, task)).isEqualTo(UNRESIZABLE_PORTRAIT_BOUNDS)
  }
@@ -2102,7 +2107,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
    val task = setUpFullscreenTask(deviceOrientation = ORIENTATION_PORTRAIT)
    setUpPortraitDisplay()

    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task)
    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task, mockSurface)
    val wct = getLatestDragToDesktopWct()
    assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS)
  }
@@ -2121,7 +2126,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
            screenOrientation = SCREEN_ORIENTATION_PORTRAIT)
    setUpPortraitDisplay()

    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task)
    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task, mockSurface)
    val wct = getLatestDragToDesktopWct()
    assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS)
  }
@@ -2141,7 +2146,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
            shouldLetterbox = true)
    setUpPortraitDisplay()

    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task)
    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task, mockSurface)
    val wct = getLatestDragToDesktopWct()
    assertThat(findBoundsChange(wct, task)).isEqualTo(RESIZABLE_LANDSCAPE_BOUNDS)
  }
@@ -2161,7 +2166,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
            screenOrientation = SCREEN_ORIENTATION_PORTRAIT)
    setUpPortraitDisplay()

    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task)
    spyController.onDragPositioningEndThroughStatusBar(PointF(800f, 1280f), task, mockSurface)
    val wct = getLatestDragToDesktopWct()
    assertThat(findBoundsChange(wct, task)).isEqualTo(DEFAULT_PORTRAIT_BOUNDS)
  }
@@ -2182,7 +2187,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
            shouldLetterbox = true)
    setUpPortraitDisplay()

    spyController.onDragPositioningEndThroughStatusBar(PointF(200f, 200f), task)
    spyController.onDragPositioningEndThroughStatusBar(PointF(200f, 200f), task, mockSurface)
    val wct = getLatestDragToDesktopWct()
    assertThat(findBoundsChange(wct, task)).isEqualTo(UNRESIZABLE_LANDSCAPE_BOUNDS)
  }
Loading