[SurfaceFlinger] Plumb getPerFrameMetadataKeys and setLayerPerFrameMetadata.

This patch compresses supported metdata types into a bitmask and stores it in
DisplayDevice and refactors the code in Hwc2::Layer regarding HdrMetadata. When
DisplayDevice is created, the ability of accepting metadata will be queried
from hardware composer and stored in DisplayDevice. Hwc2::Layer will construct
HdrMetadata to PerFrameMetadata when setPerFrameHdrMetadata is called if the
incoming meta data is changed.

Previously, setLayerPerFrameMetadata was named as setLayerHdrMetadata, but
since we move the responsibility of constructing PerFrameMetadata from
ComposerHal to Hwc2::Layer, we change the name to setLayerPerFrameMetadata,
which is more generic and matches the HIDL interface.

BUG: 77831156
Test: Build and flash
Change-Id: I447956f4dcf42c90ceb3d29091cd5034ad91061a
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 0a3ac84..1bbf039 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -842,6 +842,25 @@
     return NO_ERROR;
 }
 
+int32_t HWComposer::getSupportedPerFrameMetadata(int32_t displayId) const {
+    if (!isValidDisplay(displayId)) {
+        ALOGE("getPerFrameMetadataKeys: Attempted to access invalid display %d",
+                displayId);
+        return 0;
+    }
+
+    int32_t supportedMetadata;
+    auto error = mDisplayData[displayId].hwcDisplay->getSupportedPerFrameMetadata(
+            &supportedMetadata);
+    if (error != HWC2::Error::None) {
+        ALOGE("getPerFrameMetadataKeys failed for display %d: %s (%d)", displayId,
+              to_string(error).c_str(), static_cast<int32_t>(error));
+        return 0;
+    }
+
+    return supportedMetadata;
+}
+
 std::vector<ui::RenderIntent> HWComposer::getRenderIntents(int32_t displayId,
         ui::ColorMode colorMode) const {
     if (!isValidDisplay(displayId)) {
@@ -853,7 +872,7 @@
     std::vector<ui::RenderIntent> renderIntents;
     auto error = mDisplayData[displayId].hwcDisplay->getRenderIntents(colorMode, &renderIntents);
     if (error != HWC2::Error::None) {
-        ALOGE("getColorModes failed for display %d: %s (%d)", displayId,
+        ALOGE("getRenderIntents failed for display %d: %s (%d)", displayId,
                 to_string(error).c_str(), static_cast<int32_t>(error));
         return std::vector<ui::RenderIntent>();
     }