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

Commit f8135aa5 authored by Arthur Hung's avatar Arthur Hung
Browse files

Fix drag surface would be stuck (1/2)

- If a window is removing, and perform drag-drop at same time,
  transferTouchFocus would fail because the window can't be found in the
  inputflinger.

- If there is no touch down on the drag window, it should not allow to
  drag.

- If perform drag successful, and a touch up sent out at same time,
  the transferTouchFocus might fail because there is no touch state for
  the calling window.

This patch would add syncInputTransactions to ensure input windows
information has been propagated to native InputManager.
So transferTouchFocus can base on current input windows information
to check if it should allow the drag-drop.

Also use the same transaction to control drag surface to prevent wrong
order cause surface can't be dismissed.

Bug: 137819199
Test: atest WmTests:TaskPositioningControllerTests
Test: atest DragDropTest
Change-Id: I382bc1fb04e1f4469df2c512f9e0f2542bbd2390
Merged-In: I382bc1fb04e1f4469df2c512f9e0f2542bbd2390
(cherry picked from commit b62e500e)
parent 56daf760
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ class DragDropController {

                    final WindowState callingWin = mService.windowForClientLocked(
                            null, window, false);
                    if (callingWin == null) {
                    if (callingWin == null || callingWin.cantReceiveTouchInput()) {
                        Slog.w(TAG_WM, "Bad requesting window " + window);
                        return null;  // !!! TODO: throw here?
                    }
@@ -167,8 +167,7 @@ class DragDropController {
                    final SurfaceControl surfaceControl = mDragState.mSurfaceControl;
                    if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG_WM, ">>> OPEN TRANSACTION performDrag");

                    final SurfaceControl.Transaction transaction =
                            callingWin.getPendingTransaction();
                    final SurfaceControl.Transaction transaction = mDragState.mTransaction;
                    transaction.setAlpha(surfaceControl, mDragState.mOriginalAlpha);
                    transaction.setPosition(
                            surfaceControl, touchX - thumbCenterX, touchY - thumbCenterY);
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ class DragState {
    // A surface used to catch input events for the drag-and-drop operation.
    SurfaceControl mInputSurface;

    private final SurfaceControl.Transaction mTransaction;
    final SurfaceControl.Transaction mTransaction;

    private final Rect mTmpClipRect = new Rect();

+3 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import android.view.InputDevice;
import android.view.InputEvent;
import android.view.InputWindowHandle;
import android.view.MotionEvent;
import android.view.SurfaceControl;
import android.view.WindowManager;

import com.android.internal.annotations.VisibleForTesting;
@@ -307,7 +308,8 @@ class TaskPositioner implements IBinder.DeathRecipient {
        mDisplayContent.pauseRotationLocked();

        // Notify InputMonitor to take mDragWindowHandle.
        mDisplayContent.getInputMonitor().updateInputWindowsLw(true /*force*/);
        mDisplayContent.getInputMonitor().updateInputWindowsImmediately();
        new SurfaceControl.Transaction().syncInputWindows().apply();

        mSideMargin = dipToPixel(SIDE_MARGIN_DIP, mDisplayMetrics);
        mMinVisibleWidth = dipToPixel(MINIMUM_VISIBLE_WIDTH_IN_DP, mDisplayMetrics);