hwc: Check for display connection before calling commit
In some transition scenarios for external display, it can be
disconnected just before the power mode setting's display commit
goes through. This will cause the display commit to fail, which is
harmless in this context, but it causes false-negatives in test
scripts.
This patch checks if the external display is still connected
(and thus implicitly if the fd is valid) before calling a commit.
Change-Id: I386f0a951344c2aba2f8944e712df40e203d10ae
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 3026d99..df7f160 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -530,7 +530,7 @@
}
break;
case HWC_DISPLAY_EXTERNAL:
- if(mode == HWC_POWER_MODE_OFF) {
+ if(mode == HWC_POWER_MODE_OFF and ctx->dpyAttr[dpy].connected) {
if(!Overlay::displayCommit(ctx->dpyAttr[dpy].fd)) {
ALOGE("%s: displayCommit failed for external", __FUNCTION__);
ret = -1;