Separated v4l2_metadata into two pieces.

v4l2_metadata and metadata/metadata. The previous design did not work
as intended for testing (it incorrectly assumed that a constructor
would call an overridden method of a child class), plus this way
makes more sense.

BUG: 30140438
Change-Id: I1293535932fed6daed766682421b1215739e17dd
TEST: Unit tests pass
diff --git a/modules/camera/3_4/v4l2_metadata.cpp b/modules/camera/3_4/v4l2_metadata.cpp
index 54d2809..0745720 100644
--- a/modules/camera/3_4/v4l2_metadata.cpp
+++ b/modules/camera/3_4/v4l2_metadata.cpp
@@ -25,119 +25,11 @@
 V4L2Metadata::V4L2Metadata(V4L2Wrapper* device) : device_(device) {
   HAL_LOG_ENTER();
 
-  PopulateComponents();
+  // TODO(b/30140438): Add all metadata components used by V4L2Camera here.
+  // Currently these are all the fixed properties. Will add the other properties
+  // as more PartialMetadata subclasses get implemented.
 }
 
 V4L2Metadata::~V4L2Metadata() { HAL_LOG_ENTER(); }
 
-void V4L2Metadata::PopulateComponents() {
-  HAL_LOG_ENTER();
-
-  // TODO(arihc): Add all default components.
-}
-
-void V4L2Metadata::AddComponent(
-    std::unique_ptr<PartialMetadataInterface> component) {
-  HAL_LOG_ENTER();
-
-  components_.push_back(std::move(component));
-}
-
-int V4L2Metadata::FillStaticMetadata(camera_metadata_t** metadata) {
-  HAL_LOG_ENTER();
-
-  std::vector<int32_t> static_tags;
-  std::vector<int32_t> control_tags;
-  std::vector<int32_t> dynamic_tags;
-  int res = 0;
-
-  for (auto& component : components_) {
-    // Populate the fields.
-    res = component->PopulateStaticFields(metadata);
-    if (res) {
-      // Exit on error.
-      HAL_LOGE("Failed to get all static properties.");
-      return res;
-    }
-
-    // Note what tags the component adds.
-    const std::vector<int32_t>* tags = &component->StaticTags();
-    static_tags.insert(static_tags.end(), tags->begin(), tags->end());
-    tags = &component->ControlTags();
-    control_tags.insert(control_tags.end(), tags->begin(), tags->end());
-    tags = &component->DynamicTags();
-    dynamic_tags.insert(dynamic_tags.end(), tags->begin(), tags->end());
-  }
-
-  // Populate the meta fields.
-  android::CameraMetadata metadata_wrapper(*metadata);
-  static_tags.push_back(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS);
-  res = metadata_wrapper.update(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS,
-                                control_tags.data(), control_tags.size());
-  if (res != android::OK) {
-    HAL_LOGE("Failed to add request keys meta key.");
-    return -ENODEV;
-  }
-  static_tags.push_back(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS);
-  res = metadata_wrapper.update(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS,
-                                dynamic_tags.data(), dynamic_tags.size());
-  if (res != android::OK) {
-    HAL_LOGE("Failed to add result keys meta key.");
-    return -ENODEV;
-  }
-  static_tags.push_back(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS);
-  res = metadata_wrapper.update(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS,
-                                static_tags.data(), static_tags.size());
-  if (res != android::OK) {
-    HAL_LOGE("Failed to add characteristics keys meta key.");
-    return -ENODEV;
-  }
-
-  *metadata = metadata_wrapper.release();
-  return 0;
-}
-
-bool V4L2Metadata::IsValidRequest(const camera_metadata_t* metadata) {
-  HAL_LOG_ENTER();
-
-  for (auto& component : components_) {
-    // Check that all components support the values requested of them.
-    bool valid_request = component->SupportsRequestValues(metadata);
-    if (!valid_request) {
-      // Exit early if possible.
-      return false;
-    }
-  }
-
-  return true;
-}
-
-int V4L2Metadata::SetRequestSettings(const camera_metadata_t* metadata) {
-  HAL_LOG_ENTER();
-
-  for (auto& component : components_) {
-    int res = component->SetRequestValues(metadata);
-    if (res) {
-      // Exit early if possible.
-      HAL_LOGE("Failed to set all requested settings.");
-      return res;
-    }
-  }
-
-  return 0;
-}
-
-int V4L2Metadata::FillResultMetadata(camera_metadata_t** metadata) {
-  for (auto& component : components_) {
-    int res = component->PopulateDynamicFields(metadata);
-    if (res) {
-      // Exit early if possible.
-      HAL_LOGE("Failed to get all dynamic result fields.");
-      return res;
-    }
-  }
-
-  return 0;
-}
-
 }  // namespace v4l2_camera_hal