SF: Requery display modes if the active mode is not supported

Some TV devices send two hotplug events immediately one after another
during startup. Because we query the active display mode
and the supported modes in two separete calls to HWC it's possible
to get an active mode, which is not in the list of supported modes.

If this happens we requery the display modes up to 3 times. If the
problem still persists we throw a fatal error.

Bug: 175678215
Bug: 159590486
Test: check that device boots
Test: plug HDMI out and it
Change-Id: I94dbadac4eb75ed659ede6299df0c3459ed6c74e
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index d1eae1c..23f0842 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -906,7 +906,8 @@
     /*
      * Display management
      */
-    DisplayModes loadSupportedDisplayModes(PhysicalDisplayId) const REQUIRES(mStateLock);
+    void loadDisplayModes(PhysicalDisplayId displayId, DisplayModes& outModes,
+                          DisplayModePtr& outActiveMode) const REQUIRES(mStateLock);
     sp<DisplayDevice> setupNewDisplayDeviceInternal(
             const wp<IBinder>& displayToken,
             std::shared_ptr<compositionengine::Display> compositionDisplay,