Merge "Check super size for factory OTA at build time" into sc-dev

This commit is contained in:
Tianjie Xu 2021-06-02 21:53:36 +00:00 committed by Android (Google) Code Review
commit b195f48ce9
3 changed files with 30 additions and 6 deletions

View File

@ -3416,7 +3416,7 @@ endif # BOARD_PREBUILT_PVMFWIMAGE
# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor". # $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
# (1): list of partitions like "system", "vendor" or "system product system_ext". # (1): list of partitions like "system", "vendor" or "system product system_ext".
define images-for-partitions define images-for-partitions
$(strip $(foreach item,$(1),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET))) $(strip $(foreach item,$(1),$(if $(filter $(item),system_other),$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET))))
endef endef
# ----------------------------------------------------------------- # -----------------------------------------------------------------
@ -4145,13 +4145,20 @@ ifeq (,$(TARGET_BUILD_UNBUNDLED))
ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION)) ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
PARTITIONS_AND_OTHER_IN_SUPER := $(BOARD_SUPER_PARTITION_PARTITION_LIST)
# Add the system other image to the misc_info. Because factory ota may install system_other to the super partition.
ifdef BUILDING_SYSTEM_OTHER_IMAGE
PARTITIONS_AND_OTHER_IN_SUPER += system_other
endif # BUILDING_SYSTEM_OTHER_IMAGE
# $(1): misc_info.txt # $(1): misc_info.txt
# #(2): optional log file # #(2): optional log file
define check-all-partition-sizes-target define check-all-partition-sizes-target
mkdir -p $(dir $(1)) mkdir -p $(dir $(1))
rm -f $(1) rm -f $(1)
$(call dump-super-image-info, $(1)) $(call dump-super-image-info, $(1))
$(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \ $(foreach partition,$(PARTITIONS_AND_OTHER_IN_SUPER), \
echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);) echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
$(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1) $(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
endef endef
@ -4162,7 +4169,7 @@ $(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
$(check_all_partition_sizes_log): \ $(check_all_partition_sizes_log): \
$(CHECK_PARTITION_SIZES) \ $(CHECK_PARTITION_SIZES) \
$(call images-for-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST)) $(call images-for-partitions,$(PARTITIONS_AND_OTHER_IN_SUPER))
$(call check-all-partition-sizes-target, \ $(call check-all-partition-sizes-target, \
$(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \ $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
$@) $@)

View File

@ -223,9 +223,15 @@ class DynamicPartitionSizeChecker(object):
error_limit = Expression( error_limit = Expression(
"BOARD_SUPER_PARTITION_ERROR_LIMIT{}".format(size_limit_suffix), "BOARD_SUPER_PARTITION_ERROR_LIMIT{}".format(size_limit_suffix),
int(info_dict["super_partition_error_limit"]) // num_slots) int(info_dict["super_partition_error_limit"]) // num_slots)
self._CheckSumOfPartitionSizes( partitions_in_super = info_dict["dynamic_partition_list"].strip().split()
max_size, info_dict["dynamic_partition_list"].strip().split(), # In the vab case, factory OTA will allocate space on super to install
warn_limit, error_limit) # the system_other partition. So add system_other to the partition list.
if DeviceType.Get(self.info_dict) == DeviceType.VAB and (
"system_other_image" in info_dict or
"system_other_image_size" in info_dict):
partitions_in_super.append("system_other")
self._CheckSumOfPartitionSizes(max_size, partitions_in_super,
warn_limit, error_limit)
groups = info_dict.get("super_partition_groups", "").strip().split() groups = info_dict.get("super_partition_groups", "").strip().split()

View File

@ -33,6 +33,7 @@ class CheckPartitionSizesTest(test_utils.ReleaseToolsTestCase):
system_image_size=50 system_image_size=50
vendor_image_size=20 vendor_image_size=20
product_image_size=20 product_image_size=20
system_other_image_size=10
""".split("\n")) """.split("\n"))
def test_ab(self): def test_ab(self):
@ -126,3 +127,13 @@ class CheckPartitionSizesTest(test_utils.ReleaseToolsTestCase):
""".split("\n"))) """.split("\n")))
with self.assertRaises(RuntimeError): with self.assertRaises(RuntimeError):
CheckPartitionSizes(self.info_dict) CheckPartitionSizes(self.info_dict)
def test_vab_too_big_with_system_other(self):
self.info_dict.update(common.LoadDictionaryFromLines("""
virtual_ab=true
system_other_image_size=20
super_partition_size=101
super_super_device_size=101
""".split("\n")))
with self.assertRaises(RuntimeError):
CheckPartitionSizes(self.info_dict)