Add setPointerIcon for PointerChoreographer (base)
To set pointer icon for mouse or stylus, we are going to use
setPointerIcon with more parameters which will be useful for
multi-device experience and security.
Test: Manual
Bug: 293587049
Change-Id: I17bb047b0bfbff6cf3a129e4fa742ec489420faf
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java
index 53ec201..8511a21 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DragResizeInputListener.java
@@ -24,6 +24,7 @@
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_CONSUMER;
+import static com.android.input.flags.Flags.enablePointerChoreographer;
import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_BOTTOM;
import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_LEFT;
import static com.android.wm.shell.windowdecor.DragPositioningCallback.CTRL_TYPE_RIGHT;
@@ -63,6 +64,7 @@
class DragResizeInputListener implements AutoCloseable {
private static final String TAG = "DragResizeInputListener";
private final IWindowSession mWindowSession = WindowManagerGlobal.getWindowSession();
+ private final Context mContext;
private final Handler mHandler;
private final Choreographer mChoreographer;
private final InputManager mInputManager;
@@ -110,6 +112,7 @@
Supplier<SurfaceControl.Transaction> surfaceControlTransactionSupplier,
DisplayController displayController) {
mInputManager = context.getSystemService(InputManager.class);
+ mContext = context;
mHandler = handler;
mChoreographer = choreographer;
mSurfaceControlTransactionSupplier = surfaceControlTransactionSupplier;
@@ -451,7 +454,9 @@
}
case MotionEvent.ACTION_HOVER_ENTER:
case MotionEvent.ACTION_HOVER_MOVE: {
- updateCursorType(e.getXCursorPosition(), e.getYCursorPosition());
+ updateCursorType(e.getDisplayId(), e.getDeviceId(),
+ e.getPointerId(/*pointerIndex=*/0), e.getXCursorPosition(),
+ e.getYCursorPosition());
result = true;
break;
}
@@ -579,7 +584,8 @@
return 0;
}
- private void updateCursorType(float x, float y) {
+ private void updateCursorType(int displayId, int deviceId, int pointerId, float x,
+ float y) {
@DragPositioningCallback.CtrlType int ctrlType = calculateResizeHandlesCtrlType(x, y);
int cursorType = PointerIcon.TYPE_DEFAULT;
@@ -611,9 +617,14 @@
// where views in the task can receive input events because we can't set touch regions
// of input sinks to have rounded corners.
if (mLastCursorType != cursorType || cursorType != PointerIcon.TYPE_DEFAULT) {
- mInputManager.setPointerIconType(cursorType);
+ if (enablePointerChoreographer()) {
+ mInputManager.setPointerIcon(PointerIcon.getSystemIcon(mContext, cursorType),
+ displayId, deviceId, pointerId, mInputChannel.getToken());
+ } else {
+ mInputManager.setPointerIconType(cursorType);
+ }
mLastCursorType = cursorType;
}
}
}
-}
\ No newline at end of file
+}
diff --git a/libs/input/PointerController.h b/libs/input/PointerController.h
index fa07c39..a8b9633 100644
--- a/libs/input/PointerController.h
+++ b/libs/input/PointerController.h
@@ -65,9 +65,9 @@
void setSpots(const PointerCoords* spotCoords, const uint32_t* spotIdToIndex,
BitSet32 spotIdBits, int32_t displayId) override;
void clearSpots() override;
+ void updatePointerIcon(PointerIconStyle iconId) override;
+ void setCustomPointerIcon(const SpriteIcon& icon) override;
- void updatePointerIcon(PointerIconStyle iconId);
- void setCustomPointerIcon(const SpriteIcon& icon);
virtual void setInactivityTimeout(InactivityTimeout inactivityTimeout);
void doInactivityTimeout();
void reloadPointerResources();
@@ -192,10 +192,10 @@
void setPresentation(Presentation) override {
LOG_ALWAYS_FATAL("Should not be called");
}
- void updatePointerIcon(PointerIconStyle) {
+ void updatePointerIcon(PointerIconStyle) override {
LOG_ALWAYS_FATAL("Should not be called");
}
- void setCustomPointerIcon(const SpriteIcon&) {
+ void setCustomPointerIcon(const SpriteIcon&) override {
LOG_ALWAYS_FATAL("Should not be called");
}
// fade() should not be called by inactivity timeout. Do nothing.