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

Commit 04397eba authored by Graciela Wissen Putri's avatar Graciela Wissen Putri
Browse files

[8/n] Add drag resize listener to desktop app header

No-op change to add skeleton to log task resize start and end with
deskId identifier in DesktopModeWindowDecorViewModel instead of
DragResizeInputListener which shouldn't have any desktop dependencies.

Flag: EXEMPT refactor
Bug: 423560267
Test: m && atest WMShellUnitTests
Change-Id: I1b1a90015d90cf674dfcef8f8e28a001e2d8430a
parent 3922d5a4
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@ import com.android.wm.shell.EventLogTags
import com.android.wm.shell.common.DisplayController
import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE
import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource
import com.android.wm.shell.windowdecor.DragPositioningCallback.INPUT_METHOD_TYPE_MOUSE
import com.android.wm.shell.windowdecor.DragPositioningCallback.INPUT_METHOD_TYPE_STYLUS
import com.android.wm.shell.windowdecor.DragPositioningCallback.INPUT_METHOD_TYPE_TOUCH
import com.android.wm.shell.windowdecor.DragPositioningCallback.INPUT_METHOD_TYPE_TOUCHPAD
import java.security.SecureRandom
import java.util.Random
import java.util.concurrent.atomic.AtomicInteger
@@ -462,6 +466,20 @@ class DesktopModeEventLogger {
            }
        }

        /**
         * Returns corresponding [InputMethod] for a given input method type defined in
         * [com.android.wm.shell.windowdecor.DragPositioningCallback.InputMethodType].
         */
        @JvmStatic
        fun getInputMethodType(inputMethodType: Int): InputMethod =
            when (inputMethodType) {
                INPUT_METHOD_TYPE_STYLUS -> InputMethod.STYLUS
                INPUT_METHOD_TYPE_MOUSE -> InputMethod.MOUSE
                INPUT_METHOD_TYPE_TOUCHPAD -> InputMethod.TOUCHPAD
                INPUT_METHOD_TYPE_TOUCH -> InputMethod.TOUCH
                else -> InputMethod.UNKNOWN_INPUT_METHOD
            }

        /**
         * Returns corresponding desktop mode enter [EnterReason] for a
         * [DesktopModeTransitionSource].
+4 −1
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import static android.provider.Settings.Global.DEVELOPMENT_FORCE_DESKTOP_MODE_ON
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.window.DesktopExperienceFlags.ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS;

import static com.android.wm.shell.windowdecor.DragPositioningCallbackUtility.getInputMethodFromMotionEvent;

import android.annotation.NonNull;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.ContentResolver;
@@ -491,7 +493,8 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel, FocusT
                case MotionEvent.ACTION_DOWN: {
                    mDragPointerId = e.getPointerId(0);
                    mDragPositioningCallback.onDragPositioningStart(
                            0 /* ctrlType */, e.getDisplayId(), e.getRawX(0), e.getRawY(0));
                            0 /* ctrlType */, e.getDisplayId(), e.getRawX(0), e.getRawY(0),
                            getInputMethodFromMotionEvent(e));
                    mIsDragging = false;
                    return false;
                }
+2 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.view.MotionEvent.ACTION_UP;

import static com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.MinimizeReason;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_WINDOW_DECORATION;
import static com.android.wm.shell.windowdecor.DragPositioningCallbackUtility.getInputMethodFromMotionEvent;

import android.annotation.NonNull;
import android.app.ActivityManager;
@@ -516,7 +517,7 @@ public class DesktopModeTouchEventListener
                    mDragPointerId = e.getPointerId(0);
                    final Rect initialBounds = mDragPositioningCallback.onDragPositioningStart(
                            0 /* ctrlType */, e.getDisplayId(), e.getRawX(0),
                            e.getRawY(0));
                            e.getRawY(0), getInputMethodFromMotionEvent(e));
                    updateDragStatus(decoration, e);
                    mOnDragStartInitialBounds.set(initialBounds);
                    mCurrentBounds.set(initialBounds);
+29 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import static com.android.wm.shell.shared.multiinstance.ManageWindowsViewContain
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_UNDEFINED;
import static com.android.wm.shell.windowdecor.DragPositioningCallbackUtility.getInputMethodFromMotionEvent;

import android.annotation.NonNull;
import android.app.ActivityManager;
@@ -222,6 +223,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,

    private final ExclusionRegionListener mExclusionRegionListener =
            new ExclusionRegionListenerImpl();
    private final DragPositioningCallbackUtility.DragEventListener mDragEventListener =
            new DesktopModeDragEventListener();

    private final SparseArray<WindowDecorationWrapper> mWindowDecorByTaskId;
    private final Function<Integer, WindowDecorationWrapper> mWindowDecorationFinder =
@@ -1681,6 +1684,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                touchEventListener, touchEventListener, touchEventListener, touchEventListener);
        windowDecoration.setExclusionRegionListener(mExclusionRegionListener);
        windowDecoration.setDragPositioningCallback(taskPositioner);
        windowDecoration.addDragResizeListener(mDragEventListener);
        windowDecoration.relayout(taskInfo, startT, finishT,
                false /* applyStartTransactionOnDraw */, false /* shouldSetTaskPositionAndCrop */,
                mFocusTransitionObserver.hasGlobalFocus(taskInfo),
@@ -1844,6 +1848,31 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        }
    }

    private class DesktopModeDragEventListener implements
            DragPositioningCallbackUtility.DragEventListener {

        @Override
        public void onDragMove(int taskId) {
            // Do nothing.
        }

        @Override
        public void onDragResizeStarted(int taskId,
                @NonNull ResizeTrigger resizeTrigger,
                @NonNull InputMethod inputMethod,
                @NonNull Rect startTaskBounds) {
            // TODO: b/423560267 - Implement logging task resize started.
        }

        @Override
        public void onDragResizeEnded(int taskId,
                @NonNull ResizeTrigger resizeTrigger,
                @NonNull InputMethod inputMethod,
                @NonNull Rect endTaskBounds) {
            // TODO: b/423560267 - Implement logging task resize ended.
        }
    }

    class DesktopModeKeyguardChangeListener implements KeyguardChangeListener {
        @Override
        public void onKeyguardVisibilityChanged(boolean visible, boolean occluded,
+20 −1
Original line number Diff line number Diff line
@@ -36,6 +36,22 @@ public interface DragPositioningCallback {
    int CTRL_TYPE_RIGHT = 2;
    int CTRL_TYPE_TOP = 4;
    int CTRL_TYPE_BOTTOM = 8;

    /**
     * Indicates the input method type when resizing.
     */
    @IntDef(flag = true, value = {
            INPUT_METHOD_TYPE_UNKNOWN, INPUT_METHOD_TYPE_TOUCH, INPUT_METHOD_TYPE_STYLUS,
            INPUT_METHOD_TYPE_MOUSE, INPUT_METHOD_TYPE_TOUCHPAD
    })
    @interface InputMethodType {}

    int INPUT_METHOD_TYPE_UNKNOWN = 0;
    int INPUT_METHOD_TYPE_TOUCH = 1;
    int INPUT_METHOD_TYPE_STYLUS = 2;
    int INPUT_METHOD_TYPE_MOUSE = 3;
    int INPUT_METHOD_TYPE_TOUCHPAD = 4;

    /**
     * Called when a drag-resize or drag-move starts.
     *
@@ -44,9 +60,12 @@ public interface DragPositioningCallback {
     * @param displayId the ID of the display where the drag starts
     * @param x x coordinate in window decoration coordinate system where the drag starts
     * @param y y coordinate in window decoration coordinate system where the drag starts
     * @param inputMethodType {@link InputMethodType} indicating the type of tool used to make
     *                 contact such as a finger or stylus, if known.
     * @return the starting task bounds
     */
    Rect onDragPositioningStart(@CtrlType int ctrlType, int displayId, float x, float y);
    Rect onDragPositioningStart(@CtrlType int ctrlType, int displayId, float x, float y,
            @InputMethodType int inputMethodType);

    /**
     * Called when the pointer moves during a drag-resize or drag-move.
Loading