Merge "hwc2: Skip hotplug uevent handling if client is not connected"
diff --git a/sdm/libs/hwc2/hwc_session.cpp b/sdm/libs/hwc2/hwc_session.cpp
index 0095837..0956401 100644
--- a/sdm/libs/hwc2/hwc_session.cpp
+++ b/sdm/libs/hwc2/hwc_session.cpp
@@ -2238,7 +2238,11 @@
 }
 
 void HWCSession::UEventHandler(const char *uevent_data, int length) {
-  if (strcasestr(uevent_data, HWC_UEVENT_DRM_EXT_HOTPLUG)) {
+  // Drop hotplug uevents until SurfaceFlinger (the client) is connected. The equivalent of hotplug
+  // uevent handling will be done once when SurfaceFlinger connects, at RegisterCallback(). Since
+  // HandlePluggableDisplays() reads the latest connection states of all displays, no uevent is
+  // lost.
+  if (client_connected_ && strcasestr(uevent_data, HWC_UEVENT_DRM_EXT_HOTPLUG)) {
     // MST hotplug will not carry connection status/test pattern etc.
     // Pluggable display handler will check all connection status' and take action accordingly.
     const char *str_status = GetTokenValue(uevent_data, length, "status=");