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/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h
index cf6bc68..f532e50 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.h
@@ -91,6 +91,12 @@
         int32_t dpiX = -1;
         int32_t dpiY = -1;
         int32_t configGroup = -1;
+
+        friend std::ostream& operator<<(std::ostream& os, const HWCDisplayMode& mode) {
+            return os << "id=" << mode.hwcId << " res=" << mode.width << "x" << mode.height
+                      << " vsyncPeriod=" << mode.vsyncPeriod << " dpi=" << mode.dpiX << "x"
+                      << mode.dpiY << " group=" << mode.configGroup;
+        }
     };
 
     virtual ~HWComposer();