SurfaceFlinger: Check frameIsEarly earlier

If we allow the transaction to apply but then later delay
the buffer we may end up 'splitting a transaction' applying
part of it without applying an included buffer.

Bug: 179712630
Test: Existing tests pass
Change-Id: Ia54ba0f9b34a7b676af95418181c2e0f0b807b25
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 5364adf..fdefca7 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3361,6 +3361,10 @@
         if (!layer) {
             continue;
         }
+        if (layer->frameIsEarly(expectedPresentTime)) {
+            ATRACE_NAME("frameIsEarly()");
+            return false;
+        }
 
         if (!mScheduler->isVsyncValid(expectedPresentTime, layer->getOwnerUid())) {
             ATRACE_NAME("!isVsyncValidForUid");