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

Commit 0987f02f authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Modify logging to use input method from keyboard and derive input method

from motion event.

Fixes: 375356876
Test: atest DesktopModeEventLogger
Flag: com.android.window.flags.enable_resizing_metrics
Change-Id: I35476c60bd8e5c11d97321bd91e47504c77b0ca0
parent 9fb681ff
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ class DesktopModeEventLogger {
     */
    fun logTaskResizingStarted(
        resizeTrigger: ResizeTrigger,
        motionEvent: MotionEvent?,
        inputMethod: InputMethod,
        taskInfo: RunningTaskInfo,
        taskWidth: Int? = null,
        taskHeight: Int? = null,
@@ -207,7 +207,7 @@ class DesktopModeEventLogger {

        val taskSizeUpdate = createTaskSizeUpdate(
            resizeTrigger,
            motionEvent,
            inputMethod,
            taskInfo,
            taskWidth,
            taskHeight,
@@ -232,7 +232,7 @@ class DesktopModeEventLogger {
     */
    fun logTaskResizingEnded(
        resizeTrigger: ResizeTrigger,
        motionEvent: MotionEvent?,
        inputMethod: InputMethod,
        taskInfo: RunningTaskInfo,
        taskWidth: Int? = null,
        taskHeight: Int? = null,
@@ -252,7 +252,7 @@ class DesktopModeEventLogger {

        val taskSizeUpdate = createTaskSizeUpdate(
            resizeTrigger,
            motionEvent,
            inputMethod,
            taskInfo,
            taskWidth,
            taskHeight,
@@ -275,7 +275,7 @@ class DesktopModeEventLogger {

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

        return TaskSizeUpdate(
            resizeTrigger,
            getInputMethodFromMotionEvent(motionEvent),
            inputMethod,
            taskInfo.taskId,
            taskInfo.effectiveUid,
            height,
@@ -446,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
+10 −8
Original line number Diff line number Diff line
@@ -129,6 +129,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
@@ -795,7 +796,7 @@ class DesktopTasksController(
        val currentTaskBounds = taskInfo.configuration.windowConfiguration.bounds
        desktopModeEventLogger.logTaskResizingStarted(
            resizeTrigger,
            motionEvent,
            DesktopModeEventLogger.getInputMethodFromMotionEvent(motionEvent),
            taskInfo,
            currentTaskBounds.width(),
            currentTaskBounds.height(),
@@ -848,7 +849,8 @@ class DesktopTasksController(
        taskbarDesktopTaskListener?.onTaskbarCornerRoundingUpdate(doesAnyTaskRequireTaskbarRounding)
        val wct = WindowContainerTransaction().setBounds(taskInfo.token, destinationBounds)
        desktopModeEventLogger.logTaskResizingEnded(
            resizeTrigger, motionEvent, taskInfo, destinationBounds.width(),
            resizeTrigger, DesktopModeEventLogger.getInputMethodFromMotionEvent(motionEvent),
            taskInfo, destinationBounds.width(),
            destinationBounds.height(), displayController
        )
        toggleResizeDesktopTaskTransitionHandler.startTransition(wct)
@@ -970,12 +972,12 @@ class DesktopTasksController(
        currentDragBounds: Rect,
        position: SnapPosition,
        resizeTrigger: ResizeTrigger,
        motionEvent: MotionEvent?,
        inputMethod: InputMethod,
        desktopWindowDecoration: DesktopModeWindowDecoration,
    ) {
        desktopModeEventLogger.logTaskResizingStarted(
            resizeTrigger,
            motionEvent,
            inputMethod,
            taskInfo,
            currentDragBounds.width(),
            currentDragBounds.height(),
@@ -985,7 +987,7 @@ class DesktopTasksController(
        val destinationBounds = getSnapBounds(taskInfo, position)
        desktopModeEventLogger.logTaskResizingEnded(
            resizeTrigger,
            motionEvent,
            inputMethod,
            taskInfo,
            destinationBounds.width(),
            destinationBounds.height(),
@@ -1034,7 +1036,7 @@ class DesktopTasksController(
        taskInfo: RunningTaskInfo,
        position: SnapPosition,
        resizeTrigger: ResizeTrigger,
        motionEvent: MotionEvent? = null,
        inputMethod: InputMethod,
        desktopModeWindowDecoration: DesktopModeWindowDecoration,
    ) {
        if (!isSnapResizingAllowed(taskInfo)) {
@@ -1052,7 +1054,7 @@ class DesktopTasksController(
            taskInfo.configuration.windowConfiguration.bounds,
            position,
            resizeTrigger,
            motionEvent,
            inputMethod,
            desktopModeWindowDecoration
        )
    }
@@ -1103,7 +1105,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 -> {
+4 −2
Original line number Diff line number Diff line
@@ -460,7 +460,8 @@ class DragResizeInputListener implements AutoCloseable {
                                || ctrlType == CTRL_TYPE_RIGHT || ctrlType == CTRL_TYPE_LEFT)
                                ? ResizeTrigger.EDGE : ResizeTrigger.CORNER;
                        mDesktopModeEventLogger.logTaskResizingStarted(mResizeTrigger,
                                e, mTaskInfo, mDragStartTaskBounds.width(),
                                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
@@ -513,7 +514,8 @@ class DragResizeInputListener implements AutoCloseable {
                        }

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