sdm: Avoid flush for virtual display when no app layer is present.

Flicker is observed when there is no app layer present. Flush
operation is triggered, but flush does not update output buffer.
Fix is to avoid flush when there is valid output buffer (wfd scenario).

CRs-Fixed: 970754

Change-Id: I1125e376eea47bd31237a206ce0b2688ad6796d2
diff --git a/sdm/libs/hwc/hwc_display.cpp b/sdm/libs/hwc/hwc_display.cpp
index def453b..1224cb9 100644
--- a/sdm/libs/hwc/hwc_display.cpp
+++ b/sdm/libs/hwc/hwc_display.cpp
@@ -602,10 +602,6 @@
   }
 
   size_t num_hw_layers = content_list->numHwLayers;
-  if (num_hw_layers <= 1) {
-    flush_ = true;
-    return 0;
-  }
 
   if (!skip_prepare_) {
     DisplayError error = display_intf_->Prepare(&layer_stack_);
diff --git a/sdm/libs/hwc/hwc_display_external.cpp b/sdm/libs/hwc/hwc_display_external.cpp
index 9b175d9..74a79bb 100644
--- a/sdm/libs/hwc/hwc_display_external.cpp
+++ b/sdm/libs/hwc/hwc_display_external.cpp
@@ -97,6 +97,11 @@
     return status;
   }
 
+  if (content_list->numHwLayers <= 1) {
+    flush_ = true;
+    return 0;
+  }
+
   status = PrepareLayerStack(content_list);
   if (status) {
     return status;
diff --git a/sdm/libs/hwc/hwc_display_primary.cpp b/sdm/libs/hwc/hwc_display_primary.cpp
old mode 100755
new mode 100644
index a9c7e67..efef736
--- a/sdm/libs/hwc/hwc_display_primary.cpp
+++ b/sdm/libs/hwc/hwc_display_primary.cpp
@@ -153,6 +153,11 @@
     handle_idle_timeout_ = false;
   }
 
+  if (content_list->numHwLayers <= 1) {
+    flush_ = true;
+    return 0;
+  }
+
   status = PrepareLayerStack(content_list);
   if (status) {
     return status;