Merge "Update input-monitors to accept unrotated coordinates" into sc-dev
This commit is contained in:
commit
be5fdb08a5
|
@ -37,18 +37,23 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Region;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.SystemClock;
|
||||
import android.os.SystemProperties;
|
||||
import android.util.Log;
|
||||
import android.view.Choreographer;
|
||||
import android.view.Display;
|
||||
import android.view.InputEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import androidx.annotation.BinderThread;
|
||||
|
@ -91,6 +96,7 @@ import com.android.systemui.plugins.PluginListener;
|
|||
import com.android.systemui.shared.recents.IOverviewProxy;
|
||||
import com.android.systemui.shared.recents.ISystemUiProxy;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
import com.android.systemui.shared.system.InputChannelCompat;
|
||||
import com.android.systemui.shared.system.InputChannelCompat.InputEventReceiver;
|
||||
import com.android.systemui.shared.system.InputConsumerController;
|
||||
import com.android.systemui.shared.system.InputMonitorCompat;
|
||||
|
@ -121,6 +127,9 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
|||
*/
|
||||
private static final int SYSTEM_ACTION_ID_ALL_APPS = 14;
|
||||
|
||||
public static final boolean ENABLE_PER_WINDOW_INPUT_ROTATION =
|
||||
SystemProperties.getBoolean("persist.debug.per_window_input_rotation", false);
|
||||
|
||||
private int mBackGestureNotificationCounter = -1;
|
||||
@Nullable
|
||||
private OverscrollPlugin mOverscrollPlugin;
|
||||
|
@ -248,6 +257,8 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
|||
private InputMonitorCompat mInputMonitorCompat;
|
||||
private InputEventReceiver mInputEventReceiver;
|
||||
|
||||
private DisplayManager mDisplayManager;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
@ -261,6 +272,7 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
|||
mDeviceState.addOneHandedModeChangedCallback(this::onOneHandedModeOverlayChanged);
|
||||
mDeviceState.runOnUserUnlocked(this::onUserUnlocked);
|
||||
ProtoTracer.INSTANCE.get(this).add(this);
|
||||
mDisplayManager = getSystemService(DisplayManager.class);
|
||||
|
||||
sConnected = true;
|
||||
}
|
||||
|
@ -426,6 +438,15 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
|||
return;
|
||||
}
|
||||
MotionEvent event = (MotionEvent) ev;
|
||||
if (ENABLE_PER_WINDOW_INPUT_ROTATION) {
|
||||
final Display display = mDisplayManager.getDisplay(mDeviceState.getDisplayId());
|
||||
int rotation = display.getRotation();
|
||||
Point sz = new Point();
|
||||
display.getRealSize(sz);
|
||||
if (rotation != Surface.ROTATION_0) {
|
||||
event.transform(InputChannelCompat.createRotationMatrix(rotation, sz.x, sz.y));
|
||||
}
|
||||
}
|
||||
|
||||
TestLogging.recordMotionEvent(
|
||||
TestProtocol.SEQUENCE_TIS, "TouchInteractionService.onInputEvent", event);
|
||||
|
|
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue