Add metadata store to surfaces

This adds a key/value metadata storage mechanism to
surfaces that allows the windowmanager to pass information
to the surfaceflinger frontend.

This then moves the existing metadata (window type and
ownerUID) into this metadata structure.

Bug: 122925737
Test: Phone boots and surfaces fling. Some unittests
Change-Id: I72c574737b7f75be2311a341812b15d385f507ed
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index ab92973..6091d3f 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -96,6 +96,7 @@
 
     output.writeStrongBinder(cachedBuffer.token);
     output.writeInt32(cachedBuffer.bufferId);
+    output.writeParcelable(metadata);
 
     output.writeFloat(colorAlpha);
     output.writeUint32(static_cast<uint32_t>(colorDataspace));
@@ -172,6 +173,7 @@
 
     cachedBuffer.token = input.readStrongBinder();
     cachedBuffer.bufferId = input.readInt32();
+    input.readParcelable(&metadata);
 
     colorAlpha = input.readFloat();
     colorDataspace = static_cast<ui::Dataspace>(input.readUint32());
@@ -396,6 +398,10 @@
         what |= eColorDataspaceChanged;
         colorDataspace = other.colorDataspace;
     }
+    if (other.what & eMetadataChanged) {
+        what |= eMetadataChanged;
+        metadata.merge(other.metadata);
+    }
     if ((other.what & what) != other.what) {
         ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? "
               "other.what=0x%" PRIu64 " what=0x%" PRIu64,