Do not consume hover events not coming from cursor for a11y.

Fix: 283041221
Test: TaplTestsTransientTaskbar
Flag: ENABLE_CURSOR_HOVER_STATES
Change-Id: I95e9ded6873173ea001c82d6319716a2d48b3bad
This commit is contained in:
Pat Manning
2023-08-16 16:57:34 +01:00
parent a5f24d709e
commit c7087e8f9f
2 changed files with 15 additions and 5 deletions

View File

@@ -70,6 +70,7 @@ import android.os.Looper;
import android.os.SystemClock;
import android.util.Log;
import android.view.Choreographer;
import android.view.InputDevice;
import android.view.InputEvent;
import android.view.MotionEvent;
import android.view.SurfaceControl;
@@ -752,7 +753,7 @@ public class TouchInteractionService extends Service {
if (mGestureState.isTrackpadGesture() && (action == ACTION_POINTER_DOWN
|| action == ACTION_POINTER_UP)) {
// Skip ACTION_POINTER_DOWN and ACTION_POINTER_UP events from trackpad.
} else if (event.isHoverEvent()) {
} else if (isCursorHoverEvent(event)) {
mUncheckedConsumer.onHoverEvent(event);
} else {
mUncheckedConsumer.onMotionEvent(event);
@@ -764,6 +765,11 @@ public class TouchInteractionService extends Service {
traceToken.close();
}
// Talkback generates hover events on touch, which we do not want to consume.
private boolean isCursorHoverEvent(MotionEvent event) {
return event.isHoverEvent() && event.getSource() == InputDevice.SOURCE_MOUSE;
}
private InputConsumer tryCreateAssistantInputConsumer(
GestureState gestureState, MotionEvent motionEvent) {
return tryCreateAssistantInputConsumer(

View File

@@ -224,12 +224,14 @@ public final class LaunchedAppState extends Background {
int leftEdge = 10;
Point taskbarUnstashArea = new Point(leftEdge, mLauncher.getRealDisplaySize().y - 1);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_ENTER,
new Point(taskbarUnstashArea.x, taskbarUnstashArea.y), null);
new Point(taskbarUnstashArea.x, taskbarUnstashArea.y), null,
InputDevice.SOURCE_MOUSE);
mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_EXIT,
new Point(taskbarUnstashArea.x, taskbarUnstashArea.y), null);
new Point(taskbarUnstashArea.x, taskbarUnstashArea.y), null,
InputDevice.SOURCE_MOUSE);
return new Taskbar(mLauncher);
}
@@ -246,7 +248,8 @@ public final class LaunchedAppState extends Background {
Point stashedTaskbarHintArea = new Point(mLauncher.getRealDisplaySize().x / 2,
mLauncher.getRealDisplaySize().y - 1);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_ENTER,
new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), null);
new Point(stashedTaskbarHintArea.x, stashedTaskbarHintArea.y), null,
InputDevice.SOURCE_MOUSE);
mLauncher.getDevice().wait(mStashedTaskbarHintScaleCondition,
LauncherInstrumentation.WAIT_TIME_MS);
@@ -257,7 +260,8 @@ public final class LaunchedAppState extends Background {
Point taskbarUnstashArea = new Point(mLauncher.getRealDisplaySize().x / 2,
mLauncher.getRealDisplaySize().y - 1);
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_HOVER_EXIT,
new Point(taskbarUnstashArea.x, taskbarUnstashArea.y), null);
new Point(taskbarUnstashArea.x, taskbarUnstashArea.y), null,
InputDevice.SOURCE_MOUSE);
mLauncher.waitForSystemLauncherObject(TASKBAR_RES_ID);
return new Taskbar(mLauncher);