Snap for 10453938 from 1bd42f7834dc064e33b00500943d46caa0d5512b to mainline-adbd-release

Change-Id: I560b28bfc8a0f3e54c470117b82a3dde4a5ad54d
diff --git a/system/hwc3/DisplayFinder.cpp b/system/hwc3/DisplayFinder.cpp
index 1bbb56c..b3bc4f6 100644
--- a/system/hwc3/DisplayFinder.cpp
+++ b/system/hwc3/DisplayFinder.cpp
@@ -123,39 +123,54 @@
   return HWC3::Error::None;
 }
 
+void parseExternalDisplaysFromProperties(std::vector<int>& outPropIntParts) {
+
+  static constexpr const char* kExternalDisplayProp[] = {
+      "hwservicemanager.external.displays",
+      "ro.boot.qemu.external.displays",
+  };
+
+  for (auto propName: kExternalDisplayProp) {
+      const std::string propVal = ::android::base::GetProperty(propName, "");
+      if (propVal.empty()) {
+            DEBUG_LOG("%s: prop name is: %s, prop value is: empty", __FUNCTION__,
+              propName);
+          continue;
+      }
+      DEBUG_LOG("%s: prop name is: %s, prop value is: %s", __FUNCTION__,
+              propName, propVal.c_str());
+
+      const std::vector<std::string> propStringParts =
+          ::android::base::Split(propVal, ",");
+      if (propStringParts.size() % 5 != 0) {
+          ALOGE("%s: Invalid syntax for system prop %s which is %s", __FUNCTION__,
+                  propName, propVal.c_str());
+          continue;
+      }
+      std::vector<int> propIntParts;
+      for (const std::string& propStringPart : propStringParts) {
+          int propIntPart;
+          if (!::android::base::ParseInt(propStringPart, &propIntPart)) {
+              ALOGE("%s: Invalid syntax for system prop %s which is %s", __FUNCTION__,
+                      propName, propVal.c_str());
+              break;
+          }
+          propIntParts.push_back(propIntPart);
+      }
+      if (propIntParts.empty() || propIntParts.size() % 5 != 0) {
+          continue;
+      }
+      outPropIntParts.insert(outPropIntParts.end(), propIntParts.begin(), propIntParts.end());
+  }
+}
+
 HWC3::Error findGoldfishSecondaryDisplays(
     std::vector<DisplayMultiConfigs>* outDisplays) {
   DEBUG_LOG("%s", __FUNCTION__);
 
-  static constexpr const char kExternalDisplayProp[] =
-      "hwservicemanager.external.displays";
-
-  const auto propString =
-      ::android::base::GetProperty(kExternalDisplayProp, "");
-  DEBUG_LOG("%s: prop value is: %s", __FUNCTION__, propString.c_str());
-
-  if (propString.empty()) {
-    return HWC3::Error::None;
-  }
-
-  const std::vector<std::string> propStringParts =
-      ::android::base::Split(propString, ",");
-  if (propStringParts.size() % 5 != 0) {
-    ALOGE("%s: Invalid syntax for system prop %s which is %s", __FUNCTION__,
-          kExternalDisplayProp, propString.c_str());
-    return HWC3::Error::BadParameter;
-  }
 
   std::vector<int> propIntParts;
-  for (const std::string& propStringPart : propStringParts) {
-    int propIntPart;
-    if (!::android::base::ParseInt(propStringPart, &propIntPart)) {
-      ALOGE("%s: Invalid syntax for system prop %s which is %s", __FUNCTION__,
-            kExternalDisplayProp, propString.c_str());
-      return HWC3::Error::BadParameter;
-    }
-    propIntParts.push_back(propIntPart);
-  }
+  parseExternalDisplaysFromProperties(propIntParts);
 
   int64_t secondaryDisplayId = 1;
   while (!propIntParts.empty()) {
diff --git a/system/hwc3/DisplayFinder.h b/system/hwc3/DisplayFinder.h
index 963e4c1..f66eedf 100644
--- a/system/hwc3/DisplayFinder.h
+++ b/system/hwc3/DisplayFinder.h
@@ -33,6 +33,8 @@
   std::vector<DisplayConfig> configs;
 };
 
+void parseExternalDisplaysFromProperties(std::vector<int>& outPropIntParts);
+
 HWC3::Error findDisplays(const DrmClient* drm,
                          std::vector<DisplayMultiConfigs>* outDisplays);
 
diff --git a/system/hwc3/GuestFrameComposer.cpp b/system/hwc3/GuestFrameComposer.cpp
index 078cce4..b4eef6a 100644
--- a/system/hwc3/GuestFrameComposer.cpp
+++ b/system/hwc3/GuestFrameComposer.cpp
@@ -29,6 +29,7 @@
 #include <ui/GraphicBufferMapper.h>
 
 #include "Display.h"
+#include "DisplayFinder.h"
 #include "Drm.h"
 #include "Layer.h"
 
@@ -591,35 +592,8 @@
     std::vector<GuestFrameComposer::DisplayConfig>* configs) {
   DEBUG_LOG("%s", __FUNCTION__);
 
-  static constexpr const char kExternalDisplayProp[] =
-      "hwservicemanager.external.displays";
-
-  const auto propString =
-      ::android::base::GetProperty(kExternalDisplayProp, "");
-  DEBUG_LOG("%s: prop value is: %s", __FUNCTION__, propString.c_str());
-
-  if (propString.empty()) {
-    return HWC3::Error::None;
-  }
-
-  const std::vector<std::string> propStringParts =
-      ::android::base::Split(propString, ",");
-  if (propStringParts.size() % 5 != 0) {
-    ALOGE("%s: Invalid syntax for system prop %s which is %s", __FUNCTION__,
-          kExternalDisplayProp, propString.c_str());
-    return HWC3::Error::BadParameter;
-  }
-
   std::vector<int> propIntParts;
-  for (const std::string& propStringPart : propStringParts) {
-    int propIntPart;
-    if (!::android::base::ParseInt(propStringPart, &propIntPart)) {
-      ALOGE("%s: Invalid syntax for system prop %s which is %s", __FUNCTION__,
-            kExternalDisplayProp, propString.c_str());
-      return HWC3::Error::BadParameter;
-    }
-    propIntParts.push_back(propIntPart);
-  }
+  parseExternalDisplaysFromProperties(propIntParts);
 
   while (!propIntParts.empty()) {
     DisplayConfig display_config = {
diff --git a/system/hwc3/HostFrameComposer.cpp b/system/hwc3/HostFrameComposer.cpp
index 91590ee..044c081 100644
--- a/system/hwc3/HostFrameComposer.cpp
+++ b/system/hwc3/HostFrameComposer.cpp
@@ -591,6 +591,8 @@
 
           *outDisplayFence = std::move(flushCompleteFence);
         } else {
+          rcEnc->rcSetDisplayColorBuffer(rcEnc, displayInfo.hostDisplayId,
+                  hostCon->grallocHelper()->getHostHandle(displayClientTarget.getBuffer()));
           post(hostCon, rcEnc, displayClientTarget.getBuffer());
           *outDisplayFence = std::move(fence);
         }
@@ -766,6 +768,8 @@
           displayClientTargetFence);
       *outDisplayFence = std::move(flushFence);
     } else {
+          rcEnc->rcSetDisplayColorBuffer(rcEnc, displayInfo.hostDisplayId,
+                  hostCon->grallocHelper()->getHostHandle(displayClientTarget.getBuffer()));
       post(hostCon, rcEnc, displayClientTarget.getBuffer());
       *outDisplayFence = std::move(displayClientTargetFence);
     }