ResyncCallback in getLatestVsyncEventData.

Without resyncing, getLatestVsyncEventData might have wrong refresh rate
compared to hardware. `getLatestVsyncEventData` is an alternate way
to get vsync information, instead of posting callbacks to Choreographer.

Choreographer only needs to resync when the main thread is hogged by an
application for more than the threshold (currently 750ms), and simulated
vsync is no longer accurate.

Bug: 205721584
Test: atest libsurfaceflinger_unittest
Change-Id: I32c69b0368365c860fa0eb75f932e283e05a1302
diff --git a/services/surfaceflinger/Scheduler/EventThread.cpp b/services/surfaceflinger/Scheduler/EventThread.cpp
index 5ba8a1b..cbea77e 100644
--- a/services/surfaceflinger/Scheduler/EventThread.cpp
+++ b/services/surfaceflinger/Scheduler/EventThread.cpp
@@ -346,6 +346,12 @@
 
 VsyncEventData EventThread::getLatestVsyncEventData(
         const sp<EventThreadConnection>& connection) const {
+    // Resync so that the vsync is accurate with hardware. getLatestVsyncEventData is an alternate
+    // way to get vsync data (instead of posting callbacks to Choreographer).
+    if (connection->resyncCallback) {
+        connection->resyncCallback();
+    }
+
     VsyncEventData vsyncEventData;
     nsecs_t frameInterval = mGetVsyncPeriodFunction(connection->mOwnerUid);
     vsyncEventData.frameInterval = frameInterval;