[sf] Add support for generic layer metadata to HWComposer and HWC2

HWComposer construction is slightly modified to make it easier to test.
Data is retrieved about the device on the call SurfaceFlinger makes
right after creaton (was registerCallbacks, now called
setConfiguration). This now includes obtaining the supported layer
metadata information from the HAL implementation.

Since getting capabilities is now no longer done by just construction,
the existing tests were adjusted to not expect the call, especially as
none of them were testing any variance in capabilities.

A HWC2::Layer::setLayerGenericMetadata function is also added to set
the metadata.

Tests are explicitly added for both retrieving the supported metadata
and for setting layer generic metadata.

Bug: 139747351
Test: atest libsurfaceflinger_unittest
Change-Id: I3e95be932d94d4e9f200b870acea965744c68d2c
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.h b/services/surfaceflinger/DisplayHardware/HWC2.h
index e7cf5ff..5804903 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.h
+++ b/services/surfaceflinger/DisplayHardware/HWC2.h
@@ -374,6 +374,10 @@
 
     // Composer HAL 2.3
     [[clang::warn_unused_result]] virtual Error setColorTransform(const android::mat4& matrix) = 0;
+
+    // Composer HAL 2.4
+    [[clang::warn_unused_result]] virtual Error setLayerGenericMetadata(
+            const std::string& name, bool mandatory, const std::vector<uint8_t>& value) = 0;
 };
 
 namespace impl {
@@ -382,8 +386,7 @@
 
 class Layer : public HWC2::Layer {
 public:
-    Layer(android::Hwc2::Composer& composer,
-          const std::unordered_set<Capability>& capabilities,
+    Layer(android::Hwc2::Composer& composer, const std::unordered_set<Capability>& capabilities,
           hwc2_display_t displayId, hwc2_layer_t layerId);
     ~Layer() override;
 
@@ -412,6 +415,10 @@
     // Composer HAL 2.3
     Error setColorTransform(const android::mat4& matrix) override;
 
+    // Composer HAL 2.4
+    Error setLayerGenericMetadata(const std::string& name, bool mandatory,
+                                  const std::vector<uint8_t>& value) override;
+
 private:
     // These are references to data owned by HWC2::Device, which will outlive
     // this HWC2::Layer, so these references are guaranteed to be valid for