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
3 files changed