Postpone window_state_changed events until the window is added

ViewRootImpl sends window_state_changed event to notify
AccessibilityService that itself is visible on the screen. However,
the corresponding window is not available from accessibility framework
perspective because the window information is from SurfaceFlinger process
now, so the window is added only when it is really visible on the screen.

To ensure accessibilityService could get the node or the window when
receiving this event, we postpone this event until the corresponding
window is added. We also set a timeout to send those pending events.

Bug: 228442331
Bug: 226371995
Test: atest CtsAccessibilityServiceTestCases
      manual test: write a sample AccessibilityService to test the apis
      when receving window_state_changed events
Change-Id: I92cf2ddb9de90c050cf145f746a53f31d3a5df83
1 file changed