Don't clear timestamps when enabling HW vsync.

It should clear after the first HW Vsync timestamp comes in,
and when VSyncReactor period confirmed. Therefore, a prediction
when HW vsync is enabled but not yet confirmed is consistent with a
prediction when coming out of idle.

Bug: 272802278
Test: Flash, perfetto trace
Test: atest libsurfaceflinger_unittest
Change-Id: I619162d5583f33087de04c0e3b073a589ec4c2f7
diff --git a/services/surfaceflinger/Scheduler/VsyncSchedule.h b/services/surfaceflinger/Scheduler/VsyncSchedule.h
index 5eca29a..556ef80 100644
--- a/services/surfaceflinger/Scheduler/VsyncSchedule.h
+++ b/services/surfaceflinger/Scheduler/VsyncSchedule.h
@@ -146,6 +146,11 @@
     // device is off.
     HwVsyncState mPendingHwVsyncState GUARDED_BY(kMainThreadContext) = HwVsyncState::Disabled;
 
+    // Whether to reset the timestamps stored in the vsync model on the next hw vsync sample. This
+    // is to avoid clearing the model when hw vsync is enabled, in order to be consistent with the
+    // stale timestamps. Instead, clear the model on the first hw vsync callback.
+    bool mClearTimestampsOnNextSample = false;
+
     class PredictedVsyncTracer;
     using TracerPtr = std::unique_ptr<PredictedVsyncTracer>;