Fix the race condition that cause windows cache stale

AccessibilityCache clear the windows cache when receivng
windows_change events. If the windows change events is received right
during  we fetch the data from system_server, the data might be stale but
still put in the cache.

To fix it, we record the timestamp of the event which presents the valid
cahe timestamp. If the timestamp of fetching data is earlier than the
timestamp of the accessibility event, then we will discard the data.

Bug: 205836014
Test: atest CtsAccessibilityServiceTestCases
      atest AccessibilityCacheTest
Change-Id: I2f1c264dc7af1fbb5876143ba177f84836065d2b
3 files changed