Do not handle VSync event during resolution switch

When there is a resolution switch, SurfaceFlinger will handle as display
changes. If the VSync comes before the display is ready, the access to
the display will bring exception.

Solution: Add mutex lock between onComposerHalVsync() and
setActiveModeInternal().

Bug: 210378166
Test: run cts-on-gsi -m CtsDisplayTestCases
Change-Id: Ide53b0e5cff3b569593a2ed388d0ea66e0002e9d
Merged-In: Ide53b0e5cff3b569593a2ed388d0ea66e0002e9d
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 230810c..0f64882 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1949,7 +1949,10 @@
         // We received the present fence from the HWC, so we assume it successfully updated
         // the mode, hence we update SF.
         mSetActiveModePending = false;
-        ON_MAIN_THREAD(setActiveModeInternal());
+        {
+            Mutex::Autolock lock(mStateLock);
+            setActiveModeInternal();
+        }
     }
 
     if (framePending) {