Fix transaction phase offsets

There are cases where we have multiple source of transactions
in one frame. In these cases, if a NORMAL gets submitted after an
EARLY, it will override the early one which will cause to use
the wrong phase offset for this frame.

In some cases an EARLY was then still scheduled before the frame
happened, so any kind of phase offset was observeable, which
looked like drifting.

Fix this by making sure an EARLY frame stays an EARLY frame.

Test: Open app. Ensure by looking really closely that vsync-sf is
happening at the supposed offset.
Bug: 75985430

Change-Id: I5dbf097d314767493b0f06b9eb6dd7c6b2f93919
diff --git a/services/surfaceflinger/VSyncModulator.h b/services/surfaceflinger/VSyncModulator.h
index 3126deb..3e5800e 100644
--- a/services/surfaceflinger/VSyncModulator.h
+++ b/services/surfaceflinger/VSyncModulator.h
@@ -55,11 +55,20 @@
     }
 
     void setTransactionStart(TransactionStart transactionStart) {
-        if (transactionStart == mTransactionStart) return;
+        // An early transaction stays an early transaction.
+        if (transactionStart == mTransactionStart || mTransactionStart == TransactionStart::EARLY) {
+            return;
+        }
         mTransactionStart = transactionStart;
         updatePhaseOffsets();
     }
 
+    void onTransactionHandled() {
+        if (mTransactionStart == TransactionStart::NORMAL) return;
+        mTransactionStart = TransactionStart::NORMAL;
+        updatePhaseOffsets();
+    }
+
     void setLastFrameUsedRenderEngine(bool re) {
         if (re == mLastFrameUsedRenderEngine) return;
         mLastFrameUsedRenderEngine = re;