Merge "Add unit_test option to module-info.json"
diff --git a/core/soong_config.mk b/core/soong_config.mk
index 5b2d1dc..48ab0eb 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -103,8 +103,6 @@
$(call add_json_list, CFIIncludePaths, $(CFI_INCLUDE_PATHS) $(PRODUCT_CFI_INCLUDE_PATHS))
$(call add_json_list, IntegerOverflowExcludePaths, $(INTEGER_OVERFLOW_EXCLUDE_PATHS) $(PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS))
-$(call add_json_bool, Experimental_mte, $(filter true,$(TARGET_EXPERIMENTAL_MTE)))
-
$(call add_json_bool, DisableScudo, $(filter true,$(PRODUCT_DISABLE_SCUDO)))
$(call add_json_bool, ClangTidy, $(filter 1 true,$(WITH_TIDY)))
diff --git a/core/sysprop.mk b/core/sysprop.mk
index bb19dc5..1540736 100644
--- a/core/sysprop.mk
+++ b/core/sysprop.mk
@@ -71,6 +71,7 @@
# $(3) and (4) are affected
# $(6): optional list of files to append at the end. The content of each file is emitted
# to the output
+# $(7): optional flag to skip common properties generation
define build-properties
ALL_DEFAULT_INSTALLED_MODULES += $(2)
@@ -96,7 +97,9 @@
$(hide) echo Building $$@
$(hide) mkdir -p $$(dir $$@)
$(hide) rm -f $$@ && touch $$@
+ifneq ($(strip $(7)), true)
$(hide) $$(call generate-common-build-props,$(call to-lower,$(strip $(1))),$$@)
+endif
$(hide) $(foreach file,$(strip $(3)),\
if [ -f "$(file)" ]; then\
echo "" >> $$@;\
@@ -309,6 +312,7 @@
$(_prop_files_),\
$(_prop_vars_),\
$(_blacklist_names_),\
+ $(empty),\
$(empty)))
# -----------------------------------------------------------------
@@ -346,6 +350,7 @@
$(_prop_files_),\
$(_prop_vars_),\
$(PRODUCT_VENDOR_PROPERTY_BLACKLIST),\
+ $(empty),\
$(empty)))
# -----------------------------------------------------------------
@@ -379,13 +384,28 @@
_footers_ :=
endif
+# Skip common /product properties generation if device released before R and
+# has no product partition. This is the first part of the check.
+ifeq ($(call math_lt,$(if $(PRODUCT_SHIPPING_API_LEVEL),$(PRODUCT_SHIPPING_API_LEVEL),30),30), true)
+ _skip_common_properties := true
+endif
+
+# The second part of the check - always generate common properties for the
+# devices with product partition regardless of shipping level.
+ifneq ($(BOARD_USES_PRODUCTIMAGE),)
+ _skip_common_properties :=
+endif
+
$(eval $(call build-properties,\
product,\
$(INSTALLED_PRODUCT_BUILD_PROP_TARGET),\
$(_prop_files_),\
$(_prop_vars_),\
$(empty),\
- $(_footers_)))
+ $(_footers_),\
+ $(_skip_common_properties)))
+
+_skip_common_properties :=
# ----------------------------------------------------------------
# odm/etc/build.prop
@@ -407,6 +427,7 @@
$(_prop_files),\
$(_prop_vars_),\
$(empty),\
+ $(empty),\
$(empty)))
# ----------------------------------------------------------------
@@ -420,6 +441,7 @@
$(empty),\
$(empty),\
$(empty),\
+ $(empty),\
$(empty)))
# ----------------------------------------------------------------
@@ -433,6 +455,7 @@
$(empty),\
$(empty),\
$(empty),\
+ $(empty),\
$(empty)))
# -----------------------------------------------------------------
@@ -453,6 +476,7 @@
$(_prop_files_),\
$(_prop_vars_),\
$(empty),\
+ $(empty),\
$(empty)))
# ----------------------------------------------------------------
@@ -467,4 +491,5 @@
$(empty),\
$(empty),\
$(empty),\
+ $(empty),\
$(empty)))
diff --git a/target/product/gsi/current.txt b/target/product/gsi/current.txt
index 2a6981b..4935a3d 100644
--- a/target/product/gsi/current.txt
+++ b/target/product/gsi/current.txt
@@ -75,6 +75,7 @@
VNDK-core: android.hardware.media@1.0.so
VNDK-core: android.hardware.memtrack-V1-ndk_platform.so
VNDK-core: android.hardware.memtrack@1.0.so
+VNDK-core: android.hardware.oemlock-V1-ndk_platform.so
VNDK-core: android.hardware.power-V1-ndk_platform.so
VNDK-core: android.hardware.rebootescrow-V1-ndk_platform.so
VNDK-core: android.hardware.security.keymint-V1-ndk_platform.so
diff --git a/tools/releasetools/apex_utils.py b/tools/releasetools/apex_utils.py
index dc6e3ca..6808f15 100644
--- a/tools/releasetools/apex_utils.py
+++ b/tools/releasetools/apex_utils.py
@@ -370,11 +370,12 @@
extra_signapk_args = OPTIONS.extra_signapk_args[:]
extra_signapk_args.extend(['-a', '4096'])
+ password = container_pw.get(container_key) if container_pw else None
common.SignFile(
aligned_apex,
signed_apex,
container_key,
- container_pw.get(container_key),
+ password,
codename_to_api_level_map=codename_to_api_level_map,
extra_signapk_args=extra_signapk_args)
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 0172add..19b132b 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -128,6 +128,12 @@
'odm_dlkm',
]
+# Partitions with a build.prop file
+PARTITIONS_WITH_BUILD_PROP = PARTITIONS_WITH_CARE_MAP + ['boot']
+
+# See sysprop.mk. If file is moved, add new search paths here; don't remove
+# existing search paths.
+RAMDISK_BUILD_PROP_REL_PATHS = ['system/etc/ramdisk/build.prop']
class ErrorCode(object):
"""Define error_codes for failures that happen during the actual
@@ -417,7 +423,7 @@
"3.2.2. Build Parameters.".format(fingerprint))
self._partition_fingerprints = {}
- for partition in PARTITIONS_WITH_CARE_MAP:
+ for partition in PARTITIONS_WITH_BUILD_PROP:
try:
fingerprint = self.CalculatePartitionFingerprint(partition)
check_fingerprint(fingerprint)
@@ -425,7 +431,7 @@
except ExternalError:
continue
if "system" in self._partition_fingerprints:
- # system_other is not included in PARTITIONS_WITH_CARE_MAP, but does
+ # system_other is not included in PARTITIONS_WITH_BUILD_PROP, but does
# need a fingerprint when creating the image.
self._partition_fingerprints[
"system_other"] = self._partition_fingerprints["system"]
@@ -473,12 +479,16 @@
def GetPartitionBuildProp(self, prop, partition):
"""Returns the inquired build property for the provided partition."""
+
+ # Boot image uses ro.[product.]bootimage instead of boot.
+ prop_partition = "bootimage" if partition == "boot" else partition
+
# If provided a partition for this property, only look within that
# partition's build.prop.
if prop in BuildInfo._RO_PRODUCT_RESOLVE_PROPS:
- prop = prop.replace("ro.product", "ro.product.{}".format(partition))
+ prop = prop.replace("ro.product", "ro.product.{}".format(prop_partition))
else:
- prop = prop.replace("ro.", "ro.{}.".format(partition))
+ prop = prop.replace("ro.", "ro.{}.".format(prop_partition))
prop_val = self._GetRawBuildProp(prop, partition)
if prop_val is not None:
@@ -649,6 +659,20 @@
raise KeyError(fn)
+def ExtractFromInputFile(input_file, fn):
+ """Extracts the contents of fn from input zipfile or directory into a file."""
+ if isinstance(input_file, zipfile.ZipFile):
+ tmp_file = MakeTempFile(os.path.basename(fn))
+ with open(tmp_file, 'w') as f:
+ f.write(input_file.read(fn))
+ return tmp_file
+ else:
+ file = os.path.join(input_file, *fn.split("/"))
+ if not os.path.exists(file):
+ raise KeyError(fn)
+ return file
+
+
def LoadInfoDict(input_file, repacking=False):
"""Loads the key/value pairs from the given input target_files.
@@ -753,7 +777,7 @@
# Tries to load the build props for all partitions with care_map, including
# system and vendor.
- for partition in PARTITIONS_WITH_CARE_MAP:
+ for partition in PARTITIONS_WITH_BUILD_PROP:
partition_prop = "{}.build.prop".format(partition)
d[partition_prop] = PartitionBuildProps.FromInputFile(
input_file, partition)
@@ -763,7 +787,7 @@
# hash / hashtree footers.
if d.get("avb_enable") == "true":
build_info = BuildInfo(d)
- for partition in PARTITIONS_WITH_CARE_MAP:
+ for partition in PARTITIONS_WITH_BUILD_PROP:
fingerprint = build_info.GetPartitionFingerprint(partition)
if fingerprint:
d["avb_{}_salt".format(partition)] = sha256(fingerprint.encode()).hexdigest()
@@ -839,6 +863,39 @@
@staticmethod
def FromInputFile(input_file, name, placeholder_values=None):
"""Loads the build.prop file and builds the attributes."""
+
+ if name == "boot":
+ data = PartitionBuildProps._ReadBootPropFile(input_file)
+ else:
+ data = PartitionBuildProps._ReadPartitionPropFile(input_file, name)
+
+ props = PartitionBuildProps(input_file, name, placeholder_values)
+ props._LoadBuildProp(data)
+ return props
+
+ @staticmethod
+ def _ReadBootPropFile(input_file):
+ """
+ Read build.prop for boot image from input_file.
+ Return empty string if not found.
+ """
+ try:
+ boot_img = ExtractFromInputFile(input_file, 'IMAGES/boot.img')
+ except KeyError:
+ logger.warning('Failed to read IMAGES/boot.img')
+ return ''
+ prop_file = GetBootImageBuildProp(boot_img)
+ if prop_file is None:
+ return ''
+ with open(prop_file) as f:
+ return f.read().decode()
+
+ @staticmethod
+ def _ReadPartitionPropFile(input_file, name):
+ """
+ Read build.prop for name from input_file.
+ Return empty string if not found.
+ """
data = ''
for prop_file in ['{}/etc/build.prop'.format(name.upper()),
'{}/build.prop'.format(name.upper())]:
@@ -847,10 +904,7 @@
break
except KeyError:
logger.warning('Failed to read %s', prop_file)
-
- props = PartitionBuildProps(input_file, name, placeholder_values)
- props._LoadBuildProp(data)
- return props
+ return data
@staticmethod
def FromBuildPropFile(name, build_prop_file):
@@ -3589,3 +3643,76 @@
comment('Move partition %s from default to %s' %
(p, u.tgt_group))
append('move %s %s' % (p, u.tgt_group))
+
+
+def GetBootImageBuildProp(boot_img):
+ """
+ Get build.prop from ramdisk within the boot image
+
+ Args:
+ boot_img: the boot image file. Ramdisk must be compressed with lz4 format.
+
+ Return:
+ An extracted file that stores properties in the boot image.
+ """
+ tmp_dir = MakeTempDir('boot_', suffix='.img')
+ try:
+ RunAndCheckOutput(['unpack_bootimg', '--boot_img', boot_img, '--out', tmp_dir])
+ ramdisk = os.path.join(tmp_dir, 'ramdisk')
+ if not os.path.isfile(ramdisk):
+ logger.warning('Unable to get boot image timestamp: no ramdisk in boot')
+ return None
+ uncompressed_ramdisk = os.path.join(tmp_dir, 'uncompressed_ramdisk')
+ RunAndCheckOutput(['lz4', '-d', ramdisk, uncompressed_ramdisk])
+
+ abs_uncompressed_ramdisk = os.path.abspath(uncompressed_ramdisk)
+ extracted_ramdisk = MakeTempDir('extracted_ramdisk')
+ # Use "toybox cpio" instead of "cpio" because the latter invokes cpio from
+ # the host environment.
+ RunAndCheckOutput(['toybox', 'cpio', '-F', abs_uncompressed_ramdisk, '-i'],
+ cwd=extracted_ramdisk)
+
+ prop_file = None
+ for search_path in RAMDISK_BUILD_PROP_REL_PATHS:
+ prop_file = os.path.join(extracted_ramdisk, search_path)
+ if os.path.isfile(prop_file):
+ break
+ logger.warning('Unable to get boot image timestamp: no %s in ramdisk', search_path)
+
+ return prop_file
+
+ except ExternalError as e:
+ logger.warning('Unable to get boot image build props: %s', e)
+ return None
+
+
+def GetBootImageTimestamp(boot_img):
+ """
+ Get timestamp from ramdisk within the boot image
+
+ Args:
+ boot_img: the boot image file. Ramdisk must be compressed with lz4 format.
+
+ Return:
+ An integer that corresponds to the timestamp of the boot image, or None
+ if file has unknown format. Raise exception if an unexpected error has
+ occurred.
+ """
+ prop_file = GetBootImageBuildProp(boot_img)
+ if not prop_file:
+ return None
+
+ props = PartitionBuildProps.FromBuildPropFile('boot', prop_file)
+ if props is None:
+ return None
+
+ try:
+ timestamp = props.GetProp('ro.bootimage.build.date.utc')
+ if timestamp:
+ return int(timestamp)
+ logger.warning('Unable to get boot image timestamp: ro.bootimage.build.date.utc is undefined')
+ return None
+
+ except ExternalError as e:
+ logger.warning('Unable to get boot image timestamp: %s', e)
+ return None
diff --git a/tools/releasetools/ota_utils.py b/tools/releasetools/ota_utils.py
index cb0f6e6..6bbcc92 100644
--- a/tools/releasetools/ota_utils.py
+++ b/tools/releasetools/ota_utils.py
@@ -21,8 +21,7 @@
import ota_metadata_pb2
from common import (ZipDelete, ZipClose, OPTIONS, MakeTempFile,
ZipWriteStr, BuildInfo, LoadDictionaryFromFile,
- SignFile, PARTITIONS_WITH_CARE_MAP, PartitionBuildProps,
- MakeTempDir, RunAndCheckOutput, ExternalError)
+ SignFile, PARTITIONS_WITH_BUILD_PROP, PartitionBuildProps)
logger = logging.getLogger(__name__)
@@ -41,10 +40,6 @@
METADATA_PROTO_NAME = 'META-INF/com/android/metadata.pb'
UNZIP_PATTERN = ['IMAGES/*', 'META/*', 'OTA/*', 'RADIO/*']
-# See sysprop.mk. If file is moved, add new search paths here; don't remove
-# existing search paths.
-RAMDISK_BUILD_PROP_REL_PATHS = ['system/etc/ramdisk/build.prop']
-
def FinalizeMetadata(metadata, input_file, output_file, needed_property_files):
"""Finalizes the metadata and signs an A/B OTA package.
@@ -179,7 +174,7 @@
# delta_generator will error out on unused timestamps,
# so only generate timestamps for dynamic partitions
# used in OTA update.
- for partition in sorted(set(PARTITIONS_WITH_CARE_MAP) & ab_partitions):
+ for partition in sorted(set(PARTITIONS_WITH_BUILD_PROP) & ab_partitions):
partition_prop = build_info.info_dict.get(
'{}.build.prop'.format(partition))
# Skip if the partition is missing, or it doesn't have a build.prop
@@ -365,7 +360,7 @@
# Reload the info_dict as some build properties may change their values
# based on the value of ro.boot* properties.
info_dict = copy.deepcopy(default_build_info.info_dict)
- for partition in PARTITIONS_WITH_CARE_MAP:
+ for partition in PARTITIONS_WITH_BUILD_PROP:
partition_prop_key = "{}.build.prop".format(partition)
input_file = info_dict[partition_prop_key].input_file
if isinstance(input_file, zipfile.ZipFile):
@@ -567,55 +562,3 @@
SignFile(temp_zip_name, output_zip_name, OPTIONS.package_key, pw,
whole_file=True)
-
-
-def GetBootImageTimestamp(boot_img):
- """
- Get timestamp from ramdisk within the boot image
-
- Args:
- boot_img: the boot image file. Ramdisk must be compressed with lz4 format.
-
- Return:
- An integer that corresponds to the timestamp of the boot image, or None
- if file has unknown format. Raise exception if an unexpected error has
- occurred.
- """
-
- tmp_dir = MakeTempDir('boot_', suffix='.img')
- try:
- RunAndCheckOutput(['unpack_bootimg', '--boot_img', boot_img, '--out', tmp_dir])
- ramdisk = os.path.join(tmp_dir, 'ramdisk')
- if not os.path.isfile(ramdisk):
- logger.warning('Unable to get boot image timestamp: no ramdisk in boot')
- return None
- uncompressed_ramdisk = os.path.join(tmp_dir, 'uncompressed_ramdisk')
- RunAndCheckOutput(['lz4', '-d', ramdisk, uncompressed_ramdisk])
-
- abs_uncompressed_ramdisk = os.path.abspath(uncompressed_ramdisk)
- extracted_ramdisk = MakeTempDir('extracted_ramdisk')
- # Use "toybox cpio" instead of "cpio" because the latter invokes cpio from
- # the host environment.
- RunAndCheckOutput(['toybox', 'cpio', '-F', abs_uncompressed_ramdisk, '-i'],
- cwd=extracted_ramdisk)
-
- prop_file = None
- for search_path in RAMDISK_BUILD_PROP_REL_PATHS:
- prop_file = os.path.join(extracted_ramdisk, search_path)
- if os.path.isfile(prop_file):
- break
- logger.warning('Unable to get boot image timestamp: no %s in ramdisk', search_path)
-
- if not prop_file:
- return None
-
- props = PartitionBuildProps.FromBuildPropFile('boot', prop_file)
- timestamp = props.GetProp('ro.bootimage.build.date.utc')
- if timestamp:
- return int(timestamp)
- logger.warning('Unable to get boot image timestamp: ro.bootimage.build.date.utc is undefined')
- return None
-
- except ExternalError as e:
- logger.warning('Unable to get boot image timestamp: %s', e)
- return None
diff --git a/tools/zipalign/ZipFile.cpp b/tools/zipalign/ZipFile.cpp
index 9938a06..1e3c413 100644
--- a/tools/zipalign/ZipFile.cpp
+++ b/tools/zipalign/ZipFile.cpp
@@ -245,7 +245,11 @@
/* read the last part of the file into the buffer */
if (fread(buf, 1, readAmount, mZipFp) != (size_t) readAmount) {
- ALOGD("short file? wanted %ld\n", readAmount);
+ if (feof(mZipFp)) {
+ ALOGW("fread %ld bytes failed, unexpected EOF", readAmount);
+ } else {
+ ALOGW("fread %ld bytes failed, %s", readAmount, strerror(errno));
+ }
result = UNKNOWN_ERROR;
goto bail;
}
@@ -327,7 +331,11 @@
{
uint8_t checkBuf[4];
if (fread(checkBuf, 1, 4, mZipFp) != 4) {
- ALOGD("EOCD check read failed\n");
+ if (feof(mZipFp)) {
+ ALOGW("fread EOCD failed, unexpected EOF");
+ } else {
+ ALOGW("fread EOCD failed, %s", strerror(errno));
+ }
result = INVALID_OPERATION;
goto bail;
}
@@ -785,15 +793,18 @@
while (1) {
count = fread(tmpBuf, 1, sizeof(tmpBuf), srcFp);
- if (ferror(srcFp) || ferror(dstFp))
- return errnoToStatus(errno);
+ if (ferror(srcFp) || ferror(dstFp)) {
+ status_t status = errnoToStatus(errno);
+ ALOGW("fread %zu bytes failed, %s", count, strerror(errno));
+ return status;
+ }
if (count == 0)
break;
*pCRC32 = crc32(*pCRC32, tmpBuf, count);
if (fwrite(tmpBuf, 1, count, dstFp) != count) {
- ALOGD("fwrite %d bytes failed\n", (int) count);
+ ALOGW("fwrite %zu bytes failed, %s", count, strerror(errno));
return UNKNOWN_ERROR;
}
}
@@ -813,7 +824,7 @@
if (size > 0) {
*pCRC32 = crc32(*pCRC32, (const unsigned char*)data, size);
if (fwrite(data, 1, size, dstFp) != size) {
- ALOGD("fwrite %d bytes failed\n", (int) size);
+ ALOGW("fwrite %zu bytes failed, %s", size, strerror(errno));
return UNKNOWN_ERROR;
}
}
@@ -847,7 +858,11 @@
count = fread(tmpBuf, 1, readSize, srcFp);
if (count != readSize) { // error or unexpected EOF
- ALOGD("fread %d bytes failed\n", (int) readSize);
+ if (feof(srcFp)) {
+ ALOGW("fread %zu bytes failed, unexpected EOF", readSize);
+ } else {
+ ALOGW("fread %zu bytes failed, %s", readSize, strerror(errno));
+ }
return UNKNOWN_ERROR;
}
@@ -855,7 +870,7 @@
*pCRC32 = crc32(*pCRC32, tmpBuf, count);
if (fwrite(tmpBuf, 1, count, dstFp) != count) {
- ALOGD("fwrite %d bytes failed\n", (int) count);
+ ALOGW("fwrite %zu bytes failed, %s", count, strerror(errno));
return UNKNOWN_ERROR;
}
@@ -915,8 +930,7 @@
goto bail;
}
if (getSize < kBufSize) {
- ALOGV("+++ got %d bytes, EOF reached\n",
- (int)getSize);
+ ALOGV("+++ got %zu bytes, EOF reached\n", getSize);
atEof = true;
}
@@ -926,9 +940,9 @@
delete[] inBuf;
}
- ALOGV("+++ writing %d bytes\n", (int)outSize);
+ ALOGV("+++ writing %zu bytes\n", outSize);
if (fwrite(outBuf, 1, outSize, dstFp) != outSize) {
- ALOGD("write %d failed in deflate\n", (int)outSize);
+ ALOGW("fwrite %zu bytes failed, %s", outSize, strerror(errno));
result = UNKNOWN_ERROR;
goto bail;
}
@@ -1134,24 +1148,31 @@
getSize = n;
if (fseek(fp, (long) src, SEEK_SET) != 0) {
- ALOGD("filemove src seek %ld failed\n", (long) src);
+ ALOGW("filemove src seek %ld failed, %s",
+ (long) src, strerror(errno));
return UNKNOWN_ERROR;
}
if (fread(readBuf, 1, getSize, fp) != getSize) {
- ALOGD("filemove read %ld off=%ld failed\n",
- (long) getSize, (long) src);
+ if (feof(fp)) {
+ ALOGW("fread %zu bytes off=%ld failed, unexpected EOF",
+ getSize, (long) src);
+ } else {
+ ALOGW("fread %zu bytes off=%ld failed, %s",
+ getSize, (long) src, strerror(errno));
+ }
return UNKNOWN_ERROR;
}
if (fseek(fp, (long) dst, SEEK_SET) != 0) {
- ALOGD("filemove dst seek %ld failed\n", (long) dst);
+ ALOGW("filemove dst seek %ld failed, %s",
+ (long) dst, strerror(errno));
return UNKNOWN_ERROR;
}
if (fwrite(readBuf, 1, getSize, fp) != getSize) {
- ALOGD("filemove write %ld off=%ld failed\n",
- (long) getSize, (long) dst);
+ ALOGW("filemove write %zu off=%ld failed, %s",
+ getSize, (long) dst, strerror(errno));
return UNKNOWN_ERROR;
}
@@ -1399,12 +1420,17 @@
ZipEntry::putLongLE(&buf[0x10], mCentralDirOffset);
ZipEntry::putShortLE(&buf[0x14], mCommentLen);
- if (fwrite(buf, 1, kEOCDLen, fp) != kEOCDLen)
+ if (fwrite(buf, 1, kEOCDLen, fp) != kEOCDLen) {
+ ALOGW("fwrite EOCD failed, %s", strerror(errno));
return UNKNOWN_ERROR;
+ }
if (mCommentLen > 0) {
assert(mComment != NULL);
- if (fwrite(mComment, mCommentLen, 1, fp) != mCommentLen)
+ if (fwrite(mComment, mCommentLen, 1, fp) != mCommentLen) {
+ ALOGW("fwrite %d bytes failed, %s",
+ (int) mCommentLen, strerror(errno));
return UNKNOWN_ERROR;
+ }
}
return OK;