Merge changes from topic "aconfig-gen-device-config-files"
* changes:
aconfig: add create-device-config-sysprops command
aconfig: add create-device-config-defaults command
aconfig: add test utilities
aconfig: cache.rs: remove unnecessary use statements
aconfig: give commands ownership of all arguments
diff --git a/core/Makefile b/core/Makefile
index 4e5787d..c3c5fb3 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -5401,6 +5401,9 @@
ifdef BOARD_PREBUILT_DTBOIMAGE
$(hide) echo "flash dtbo" >> $@
endif
+ifneq ($(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
+ $(hide) echo "flash vendor_kernel_boot" >> $@
+endif
ifeq ($(BOARD_USES_PVMFWIMAGE),true)
$(hide) echo "flash pvmfw" >> $@
endif
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 65e80fb..c61c653 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -1005,6 +1005,9 @@
ALL_MODULES.$(my_register_name).SHARED_LIBS := \
$(ALL_MODULES.$(my_register_name).SHARED_LIBS) $(LOCAL_SHARED_LIBRARIES)
+ALL_MODULES.$(my_register_name).STATIC_LIBS := \
+ $(ALL_MODULES.$(my_register_name).STATIC_LIBS) $(LOCAL_STATIC_LIBRARIES)
+
ALL_MODULES.$(my_register_name).SYSTEM_SHARED_LIBS := \
$(ALL_MODULES.$(my_register_name).SYSTEM_SHARED_LIBS) $(LOCAL_SYSTEM_SHARED_LIBRARIES)
@@ -1234,4 +1237,4 @@
###########################################################
## SBOM generation
###########################################################
-include $(BUILD_SBOM_GEN)
\ No newline at end of file
+include $(BUILD_SBOM_GEN)
diff --git a/core/board_config.mk b/core/board_config.mk
index c8ec5a9..f459d83 100644
--- a/core/board_config.mk
+++ b/core/board_config.mk
@@ -1000,6 +1000,14 @@
TARGET_FLATTEN_APEX := $(OVERRIDE_TARGET_FLATTEN_APEX)
endif
+# TODO(b/278826656) Remove the following message
+ifeq (true,$(TARGET_FLATTEN_APEX))
+ $(warning ********************************************************************************)
+ $(warning Flattened APEX will be deprecated soon. Please stop using flattened APEX and use)
+ $(warning "image" APEX instead.)
+ $(warning ********************************************************************************)
+endif
+
ifeq (,$(TARGET_BUILD_UNBUNDLED))
ifdef PRODUCT_EXTRA_VNDK_VERSIONS
$(foreach v,$(PRODUCT_EXTRA_VNDK_VERSIONS),$(call check_vndk_version,$(v)))
diff --git a/core/config.mk b/core/config.mk
index 0e2d271..c549296 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -43,6 +43,8 @@
CHANGES_URL := https://android.googlesource.com/platform/build/+/master/Changes.md
.KATI_READONLY := CHANGES_URL
$(KATI_deprecated_var TARGET_USES_64_BIT_BINDER,All devices use 64-bit binder by default now. Uses of TARGET_USES_64_BIT_BINDER should be removed.)
+$(KATI_deprecated_var PRODUCT_SEPOLICY_SPLIT,All devices are built with split sepolicy.)
+$(KATI_deprecated_var PRODUCT_SEPOLICY_SPLIT_OVERRIDE,All devices are built with split sepolicy.)
$(KATI_obsolete_var PATH,Do not use PATH directly. See $(CHANGES_URL)#PATH)
$(KATI_obsolete_var PYTHONPATH,Do not use PYTHONPATH directly. See $(CHANGES_URL)#PYTHONPATH)
$(KATI_obsolete_var OUT,Use OUT_DIR instead. See $(CHANGES_URL)#OUT)
@@ -549,7 +551,10 @@
DISABLE_PREOPT_BOOT_IMAGES :=
ifneq (,$(TARGET_BUILD_APPS)$(TARGET_BUILD_UNBUNDLED_IMAGE))
DISABLE_PREOPT := true
- DISABLE_PREOPT_BOOT_IMAGES := true
+ # VSDK builds perform dexpreopt during merge_target_files build step.
+ ifneq (true,$(BUILDING_WITH_VSDK))
+ DISABLE_PREOPT_BOOT_IMAGES := true
+ endif
endif
ifeq (true,$(TARGET_BUILD_UNBUNDLED))
ifneq (true,$(UNBUNDLED_BUILD_SDKS_FROM_SOURCE))
@@ -736,7 +741,6 @@
requirements := \
PRODUCT_TREBLE_LINKER_NAMESPACES \
- PRODUCT_SEPOLICY_SPLIT \
PRODUCT_ENFORCE_VINTF_MANIFEST \
PRODUCT_NOTICE_SPLIT
@@ -751,14 +755,6 @@
PRODUCT_FULL_TREBLE_OVERRIDE ?=
$(foreach req,$(requirements),$(eval $(req)_OVERRIDE ?=))
-ifneq ($(PRODUCT_SEPOLICY_SPLIT),true)
-# WARNING: DO NOT CHANGE: if you are downstream of AOSP, and you change this, without
-# letting upstream know it's important to you, we may do cleanup which breaks this
-# significantly. Please let us know if you are changing this.
-# TODO(b/257176017) - unsplit sepolicy is no longer supported
-PRODUCT_SEPOLICY_SPLIT := true
-endif
-
# TODO(b/114488870): disallow PRODUCT_FULL_TREBLE_OVERRIDE from being used.
.KATI_READONLY := \
PRODUCT_FULL_TREBLE_OVERRIDE \
@@ -1208,13 +1204,6 @@
TARGET_SDK_VERSIONS_WITHOUT_JAVA_18_SUPPORT := $(call numbers_less_than,24,$(TARGET_AVAILABLE_SDK_VERSIONS))
TARGET_SDK_VERSIONS_WITHOUT_JAVA_19_SUPPORT := $(call numbers_less_than,30,$(TARGET_AVAILABLE_SDK_VERSIONS))
-# Missing optional uses-libraries so that the platform doesn't create build rules that depend on
-# them.
-INTERNAL_PLATFORM_MISSING_USES_LIBRARIES := \
- com.google.android.ble \
- com.google.android.media.effects \
- com.google.android.wearable \
-
# This is the standard way to name a directory containing prebuilt target
# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
@@ -1271,6 +1260,9 @@
.KATI_READONLY := JAVAC_NINJA_POOL R8_NINJA_POOL D8_NINJA_POOL
+# Soong modules that are known to have broken optional_uses_libs dependencies.
+BUILD_WARNING_BAD_OPTIONAL_USES_LIBS_ALLOWLIST := LegacyCamera Gallery2
+
# These goals don't need to collect and include Android.mks/CleanSpec.mks
# in the source tree.
dont_bother_goals := out product-graph
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk
index 0e84f516..aa638d4 100644
--- a/core/config_sanitizers.mk
+++ b/core/config_sanitizers.mk
@@ -446,6 +446,13 @@
# If local module needs HWASAN, add compiler flags.
ifneq ($(filter hwaddress,$(my_sanitize)),)
my_cflags += $(HWADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
+
+ ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
+ ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
+ my_linker := /system/bin/linker_hwasan64
+ endif
+ endif
+
endif
# Use minimal diagnostics when integer overflow is enabled; never do it for HOST modules
diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk
index 2cf23a7..14fafa1 100644
--- a/core/dex_preopt_odex_install.mk
+++ b/core/dex_preopt_odex_install.mk
@@ -111,18 +111,19 @@
# Local module variables and functions used in dexpreopt and manifest_check.
################################################################################
-my_filtered_optional_uses_libraries := $(filter-out $(INTERNAL_PLATFORM_MISSING_USES_LIBRARIES), \
- $(LOCAL_OPTIONAL_USES_LIBRARIES))
-
# TODO(b/132357300): This may filter out too much, as PRODUCT_PACKAGES doesn't
# include all packages (the full list is unknown until reading all Android.mk
# makefiles). As a consequence, a library may be present but not included in
# dexpreopt, which will result in class loader context mismatch and a failure
-# to load dexpreopt code on device. We should fix this, either by deferring
-# dependency computation until the full list of product packages is known, or
-# by adding product-specific lists of missing libraries.
+# to load dexpreopt code on device.
+# However, we have to do filtering here. Otherwise, we may include extra
+# libraries that Soong and Make don't generate build rules for (e.g., a library
+# that exists in the source tree but not installable), and therefore get Ninja
+# errors.
+# We have deferred CLC computation to the Ninja phase, but the dependency
+# computation still needs to be done early. For now, this is the best we can do.
my_filtered_optional_uses_libraries := $(filter $(PRODUCT_PACKAGES), \
- $(my_filtered_optional_uses_libraries))
+ $(LOCAL_OPTIONAL_USES_LIBRARIES))
ifeq ($(LOCAL_MODULE_CLASS),APPS)
# compatibility libraries are added to class loader context of an app only if
diff --git a/core/instrumentation_test_config_template.xml b/core/instrumentation_test_config_template.xml
index 6ca964e..379126c 100644
--- a/core/instrumentation_test_config_template.xml
+++ b/core/instrumentation_test_config_template.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
+<!-- Copyright (C) 2023 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@
</target_preparer>
<test class="com.android.tradefed.testtype.{TEST_TYPE}" >
- <option name="package" value="{PACKAGE}" />
+ {EXTRA_TEST_RUNNER_CONFIGS}<option name="package" value="{PACKAGE}" />
<option name="runner" value="{RUNNER}" />
</test>
</configuration>
diff --git a/core/java_host_test_config_template.xml b/core/java_host_test_config_template.xml
index 26c1caf..e123dc7 100644
--- a/core/java_host_test_config_template.xml
+++ b/core/java_host_test_config_template.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2018 The Android Open Source Project
+<!-- Copyright (C) 2023 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -21,6 +21,6 @@
{EXTRA_CONFIGS}
<test class="com.android.tradefed.testtype.HostTest" >
- <option name="jar" value="{MODULE}.jar" />
+ {EXTRA_TEST_RUNNER_CONFIGS}<option name="jar" value="{MODULE}.jar" />
</test>
</configuration>
diff --git a/core/main.mk b/core/main.mk
index 2281b7a..40e690d 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -180,9 +180,7 @@
ADDITIONAL_SYSTEM_PROPERTIES += ro.treble.enabled=${PRODUCT_FULL_TREBLE}
$(KATI_obsolete_var PRODUCT_FULL_TREBLE,\
- Code should be written to work regardless of a device being Treble or \
- variables like PRODUCT_SEPOLICY_SPLIT should be used until that is \
- possible.)
+ Code should be written to work regardless of a device being Treble)
# Sets ro.actionable_compatible_property.enabled to know on runtime whether the
# allowed list of actionable compatible properties is enabled or not.
diff --git a/core/native_test_config_template.xml b/core/native_test_config_template.xml
index ea982cf..788157c 100644
--- a/core/native_test_config_template.xml
+++ b/core/native_test_config_template.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
+<!-- Copyright (C) 2023 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@
</target_preparer>
<test class="com.android.tradefed.testtype.GTest" >
- <option name="native-test-device-path" value="{TEST_INSTALL_BASE}" />
+ {EXTRA_TEST_RUNNER_CONFIGS}<option name="native-test-device-path" value="{TEST_INSTALL_BASE}" />
<option name="module-name" value="{MODULE}" />
</test>
</configuration>
diff --git a/core/soong_config.mk b/core/soong_config.mk
index 5a62a0e..6383393 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -251,8 +251,6 @@
$(call add_json_list, TargetFSConfigGen, $(TARGET_FS_CONFIG_GEN))
-$(call add_json_list, MissingUsesLibraries, $(INTERNAL_PLATFORM_MISSING_USES_LIBRARIES))
-
$(call add_json_map, VendorVars)
$(foreach namespace,$(sort $(SOONG_CONFIG_NAMESPACES)),\
$(call add_json_map, $(namespace))\
@@ -296,14 +294,14 @@
$(call add_json_bool, BuildBrokenVendorPropertyNamespace, $(filter true,$(BUILD_BROKEN_VENDOR_PROPERTY_NAMESPACE)))
$(call add_json_list, BuildBrokenInputDirModules, $(BUILD_BROKEN_INPUT_DIR_MODULES))
+$(call add_json_list, BuildWarningBadOptionalUsesLibsAllowlist, $(BUILD_WARNING_BAD_OPTIONAL_USES_LIBS_ALLOWLIST))
+
$(call add_json_bool, BuildDebugfsRestrictionsEnabled, $(filter true,$(PRODUCT_SET_DEBUGFS_RESTRICTIONS)))
$(call add_json_bool, RequiresInsecureExecmemForSwiftshader, $(filter true,$(PRODUCT_REQUIRES_INSECURE_EXECMEM_FOR_SWIFTSHADER)))
$(call add_json_bool, SelinuxIgnoreNeverallows, $(filter true,$(SELINUX_IGNORE_NEVERALLOWS)))
-$(call add_json_bool, SepolicySplit, $(filter true,$(PRODUCT_SEPOLICY_SPLIT)))
-
$(call add_json_list, SepolicyFreezeTestExtraDirs, $(SEPOLICY_FREEZE_TEST_EXTRA_DIRS))
$(call add_json_list, SepolicyFreezeTestExtraPrebuiltDirs, $(SEPOLICY_FREEZE_TEST_EXTRA_PREBUILT_DIRS))
diff --git a/core/tasks/module-info.mk b/core/tasks/module-info.mk
index e83d408..66ba8f1 100644
--- a/core/tasks/module-info.mk
+++ b/core/tasks/module-info.mk
@@ -18,6 +18,7 @@
'"test_config": [$(foreach w,$(strip $(ALL_MODULES.$(m).TEST_CONFIG) $(ALL_MODULES.$(m).EXTRA_TEST_CONFIGS)),"$(w)", )], ' \
'"dependencies": [$(foreach w,$(sort $(ALL_DEPS.$(m).ALL_DEPS)),"$(w)", )], ' \
'"shared_libs": [$(foreach w,$(sort $(ALL_MODULES.$(m).SHARED_LIBS)),"$(w)", )], ' \
+ '"static_libs": [$(foreach w,$(sort $(ALL_MODULES.$(m).STATIC_LIBS)),"$(w)", )], ' \
'"system_shared_libs": [$(foreach w,$(sort $(ALL_MODULES.$(m).SYSTEM_SHARED_LIBS)),"$(w)", )], ' \
'"srcs": [$(foreach w,$(sort $(ALL_MODULES.$(m).SRCS)),"$(w)", )], ' \
'"srcjars": [$(foreach w,$(sort $(ALL_MODULES.$(m).SRCJARS)),"$(w)", )], ' \
diff --git a/target/product/base_system.mk b/target/product/base_system.mk
index d65e5a4..a23fdd5 100644
--- a/target/product/base_system.mk
+++ b/target/product/base_system.mk
@@ -265,7 +265,6 @@
sm \
snapshotctl \
snapuserd \
- SoundPicker \
storaged \
surfaceflinger \
svc \
@@ -291,6 +290,13 @@
wifi.rc \
wm \
+# These packages are not used on Android TV
+ifneq ($(PRODUCT_IS_ATV),true)
+ PRODUCT_PACKAGES += \
+ SoundPicker \
+
+endif
+
# VINTF data for system image
PRODUCT_PACKAGES += \
system_manifest.xml \
diff --git a/target/product/default_art_config.mk b/target/product/default_art_config.mk
index 752b199..1e28c80 100644
--- a/target/product/default_art_config.mk
+++ b/target/product/default_art_config.mk
@@ -115,4 +115,4 @@
dalvik.vm.dex2oat-Xms=64m \
dalvik.vm.dex2oat-Xmx=512m \
-PRODUCT_ENABLE_UFFD_GC := false # TODO(jiakaiz): Change this to "default".
+PRODUCT_ENABLE_UFFD_GC := default
diff --git a/target/product/handheld_system.mk b/target/product/handheld_system.mk
index 41233b2..d965367 100644
--- a/target/product/handheld_system.mk
+++ b/target/product/handheld_system.mk
@@ -27,6 +27,7 @@
$(call inherit-product-if-exists, external/google-fonts/source-sans-pro/fonts.mk)
$(call inherit-product-if-exists, external/noto-fonts/fonts.mk)
$(call inherit-product-if-exists, external/roboto-fonts/fonts.mk)
+$(call inherit-product-if-exists, external/roboto-flex-fonts/fonts.mk)
$(call inherit-product-if-exists, external/hyphenation-patterns/patterns.mk)
$(call inherit-product-if-exists, frameworks/base/data/keyboards/keyboards.mk)
$(call inherit-product-if-exists, frameworks/webview/chromium/chromium.mk)
diff --git a/tools/aconfig/src/codegen_rust.rs b/tools/aconfig/src/codegen_rust.rs
index 6d60323..a48e464 100644
--- a/tools/aconfig/src/codegen_rust.rs
+++ b/tools/aconfig/src/codegen_rust.rs
@@ -93,7 +93,7 @@
#[inline(always)]
pub fn r#test_disabled_rw() -> bool {
- profcollect_libflags_rust::GetServerConfigurableFlag("test", "disabled_rw", "false") == "true"
+ flags_rust::GetServerConfigurableFlag("test", "disabled_rw", "false") == "true"
}
#[inline(always)]
@@ -103,7 +103,7 @@
#[inline(always)]
pub fn r#test_enabled_rw() -> bool {
- profcollect_libflags_rust::GetServerConfigurableFlag("test", "enabled_rw", "false") == "true"
+ flags_rust::GetServerConfigurableFlag("test", "enabled_rw", "false") == "true"
}
"#;
assert_eq!(expected.trim(), String::from_utf8(generated.contents).unwrap().trim());
diff --git a/tools/aconfig/templates/rust.template b/tools/aconfig/templates/rust.template
index 391c594..d7f4e8d 100644
--- a/tools/aconfig/templates/rust.template
+++ b/tools/aconfig/templates/rust.template
@@ -16,7 +16,7 @@
{{- if parsed_flag.is_read_write -}}
#[inline(always)]
pub fn r#{parsed_flag.fn_name}() -> bool \{
- profcollect_libflags_rust::GetServerConfigurableFlag("{namespace}", "{parsed_flag.name}", "false") == "true"
+ flags_rust::GetServerConfigurableFlag("{namespace}", "{parsed_flag.name}", "false") == "true"
}
{{ endif -}}
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index 8d660f8..465d222 100644
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -68,6 +68,7 @@
from concurrent.futures import ThreadPoolExecutor
from apex_utils import GetApexInfoFromTargetFiles
from common import ZipDelete, PARTITIONS_WITH_CARE_MAP, ExternalError, RunAndCheckOutput, IsSparseImage, MakeTempFile, ZipWrite
+from build_image import FIXED_FILE_TIMESTAMP
if sys.hexversion < 0x02070000:
print("Python 2.7 or newer is required.", file=sys.stderr)
@@ -81,12 +82,6 @@
OPTIONS.replace_updated_files_list = []
OPTIONS.is_signing = False
-# Use a fixed timestamp (01/01/2009 00:00:00 UTC) for files when packaging
-# images. (b/24377993, b/80600931)
-FIXED_FILE_TIMESTAMP = int((
- datetime.datetime(2009, 1, 1, 0, 0, 0, 0, None) -
- datetime.datetime.utcfromtimestamp(0)).total_seconds())
-
def ParseAvbFooter(img_path) -> avbtool.AvbFooter:
with open(img_path, 'rb') as fp:
@@ -594,15 +589,6 @@
if block_list:
image_props["block_list"] = block_list.name
- # Use repeatable ext4 FS UUID and hash_seed UUID (based on partition name and
- # build fingerprint). Also use the legacy build id, because the vbmeta digest
- # isn't available at this point.
- build_info = common.BuildInfo(info_dict, use_legacy_id=True)
- uuid_seed = what + "-" + build_info.GetPartitionFingerprint(what)
- image_props["uuid"] = str(uuid.uuid5(uuid.NAMESPACE_URL, uuid_seed))
- hash_seed = "hash_seed-" + uuid_seed
- image_props["hash_seed"] = str(uuid.uuid5(uuid.NAMESPACE_URL, hash_seed))
-
build_image.BuildImage(
os.path.join(input_dir, what.upper()), image_props, output_file.name)
@@ -1144,14 +1130,18 @@
item for item in vbmeta_partitions
if item not in vbmeta_vendor.split()]
vbmeta_partitions.append("vbmeta_vendor")
- custom_avb_partitions = OPTIONS.info_dict.get("avb_custom_vbmeta_images_partition_list", "").strip().split()
+ custom_avb_partitions = OPTIONS.info_dict.get(
+ "avb_custom_vbmeta_images_partition_list", "").strip().split()
if custom_avb_partitions:
for avb_part in custom_avb_partitions:
partition_name = "vbmeta_" + avb_part
- included_partitions = OPTIONS.info_dict.get("avb_vbmeta_{}".format(avb_part), "").strip().split()
- assert included_partitions, "Custom vbmeta partition {0} missing avb_vbmeta_{0} prop".format(avb_part)
+ included_partitions = OPTIONS.info_dict.get(
+ "avb_vbmeta_{}".format(avb_part), "").strip().split()
+ assert included_partitions, "Custom vbmeta partition {0} missing avb_vbmeta_{0} prop".format(
+ avb_part)
banner(partition_name)
- logger.info("VBMeta partition {} needs {}".format(partition_name, included_partitions))
+ logger.info("VBMeta partition {} needs {}".format(
+ partition_name, included_partitions))
partitions[partition_name] = AddVBMeta(
output_zip, partitions, partition_name, included_partitions)
vbmeta_partitions = [
@@ -1159,7 +1149,6 @@
if item not in included_partitions]
vbmeta_partitions.append(partition_name)
-
if OPTIONS.info_dict.get("avb_building_vbmeta_image") == "true":
banner("vbmeta")
AddVBMeta(output_zip, partitions, "vbmeta", vbmeta_partitions)
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 9064136..11bd784 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -23,24 +23,34 @@
"""
from __future__ import print_function
+import datetime
import glob
import logging
import os
import os.path
import re
+import shlex
import shutil
import sys
+import uuid
import common
import verity_utils
+
logger = logging.getLogger(__name__)
OPTIONS = common.OPTIONS
BLOCK_SIZE = common.BLOCK_SIZE
BYTES_IN_MB = 1024 * 1024
+# Use a fixed timestamp (01/01/2009 00:00:00 UTC) for files when packaging
+# images. (b/24377993, b/80600931)
+FIXED_FILE_TIMESTAMP = int((
+ datetime.datetime(2009, 1, 1, 0, 0, 0, 0, None) -
+ datetime.datetime.utcfromtimestamp(0)).total_seconds())
+
class BuildImageError(Exception):
"""An Exception raised during image building."""
@@ -487,6 +497,20 @@
raise
+def SetUUIDIfNotExist(image_props):
+
+ # Use repeatable ext4 FS UUID and hash_seed UUID (based on partition name and
+ # build fingerprint). Also use the legacy build id, because the vbmeta digest
+ # isn't available at this point.
+ what = image_props["mount_point"]
+ fingerprint = image_props.get("fingerprint", "")
+ uuid_seed = what + "-" + fingerprint
+ logger.info("Using fingerprint %s for partition %s", fingerprint, what)
+ image_props["uuid"] = str(uuid.uuid5(uuid.NAMESPACE_URL, uuid_seed))
+ hash_seed = "hash_seed-" + uuid_seed
+ image_props["hash_seed"] = str(uuid.uuid5(uuid.NAMESPACE_URL, hash_seed))
+
+
def BuildImage(in_dir, prop_dict, out_file, target_out=None):
"""Builds an image for the files under in_dir and writes it to out_file.
@@ -504,6 +528,7 @@
BuildImageError: On build image failures.
"""
in_dir, fs_config = SetUpInDirAndFsConfig(in_dir, prop_dict)
+ SetUUIDIfNotExist(prop_dict)
build_command = []
fs_type = prop_dict.get("fs_type", "")
@@ -635,6 +660,19 @@
verity_image_builder.Build(out_file)
+def TryParseFingerprint(glob_dict: dict):
+ for (key, val) in glob_dict.items():
+ if not key.endswith("_add_hashtree_footer_args") and not key.endswith("_add_hash_footer_args"):
+ continue
+ for arg in shlex.split(val):
+ m = re.match(r"^com\.android\.build\.\w+\.fingerprint:", arg)
+ if m is None:
+ continue
+ fingerprint = arg[len(m.group()):]
+ glob_dict["fingerprint"] = fingerprint
+ return
+
+
def ImagePropFromGlobalDict(glob_dict, mount_point):
"""Build an image property dictionary from the global dictionary.
@@ -643,7 +681,9 @@
mount_point: such as "system", "data" etc.
"""
d = {}
+ TryParseFingerprint(glob_dict)
+ d["timestamp"] = FIXED_FILE_TIMESTAMP
if "build.prop" in glob_dict:
timestamp = glob_dict["build.prop"].GetProp("ro.build.date.utc")
if timestamp:
@@ -680,6 +720,7 @@
"avb_enable",
"avb_avbtool",
"use_dynamic_partition_size",
+ "fingerprint",
)
for p in common_props:
copy_prop(p, p)
@@ -870,10 +911,9 @@
if item not in vbmeta_vendor.split()]
vbmeta_partitions.append("vbmeta_vendor")
-
partitions = {part: os.path.join(in_dir, part + ".img")
for part in vbmeta_partitions}
- partitions = {part:path for (part, path) in partitions.items() if os.path.exists(path)}
+ partitions = {part: path for (part, path) in partitions.items() if os.path.exists(path)}
common.BuildVBMeta(output_path, partitions, name, vbmeta_partitions)
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 7adc9fa..f92d67c 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -928,20 +928,7 @@
input_file, partition, ramdisk_format=ramdisk_format)
d["build.prop"] = d["system.build.prop"]
- # Set up the salt (based on fingerprint) that will be used when adding AVB
- # hash / hashtree footers.
if d.get("avb_enable") == "true":
- build_info = BuildInfo(d, use_legacy_id=True)
- for partition in PARTITIONS_WITH_BUILD_PROP:
- fingerprint = build_info.GetPartitionFingerprint(partition)
- if fingerprint:
- d["avb_{}_salt".format(partition)] = sha256(
- fingerprint.encode()).hexdigest()
-
- # Set up the salt for partitions without build.prop
- if build_info.fingerprint:
- d["avb_salt"] = sha256(build_info.fingerprint.encode()).hexdigest()
-
# Set the vbmeta digest if exists
try:
d["vbmeta_digest"] = read_helper("META/vbmeta_digest.txt").rstrip()
@@ -2137,20 +2124,19 @@
archvie. Non-matching patterns will be filtered out. If there's no match
after the filtering, no file will be unzipped.
"""
- cmd = ["unzip", "-o", "-q", filename, "-d", dirname]
- if patterns is not None:
+ with zipfile.ZipFile(filename, allowZip64=True, mode="r") as input_zip:
# Filter out non-matching patterns. unzip will complain otherwise.
- with zipfile.ZipFile(filename, allowZip64=True) as input_zip:
+ if patterns is not None:
names = input_zip.namelist()
- filtered = [
- pattern for pattern in patterns if fnmatch.filter(names, pattern)]
+ filtered = [name for name in names if any(
+ [fnmatch.fnmatch(name, p) for p in patterns])]
- # There isn't any matching files. Don't unzip anything.
- if not filtered:
- return
- cmd.extend(filtered)
-
- RunAndCheckOutput(cmd)
+ # There isn't any matching files. Don't unzip anything.
+ if not filtered:
+ return
+ input_zip.extractall(dirname, filtered)
+ else:
+ input_zip.extractall(dirname)
def UnzipTemp(filename, patterns=None):
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index 17f4cc5..fa53ad2 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -64,7 +64,7 @@
OPTIONS.retrofit_dap = None
OPTIONS.build_super = None
OPTIONS.sparse_userimages = None
-
+OPTIONS.use_fastboot_info = False
def LoadOptions(input_file):
"""Loads information from input_file to OPTIONS.
@@ -118,8 +118,9 @@
entries = [
'OTA/android-info.txt:android-info.txt',
- 'META/fastboot-info.txt:fastboot-info.txt',
]
+ if OPTIONS.use_fastboot_info:
+ entries.append('META/fastboot-info.txt:fastboot-info.txt')
with zipfile.ZipFile(input_file) as input_zip:
namelist = input_zip.namelist()
if 'PREBUILT_IMAGES/kernel_16k' in namelist:
diff --git a/tools/releasetools/ota_utils.py b/tools/releasetools/ota_utils.py
index fa9516e..63a863e 100644
--- a/tools/releasetools/ota_utils.py
+++ b/tools/releasetools/ota_utils.py
@@ -817,8 +817,8 @@
target_dir = ExtractTargetFiles(target_file)
cmd = ["delta_generator",
"--out_file", payload_file]
- with open(os.path.join(target_dir, "META", "ab_partitions.txt")) as fp:
- ab_partitions = fp.read().strip().split("\n")
+ with open(os.path.join(target_dir, "META", "ab_partitions.txt"), "r") as fp:
+ ab_partitions = fp.read().strip().splitlines()
cmd.extend(["--partition_names", ":".join(ab_partitions)])
cmd.extend(
["--new_partitions", GetPartitionImages(target_dir, ab_partitions, False)])
diff --git a/tools/releasetools/verity_utils.py b/tools/releasetools/verity_utils.py
index dddb7f4..7caeed4 100644
--- a/tools/releasetools/verity_utils.py
+++ b/tools/releasetools/verity_utils.py
@@ -31,6 +31,7 @@
import common
import sparse_img
from rangelib import RangeSet
+from hashlib import sha256
logger = logging.getLogger(__name__)
@@ -42,6 +43,7 @@
MAX_VBMETA_SIZE = 64 * 1024
MAX_FOOTER_SIZE = 4096
+
class BuildVerityImageError(Exception):
"""An Exception raised during verity image building."""
@@ -64,6 +66,11 @@
# partition_size could be None at this point, if using dynamic partitions.
if partition_size:
partition_size = int(partition_size)
+ # Set up the salt (based on fingerprint) that will be used when adding AVB
+ # hash / hashtree footers.
+ salt = prop_dict.get("avb_salt")
+ if salt is None:
+ salt = sha256(prop_dict.get("fingerprint", "").encode()).hexdigest()
# Verified Boot 2.0
if (prop_dict.get("avb_hash_enable") == "true" or
@@ -81,7 +88,7 @@
prop_dict["avb_avbtool"],
key_path,
algorithm,
- prop_dict.get("avb_salt"),
+ salt,
prop_dict["avb_add_hash_footer_args"])
# Image uses hashtree footer.
@@ -92,7 +99,7 @@
prop_dict["avb_avbtool"],
key_path,
algorithm,
- prop_dict.get("avb_salt"),
+ salt,
prop_dict["avb_add_hashtree_footer_args"])
return None
@@ -279,7 +286,7 @@
def CreateCustomImageBuilder(info_dict, partition_name, partition_size,
- key_path, algorithm, signing_args):
+ key_path, algorithm, signing_args):
builder = None
if info_dict.get("avb_enable") == "true":
builder = VerifiedBootVersion2VerityImageBuilder(