Update input-monitors to accept unrotated coordinates

Inputflinger now internally always works in the orientation
the display grew-up in so the coordinates of gesture-monitors
no-longer rotate to match the display.

For now, this adds some shims to achieve previous expected
coordinates in launcher

This is behind a flag:
   adb shell setprop persist.debug.per_window_input_rotation 1

Bug: 179274888
Test: use touch interactions on rotated display
Change-Id: Iecd9d233f60b86e24070d7d9055af6b8f44f0b54
This commit is contained in:
[1;3C authored and Evan Rosky committed 2021-02-09 17:21:17 -08:00
1 parent e263a44567
commit 5c3d37b37d
2 files changed
+40

No files matched your search

@@ -38,10 +38,12 @@ import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.graphics.PointF;
import android.hardware.display.DisplayManager;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.Display;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.ViewConfiguration;
@@ -64,6 +66,7 @@ import com.android.quickstep.RecentsAnimationDeviceState;
import com.android.quickstep.RotationTouchHelper;
import com.android.quickstep.TaskAnimationManager;
import com.android.quickstep.TaskUtils;
import com.android.quickstep.TouchInteractionService;
import com.android.quickstep.util.ActiveGestureLog;
import com.android.quickstep.util.CachedEventDispatcher;
import com.android.quickstep.util.MotionPauseDetector;
@@ -113,6 +116,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
private final PointF mLastPos = new PointF();
private int mActivePointerId = INVALID_POINTER_ID;
private int mLastRotation = -1;
// Distance after which we start dragging the window.
private final float mTouchSlop;
@@ -130,6 +135,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
// Might be displacement in X or Y, depending on the direction we are swiping from the nav bar.
private float mStartDisplacement;
private final DisplayManager mDisplayManager;
private Handler mMainThreadHandler;
private Runnable mCancelRecentsAnimationRunnable = () -> {
ActivityManagerWrapper.getInstance().cancelRecentsAnimation(
@@ -172,6 +179,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
mPassedPilferInputSlop = mPassedWindowMoveSlop = continuingPreviousGesture;
mDisableHorizontalSwipe = !mPassedPilferInputSlop && disableHorizontalSwipe;
mRotationTouchHelper = mDeviceState.getRotationTouchHelper();
mDisplayManager = getSystemService(DisplayManager.class);
}
@Override
@@ -197,6 +205,17 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC
return;
}
if (TouchInteractionService.ENABLE_PER_WINDOW_INPUT_ROTATION) {
final Display display = mDisplayManager.getDisplay(mDeviceState.getDisplayId());
final int rotation = display.getRotation();
if (rotation != mLastRotation) {
// If rotation changes, reset tracking to avoid degenerate velocities.
mLastPos.set(ev.getX(), ev.getY());
mVelocityTracker.clear();
mLastRotation = rotation;
}
}
// Proxy events to recents view
if (mPassedWindowMoveSlop && mInteractionHandler != null
&& !mRecentsViewDispatcher.hasConsumer()) {