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

Commit f68d1721 authored by Vania Desmonda's avatar Vania Desmonda Committed by Android (Google) Code Review
Browse files

Merge changes I35476c60,Iee9612ed into main

* changes:
  Modify logging to use input method from keyboard and derive input method from motion event.
  Fix task resizing metrics since they were getting stale task bounds and on snapping, the resizing ended log is not captured since the tiling flag is enabled.
parents 019d8152 0987f02f
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -187,8 +187,10 @@ class DesktopModeEventLogger {
     */
    fun logTaskResizingStarted(
        resizeTrigger: ResizeTrigger,
        motionEvent: MotionEvent?,
        inputMethod: InputMethod,
        taskInfo: RunningTaskInfo,
        taskWidth: Int? = null,
        taskHeight: Int? = null,
        displayController: DisplayController? = null,
        displayLayoutSize: Size? = null,
    ) {
@@ -205,8 +207,10 @@ class DesktopModeEventLogger {

        val taskSizeUpdate = createTaskSizeUpdate(
            resizeTrigger,
            motionEvent,
            inputMethod,
            taskInfo,
            taskWidth,
            taskHeight,
            displayController = displayController,
            displayLayoutSize = displayLayoutSize,
        )
@@ -228,10 +232,10 @@ class DesktopModeEventLogger {
     */
    fun logTaskResizingEnded(
        resizeTrigger: ResizeTrigger,
        motionEvent: MotionEvent?,
        inputMethod: InputMethod,
        taskInfo: RunningTaskInfo,
        taskHeight: Int? = null,
        taskWidth: Int? = null,
        taskHeight: Int? = null,
        displayController: DisplayController? = null,
        displayLayoutSize: Size? = null,
    ) {
@@ -248,10 +252,10 @@ class DesktopModeEventLogger {

        val taskSizeUpdate = createTaskSizeUpdate(
            resizeTrigger,
            motionEvent,
            inputMethod,
            taskInfo,
            taskHeight,
            taskWidth,
            taskHeight,
            displayController,
            displayLayoutSize,
        )
@@ -271,10 +275,10 @@ class DesktopModeEventLogger {

    private fun createTaskSizeUpdate(
        resizeTrigger: ResizeTrigger,
        motionEvent: MotionEvent?,
        inputMethod: InputMethod,
        taskInfo: RunningTaskInfo,
        taskHeight: Int? = null,
        taskWidth: Int? = null,
        taskHeight: Int? = null,
        displayController: DisplayController? = null,
        displayLayoutSize: Size? = null,
    ): TaskSizeUpdate {
@@ -292,7 +296,7 @@ class DesktopModeEventLogger {

        return TaskSizeUpdate(
            resizeTrigger,
            getInputMethodFromMotionEvent(motionEvent),
            inputMethod,
            taskInfo.taskId,
            taskInfo.effectiveUid,
            height,
@@ -442,7 +446,7 @@ class DesktopModeEventLogger {
            val displayArea: Int?,
        )

        private fun getInputMethodFromMotionEvent(e: MotionEvent?): InputMethod {
        fun getInputMethodFromMotionEvent(e: MotionEvent?): InputMethod {
            if (e == null) return InputMethod.UNKNOWN_INPUT_METHOD

            val toolType = e.getToolType(
+2 −4
Original line number Diff line number Diff line
@@ -66,15 +66,13 @@ class DesktopModeKeyGestureHandler(
                }
                return true
            }
            // TODO(b/375356876): Modify function to pass in keyboard shortcut as the input
            // method for logging task resize
            KeyGestureEvent.KEY_GESTURE_TYPE_SNAP_LEFT_FREEFORM_WINDOW -> {
                logV("Key gesture SNAP_LEFT_FREEFORM_WINDOW is handled")
                getGloballyFocusedFreeformTask()?.let {
                    desktopModeWindowDecorViewModel.get().onSnapResize(
                        it.taskId,
                        true,
                        null
                        DesktopModeEventLogger.Companion.InputMethod.KEYBOARD
                    )
                }
                return true
@@ -85,7 +83,7 @@ class DesktopModeKeyGestureHandler(
                    desktopModeWindowDecorViewModel.get().onSnapResize(
                        it.taskId,
                        false,
                        null
                        DesktopModeEventLogger.Companion.InputMethod.KEYBOARD
                    )
                }
                return true
+32 −18
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ import java.io.PrintWriter
import java.util.Optional
import java.util.concurrent.Executor
import java.util.function.Consumer
import com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.InputMethod
import com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.ResizeTrigger
import com.android.wm.shell.desktopmode.DragToDesktopTransitionHandler.Companion.DRAG_TO_DESKTOP_FINISH_ANIM_DURATION_MS
import com.android.wm.shell.desktopmode.EnterDesktopTaskTransitionHandler.FREEFORM_ANIMATION_DURATION
@@ -820,14 +821,19 @@ class DesktopTasksController(
        resizeTrigger: ResizeTrigger,
        motionEvent: MotionEvent?,
    ) {
        val currentTaskBounds = taskInfo.configuration.windowConfiguration.bounds
        desktopModeEventLogger.logTaskResizingStarted(
            resizeTrigger, motionEvent, taskInfo, displayController
            resizeTrigger,
            DesktopModeEventLogger.getInputMethodFromMotionEvent(motionEvent),
            taskInfo,
            currentTaskBounds.width(),
            currentTaskBounds.height(),
            displayController
        )

        val displayLayout = displayController.getDisplayLayout(taskInfo.displayId) ?: return

        val stableBounds = Rect().apply { displayLayout.getStableBounds(this) }
        val currentTaskBounds = taskInfo.configuration.windowConfiguration.bounds
        val destinationBounds = Rect()

        val isMaximized = isTaskMaximized(taskInfo, stableBounds)
@@ -871,8 +877,9 @@ class DesktopTasksController(
        taskbarDesktopTaskListener?.onTaskbarCornerRoundingUpdate(doesAnyTaskRequireTaskbarRounding)
        val wct = WindowContainerTransaction().setBounds(taskInfo.token, destinationBounds)
        desktopModeEventLogger.logTaskResizingEnded(
            resizeTrigger, motionEvent, taskInfo, destinationBounds.height(),
            destinationBounds.width(), displayController
            resizeTrigger, DesktopModeEventLogger.getInputMethodFromMotionEvent(motionEvent),
            taskInfo, destinationBounds.width(),
            destinationBounds.height(), displayController
        )
        toggleResizeDesktopTaskTransitionHandler.startTransition(wct)
    }
@@ -993,11 +1000,26 @@ class DesktopTasksController(
        currentDragBounds: Rect,
        position: SnapPosition,
        resizeTrigger: ResizeTrigger,
        motionEvent: MotionEvent?,
        inputMethod: InputMethod,
        desktopWindowDecoration: DesktopModeWindowDecoration,
    ) {
        desktopModeEventLogger.logTaskResizingStarted(
            resizeTrigger, motionEvent, taskInfo, displayController
            resizeTrigger,
            inputMethod,
            taskInfo,
            currentDragBounds.width(),
            currentDragBounds.height(),
            displayController
        )

        val destinationBounds = getSnapBounds(taskInfo, position)
        desktopModeEventLogger.logTaskResizingEnded(
            resizeTrigger,
            inputMethod,
            taskInfo,
            destinationBounds.width(),
            destinationBounds.height(),
            displayController,
        )

        if (DesktopModeFlags.ENABLE_TILE_RESIZING.isTrue()) {
@@ -1012,15 +1034,7 @@ class DesktopTasksController(
            }
            return
        }
        val destinationBounds = getSnapBounds(taskInfo, position)
        desktopModeEventLogger.logTaskResizingEnded(
            resizeTrigger,
            motionEvent,
            taskInfo,
            destinationBounds.height(),
            destinationBounds.width(),
            displayController,
        )

        if (destinationBounds == taskInfo.configuration.windowConfiguration.bounds) {
            // Handle the case where we attempt to snap resize when already snap resized: the task
            // position won't need to change but we want to animate the surface going back to the
@@ -1050,7 +1064,7 @@ class DesktopTasksController(
        taskInfo: RunningTaskInfo,
        position: SnapPosition,
        resizeTrigger: ResizeTrigger,
        motionEvent: MotionEvent? = null,
        inputMethod: InputMethod,
        desktopModeWindowDecoration: DesktopModeWindowDecoration,
    ) {
        if (!isSnapResizingAllowed(taskInfo)) {
@@ -1068,7 +1082,7 @@ class DesktopTasksController(
            taskInfo.configuration.windowConfiguration.bounds,
            position,
            resizeTrigger,
            motionEvent,
            inputMethod,
            desktopModeWindowDecoration
        )
    }
@@ -1119,7 +1133,7 @@ class DesktopTasksController(
                currentDragBounds,
                position,
                resizeTrigger,
                motionEvent,
                DesktopModeEventLogger.getInputMethodFromMotionEvent(motionEvent),
                desktopModeWindowDecoration,
            )
        }
+7 −4
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import static android.view.WindowInsets.Type.statusBars;
import static com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_ENTER_MODE_APP_HANDLE_MENU;
import static com.android.window.flags.Flags.enableDisplayFocusInShellTransitions;
import static com.android.wm.shell.compatui.AppCompatUtils.isTopActivityExemptFromDesktopWindowing;
import static com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.InputMethod;
import static com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.ResizeTrigger;
import static com.android.wm.shell.desktopmode.DesktopModeVisualIndicator.IndicatorType.TO_FULLSCREEN_INDICATOR;
import static com.android.wm.shell.desktopmode.DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR;
@@ -590,7 +591,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        decoration.closeMaximizeMenu();
    }

    public void onSnapResize(int taskId, boolean left, @Nullable MotionEvent motionEvent) {
    public void onSnapResize(int taskId, boolean left, InputMethod inputMethod) {
        final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(taskId);
        if (decoration == null) {
            return;
@@ -602,7 +603,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                decoration.mTaskInfo,
                left ? SnapPosition.LEFT : SnapPosition.RIGHT,
                left ? ResizeTrigger.SNAP_LEFT_MENU : ResizeTrigger.SNAP_RIGHT_MENU,
                motionEvent,
                inputMethod,
                decoration);

        decoration.closeHandleMenu();
@@ -1553,6 +1554,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,

        final DesktopModeTouchEventListener touchEventListener =
                new DesktopModeTouchEventListener(taskInfo, taskPositioner);
        InputMethod inputMethod = DesktopModeEventLogger.Companion.getInputMethodFromMotionEvent(
                touchEventListener.mMotionEvent);
        windowDecoration.setOnMaximizeOrRestoreClickListener(() -> {
            onMaximizeOrRestore(taskInfo.taskId, "maximize_menu", ResizeTrigger.MAXIMIZE_MENU,
                    touchEventListener.mMotionEvent);
@@ -1563,11 +1566,11 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
            return Unit.INSTANCE;
        });
        windowDecoration.setOnLeftSnapClickListener(() -> {
            onSnapResize(taskInfo.taskId, /* isLeft= */ true, touchEventListener.mMotionEvent);
            onSnapResize(taskInfo.taskId, /* isLeft= */ true, inputMethod);
            return Unit.INSTANCE;
        });
        windowDecoration.setOnRightSnapClickListener(() -> {
            onSnapResize(taskInfo.taskId, /* isLeft= */ false, touchEventListener.mMotionEvent);
            onSnapResize(taskInfo.taskId, /* isLeft= */ false, inputMethod);
            return Unit.INSTANCE;
        });
        windowDecoration.setOnToDesktopClickListener(desktopModeTransitionSource -> {
+6 −3
Original line number Diff line number Diff line
@@ -460,7 +460,9 @@ class DragResizeInputListener implements AutoCloseable {
                                || ctrlType == CTRL_TYPE_RIGHT || ctrlType == CTRL_TYPE_LEFT)
                                ? ResizeTrigger.EDGE : ResizeTrigger.CORNER;
                        mDesktopModeEventLogger.logTaskResizingStarted(mResizeTrigger,
                                e, mTaskInfo, /* displayController= */ null,
                                DesktopModeEventLogger.Companion.getInputMethodFromMotionEvent(e),
                                mTaskInfo, mDragStartTaskBounds.width(),
                                mDragStartTaskBounds.height(), /* displayController= */ null,
                                /* displayLayoutSize= */ mDisplayLayoutSizeSupplier.get());
                        // Increase the input sink region to cover the whole screen; this is to
                        // prevent input and focus from going to other tasks during a drag resize.
@@ -512,8 +514,9 @@ class DragResizeInputListener implements AutoCloseable {
                        }

                        mDesktopModeEventLogger.logTaskResizingEnded(mResizeTrigger,
                                mLastMotionEventOnDown, mTaskInfo, taskBounds.height(),
                                taskBounds.width(),
                                DesktopModeEventLogger.Companion.getInputMethodFromMotionEvent(
                                        mLastMotionEventOnDown), mTaskInfo, taskBounds.width(),
                                taskBounds.height(),
                                /* displayController= */ null,
                                /* displayLayoutSize= */ mDisplayLayoutSizeSupplier.get());
                    }
Loading