summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/accessibility/java/com/android/server/accessibility/MouseKeysInterceptor.java10
-rw-r--r--services/tests/servicestests/src/com/android/server/accessibility/MouseKeysInterceptorTest.kt11
2 files changed, 13 insertions, 8 deletions
diff --git a/services/accessibility/java/com/android/server/accessibility/MouseKeysInterceptor.java b/services/accessibility/java/com/android/server/accessibility/MouseKeysInterceptor.java
index 54368ca9c03e..4b97745b3b25 100644
--- a/services/accessibility/java/com/android/server/accessibility/MouseKeysInterceptor.java
+++ b/services/accessibility/java/com/android/server/accessibility/MouseKeysInterceptor.java
@@ -73,12 +73,16 @@ public class MouseKeysInterceptor extends BaseEventStreamTransformation
private static final int MESSAGE_MOVE_MOUSE_POINTER = 1;
private static final int MESSAGE_SCROLL_MOUSE_POINTER = 2;
- private static final float MOUSE_POINTER_MOVEMENT_STEP = 1.8f;
private static final int KEY_NOT_SET = -1;
/** Time interval after which mouse action will be repeated */
private static final int INTERVAL_MILLIS = 10;
+ @VisibleForTesting
+ public static final float MOUSE_POINTER_MOVEMENT_STEP = 1.8f;
+ @VisibleForTesting
+ public static final float MOUSE_SCROLL_STEP = 0.2f;
+
private final AccessibilityManagerService mAms;
private final Handler mHandler;
private final InputManager mInputManager;
@@ -281,8 +285,8 @@ public class MouseKeysInterceptor extends BaseEventStreamTransformation
MouseKeyEvent mouseKeyEvent = MouseKeyEvent.from(
keyCode, mActiveInputDeviceId, mDeviceKeyCodeMap);
float y = switch (mouseKeyEvent) {
- case UP_MOVE_OR_SCROLL -> 1.0f;
- case DOWN_MOVE_OR_SCROLL -> -1.0f;
+ case UP_MOVE_OR_SCROLL -> MOUSE_SCROLL_STEP;
+ case DOWN_MOVE_OR_SCROLL -> -MOUSE_SCROLL_STEP;
default -> 0.0f;
};
waitForVirtualMouseCreation();
diff --git a/services/tests/servicestests/src/com/android/server/accessibility/MouseKeysInterceptorTest.kt b/services/tests/servicestests/src/com/android/server/accessibility/MouseKeysInterceptorTest.kt
index 019ccf93fa11..c76392b30276 100644
--- a/services/tests/servicestests/src/com/android/server/accessibility/MouseKeysInterceptorTest.kt
+++ b/services/tests/servicestests/src/com/android/server/accessibility/MouseKeysInterceptorTest.kt
@@ -61,7 +61,6 @@ class MouseKeysInterceptorTest {
companion object {
const val DISPLAY_ID = 1
const val DEVICE_ID = 123
- const val MOUSE_POINTER_MOVEMENT_STEP = 1.8f
// This delay is required for key events to be sent and handled correctly.
// The handler only performs a move/scroll event if it receives the key event
// at INTERVAL_MILLIS (which happens in practice). Hence, we need this delay in the tests.
@@ -159,8 +158,8 @@ class MouseKeysInterceptorTest {
testLooper.dispatchAll()
// Verify the sendRelativeEvent method is called once and capture the arguments
- verifyRelativeEvents(arrayOf(-MOUSE_POINTER_MOVEMENT_STEP / sqrt(2.0f)),
- arrayOf(MOUSE_POINTER_MOVEMENT_STEP / sqrt(2.0f)))
+ verifyRelativeEvents(arrayOf(-MouseKeysInterceptor.MOUSE_POINTER_MOVEMENT_STEP / sqrt(2.0f)),
+ arrayOf(MouseKeysInterceptor.MOUSE_POINTER_MOVEMENT_STEP / sqrt(2.0f)))
}
@Test
@@ -232,7 +231,8 @@ class MouseKeysInterceptorTest {
testLooper.dispatchAll()
// Verify the sendScrollEvent method is called once and capture the arguments
- verifyScrollEvents(arrayOf<Float>(0f), arrayOf<Float>(1.0f))
+ verifyScrollEvents(arrayOf<Float>(0f),
+ arrayOf<Float>(MouseKeysInterceptor.MOUSE_SCROLL_STEP))
}
@Test
@@ -247,7 +247,8 @@ class MouseKeysInterceptorTest {
testLooper.dispatchAll()
// Verify the sendRelativeEvent method is called once and capture the arguments
- verifyRelativeEvents(arrayOf<Float>(0f), arrayOf<Float>(-MOUSE_POINTER_MOVEMENT_STEP))
+ verifyRelativeEvents(arrayOf<Float>(0f),
+ arrayOf<Float>(-MouseKeysInterceptor.MOUSE_POINTER_MOVEMENT_STEP))
}
private fun verifyRelativeEvents(expectedX: Array<Float>, expectedY: Array<Float>) {