Fix TouchExplorerTest flakiness.

1) Fix the test behavior to wait 10 milliseconds before sending the up event.
The point is to make sure that the delays for hover enter and exit are not scheduled for the same moment.
Scheduling them for the exact same moment can cause them to fire out of order.
It also causes the test to more closely reflect real-world behavior.
2) Send accessibility events based on the internal state as needed in TouchExplorer#onAccessibilityEvent.
Since accessibility events trigger internal state changes, we determine whether we need to send them  based on the internal state and not by unrelated things like whether we have a pending runnable to send them.

Fix: 295575684
Test: atest FrameworksServicesTests:com.android.server.accessibility.gestures.TouchExplorerTest --rerun-until-failure 300

Change-Id: I008d69add4a59ada8718463970cb66b3f07118ec
diff --git a/services/accessibility/accessibility.aconfig b/services/accessibility/accessibility.aconfig
index 3709f47..0480c22 100644
--- a/services/accessibility/accessibility.aconfig
+++ b/services/accessibility/accessibility.aconfig
@@ -19,4 +19,11 @@
     namespace: "accessibility"
     description: "Whether to enable joystick controls for magnification"
     bug: "297211257"
+}
+
+flag {
+    name: "send_a11y_events_based_on_state"
+    namespace: "accessibility"
+    description: "Sends accessibility events in TouchExplorer#onAccessibilityEvent based on internal state to keep it consistent. This reduces test flakiness."
+bug: "295575684"
 }
\ No newline at end of file