def MergeDynamicPartitionInfoDicts(framework_dict, vendor_dict):
  """Merges dynamic partition info variables.
  Args:
    framework_dict: The dictionary of dynamic partition info variables from the
      partial framework target files.
    vendor_dict: The dictionary of dynamic partition info variables from the
      partial vendor target files.
  Returns:
    The merged dynamic partition info dictionary.
  """
  merged_dict = {}
  # Partition groups and group sizes are defined by the vendor dict because
  # these values may vary for each board that uses a shared system image.
  merged_dict["super_partition_groups"] = vendor_dict["super_partition_groups"]
  framework_dynamic_partition_list = framework_dict.get(
      "dynamic_partition_list", "")
  vendor_dynamic_partition_list = vendor_dict.get("dynamic_partition_list", "")
  merged_dict["dynamic_partition_list"] = ("%s %s" % (
      framework_dynamic_partition_list, vendor_dynamic_partition_list)).strip()
  for partition_group in merged_dict["super_partition_groups"].split(" "):
    # Set the partition group's size using the value from the vendor dict.
    key = "super_%s_group_size" % partition_group
    if key not in vendor_dict:
      raise ValueError("Vendor dict does not contain required key %s." % key)
    merged_dict[key] = vendor_dict[key]

    # Set the partition group's partition list using a concatenation of the
    # framework and vendor partition lists.
    key = "super_%s_partition_list" % partition_group
    merged_dict[key] = (
        "%s %s" %
        (framework_dict.get(key, ""), vendor_dict.get(key, ""))).strip()

  # Pick virtual ab related flags from vendor dict, if defined.
  if "virtual_ab" in vendor_dict.keys():
    merged_dict["virtual_ab"] = vendor_dict["virtual_ab"]
  if "virtual_ab_retrofit" in vendor_dict.keys():
    merged_dict["virtual_ab_retrofit"] = vendor_dict["virtual_ab_retrofit"]
  return merged_dict