Merge "releasetools: Remove the reloading of target info dict."
diff --git a/Changes.md b/Changes.md
index 3e48bad..37bbad0 100644
--- a/Changes.md
+++ b/Changes.md
@@ -92,6 +92,11 @@
attribute to the root element `<manifest>`. If `PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE`
is 26 or 27, you can add `"target-level"="1"` to your device manifest instead.
+### Stop using USE_CLANG_PLATFORM_BUILD {#USE_CLANG_PLATFORM_BUILD}
+
+Clang is the default and only supported Android compiler, so there is no reason
+for this option to exist.
+
### Other envsetup.sh variables {#other_envsetup_variables}
* ANDROID_TOOLCHAIN
diff --git a/core/binary.mk b/core/binary.mk
index a4fd8e3..e3da7d2 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -354,11 +354,6 @@
my_clang := true
endif
endif
-# Add option to make gcc the default for device build
-else ifeq ($(USE_CLANG_PLATFORM_BUILD),false)
- ifeq ($(my_clang),)
- my_clang := false
- endif
else ifeq ($(my_clang),)
my_clang := true
endif
diff --git a/core/config.mk b/core/config.mk
index 1a6ac47..255c848 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -76,6 +76,7 @@
ANDROID_PRE_BUILD_PATHS \
,See $(CHANGES_URL)#other_envsetup_variables)
$(KATI_obsolete_var PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE,Set FCM Version in device manifest instead. See $(CHANGES_URL)#PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE)
+$(KATI_obsolete_var USE_CLANG_PLATFORM_BUILD,Clang is the only supported Android compiler. See $(CHANGES_URL)#USE_CLANG_PLATFORM_BUILD)
CHANGES_URL :=
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
index 79e72c1..20d43dc 100644
--- a/core/dex_preopt_libart.mk
+++ b/core/dex_preopt_libart.mk
@@ -93,8 +93,11 @@
# If we use a boot image profile.
my_use_profile_for_boot_image := $(PRODUCT_USE_PROFILE_FOR_BOOT_IMAGE)
ifeq (,$(my_use_profile_for_boot_image))
-# If not set, use the default.
-my_use_profile_for_boot_image := false
+# If not set, set the default to true if we are not a PDK build. PDK builds
+# can't build the profile since they don't have frameworks/base.
+ifneq (true,$(TARGET_BUILD_PDK))
+my_use_profile_for_boot_image := true
+endif
endif
ifeq (true,$(my_use_profile_for_boot_image))
diff --git a/core/envsetup.mk b/core/envsetup.mk
index 255c02b..05add60 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -657,13 +657,3 @@
ifeq ($(CALLED_FROM_SETUP),true)
PRINT_BUILD_CONFIG ?= true
endif
-
-ifeq ($(USE_CLANG_PLATFORM_BUILD),)
-USE_CLANG_PLATFORM_BUILD := true
-endif
-
-ifneq ($(USE_CLANG_PLATFORM_BUILD),true)
-ifneq ($(USE_CLANG_PLATFORM_BUILD),false)
-$(error USE_CLANG_PLATFORM_BUILD must be true or false)
-endif
-endif
diff --git a/core/soong_config.mk b/core/soong_config.mk
index bbad4c8..c7eefc9 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -110,7 +110,6 @@
$(call add_json_bool, Device_uses_hwc2, $(filter true,$(TARGET_USES_HWC2)))
$(call add_json_list, DeviceKernelHeaders, $(TARGET_PROJECT_SYSTEM_INCLUDES))
$(call add_json_bool, DevicePrefer32BitExecutables, $(filter true,$(TARGET_PREFER_32_BIT_EXECUTABLES)))
-$(call add_json_val, DeviceUsesClang, $(if $(USE_CLANG_PLATFORM_BUILD),$(USE_CLANG_PLATFORM_BUILD),false))
$(call add_json_str, DeviceVndkVersion, $(BOARD_VNDK_VERSION))
$(call add_json_str, Platform_vndk_version, $(PLATFORM_VNDK_VERSION))
$(call add_json_list, ExtraVndkVersions, $(PRODUCT_EXTRA_VNDK_VERSIONS))
diff --git a/target/board/Android.mk b/target/board/Android.mk
index ae6be92..3768ece 100644
--- a/target/board/Android.mk
+++ b/target/board/Android.mk
@@ -53,6 +53,13 @@
BUILT_VENDOR_MANIFEST := $(LOCAL_BUILT_MODULE)
endif
+# VNDK Version in device compatibility matrix and framework manifest
+ifeq ($(BOARD_VNDK_VERSION),current)
+VINTF_VNDK_VERSION := $(PLATFORM_VNDK_VERSION)
+else
+VINTF_VNDK_VERSION := $(BOARD_VNDK_VERSION)
+endif
+
# Device Compatibility Matrix
ifdef DEVICE_MATRIX_FILE
include $(CLEAR_VARS)
@@ -62,9 +69,11 @@
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)
GEN := $(local-generated-sources-dir)/compatibility_matrix.xml
+
+$(GEN): PRIVATE_VINTF_VNDK_VERSION := $(VINTF_VNDK_VERSION)
$(GEN): $(DEVICE_MATRIX_FILE) $(HOST_OUT_EXECUTABLES)/assemble_vintf
- # TODO(b/37342627): put BOARD_VNDK_VERSION & BOARD_VNDK_LIBRARIES into device matrix.
- $(HOST_OUT_EXECUTABLES)/assemble_vintf -i $< -o $@
+ REQUIRED_VNDK_VERSION=$(PRIVATE_VINTF_VNDK_VERSION) \
+ $(HOST_OUT_EXECUTABLES)/assemble_vintf -i $< -o $@
LOCAL_PREBUILT_MODULE_FILE := $(GEN)
include $(BUILD_PREBUILT)
@@ -89,9 +98,12 @@
endif
endif
+$(GEN): PRIVATE_VINTF_VNDK_VERSION := $(VINTF_VNDK_VERSION)
$(GEN): PRIVATE_FRAMEWORK_MANIFEST_INPUT_FILES := $(FRAMEWORK_MANIFEST_INPUT_FILES)
$(GEN): $(FRAMEWORK_MANIFEST_INPUT_FILES) $(HOST_OUT_EXECUTABLES)/assemble_vintf
- BOARD_SEPOLICY_VERS=$(BOARD_SEPOLICY_VERS) $(HOST_OUT_EXECUTABLES)/assemble_vintf \
+ BOARD_SEPOLICY_VERS=$(BOARD_SEPOLICY_VERS) \
+ PROVIDED_VNDK_VERSIONS="$(PRIVATE_VINTF_VNDK_VERSION) $(PRODUCT_EXTRA_VNDK_VERSIONS)" \
+ $(HOST_OUT_EXECUTABLES)/assemble_vintf \
-i $(call normalize-path-list,$(PRIVATE_FRAMEWORK_MANIFEST_INPUT_FILES)) \
-o $@ $(PRIVATE_FLAGS)
@@ -99,3 +111,4 @@
include $(BUILD_PREBUILT)
BUILT_SYSTEM_MANIFEST := $(LOCAL_BUILT_MODULE)
+VINTF_VNDK_VERSION :=
diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py
index 2b2e6d9..f366853 100644
--- a/tools/releasetools/blockimgdiff.py
+++ b/tools/releasetools/blockimgdiff.py
@@ -1467,7 +1467,7 @@
max_blocks_per_transfer = int(cache_size * split_threshold /
self.tgt.blocksize)
empty = RangeSet()
- for tgt_fn, tgt_ranges in self.tgt.file_map.items():
+ for tgt_fn, tgt_ranges in sorted(self.tgt.file_map.items()):
if tgt_fn == "__ZERO":
# the special "__ZERO" domain is all the blocks not contained
# in any file and that are filled with zeros. We have a
diff --git a/tools/releasetools/check_target_files_signatures.py b/tools/releasetools/check_target_files_signatures.py
index c4877e0..db63fd3 100755
--- a/tools/releasetools/check_target_files_signatures.py
+++ b/tools/releasetools/check_target_files_signatures.py
@@ -53,11 +53,13 @@
import common
-# Work around a bug in python's zipfile module that prevents opening
-# of zipfiles if any entry has an extra field of between 1 and 3 bytes
-# (which is common with zipaligned APKs). This overrides the
-# ZipInfo._decodeExtra() method (which contains the bug) with an empty
-# version (since we don't need to decode the extra field anyway).
+# Work around a bug in Python's zipfile module that prevents opening of zipfiles
+# if any entry has an extra field of between 1 and 3 bytes (which is common with
+# zipaligned APKs). This overrides the ZipInfo._decodeExtra() method (which
+# contains the bug) with an empty version (since we don't need to decode the
+# extra field anyway).
+# Issue #14315: https://bugs.python.org/issue14315, fixed in Python 2.7.8 and
+# Python 3.5.0 alpha 1.
class MyZipInfo(zipfile.ZipInfo):
def _decodeExtra(self):
pass
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index 7972306..88cb741 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -527,12 +527,7 @@
if target_info.oem_props and not OPTIONS.oem_no_mount:
target_info.WriteMountOemScript(script)
- metadata = {
- "post-build": target_info.fingerprint,
- "pre-device": target_info.device,
- "post-timestamp": target_info.GetBuildProp("ro.build.date.utc"),
- "ota-type" : "BLOCK",
- }
+ metadata = GetPackageMetadata(target_info)
device_specific = common.DeviceSpecificParams(
input_zip=input_zip,
@@ -711,6 +706,57 @@
metadata["post-timestamp"] = post_timestamp
+def GetPackageMetadata(target_info, source_info=None):
+ """Generates and returns the metadata dict.
+
+ It generates a dict() that contains the info to be written into an OTA
+ package (META-INF/com/android/metadata). It also handles the detection of
+ downgrade / timestamp override / data wipe based on the global options.
+
+ Args:
+ target_info: The BuildInfo instance that holds the target build info.
+ source_info: The BuildInfo instance that holds the source build info, or
+ None if generating full OTA.
+
+ Returns:
+ A dict to be written into package metadata entry.
+ """
+ assert isinstance(target_info, BuildInfo)
+ assert source_info is None or isinstance(source_info, BuildInfo)
+
+ metadata = {
+ 'post-build' : target_info.fingerprint,
+ 'post-build-incremental' : target_info.GetBuildProp(
+ 'ro.build.version.incremental'),
+ }
+
+ if target_info.is_ab:
+ metadata['ota-type'] = 'AB'
+ metadata['ota-required-cache'] = '0'
+ else:
+ metadata['ota-type'] = 'BLOCK'
+
+ if OPTIONS.wipe_user_data:
+ metadata['ota-wipe'] = 'yes'
+
+ is_incremental = source_info is not None
+ if is_incremental:
+ metadata['pre-build'] = source_info.fingerprint
+ metadata['pre-build-incremental'] = source_info.GetBuildProp(
+ 'ro.build.version.incremental')
+ metadata['pre-device'] = source_info.device
+ else:
+ metadata['pre-device'] = target_info.device
+
+ # Detect downgrades, or fill in the post-timestamp.
+ if is_incremental:
+ HandleDowngradeMetadata(metadata, target_info, source_info)
+ else:
+ metadata['post-timestamp'] = target_info.GetBuildProp('ro.build.date.utc')
+
+ return metadata
+
+
def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_zip):
target_info = BuildInfo(OPTIONS.target_info_dict, OPTIONS.oem_dicts)
source_info = BuildInfo(OPTIONS.source_info_dict, OPTIONS.oem_dicts)
@@ -728,12 +774,7 @@
if not OPTIONS.oem_no_mount:
source_info.WriteMountOemScript(script)
- metadata = {
- "pre-device": source_info.device,
- "ota-type": "BLOCK",
- }
-
- HandleDowngradeMetadata(metadata, target_info, source_info)
+ metadata = GetPackageMetadata(target_info, source_info)
device_specific = common.DeviceSpecificParams(
source_zip=source_zip,
@@ -745,13 +786,6 @@
metadata=metadata,
info_dict=source_info)
- metadata["pre-build"] = source_info.fingerprint
- metadata["post-build"] = target_info.fingerprint
- metadata["pre-build-incremental"] = source_info.GetBuildProp(
- "ro.build.version.incremental")
- metadata["post-build-incremental"] = target_info.GetBuildProp(
- "ro.build.version.incremental")
-
source_boot = common.GetBootableImage(
"/tmp/boot.img", "boot.img", OPTIONS.source_tmp, "BOOT", source_info)
target_boot = common.GetBootableImage(
@@ -1070,24 +1104,7 @@
source_info = None
# Metadata to comply with Android OTA package format.
- metadata = {
- "post-build" : target_info.fingerprint,
- "post-build-incremental" : target_info.GetBuildProp(
- "ro.build.version.incremental"),
- "ota-required-cache" : "0",
- "ota-type" : "AB",
- }
-
- if source_file is not None:
- metadata["pre-device"] = source_info.device
- metadata["pre-build"] = source_info.fingerprint
- metadata["pre-build-incremental"] = source_info.GetBuildProp(
- "ro.build.version.incremental")
-
- HandleDowngradeMetadata(metadata, target_info, source_info)
- else:
- metadata["pre-device"] = target_info.device
- metadata["post-timestamp"] = target_info.GetBuildProp("ro.build.date.utc")
+ metadata = GetPackageMetadata(target_info, source_info)
# 1. Generate payload.
payload_file = common.MakeTempFile(prefix="payload-", suffix=".bin")
diff --git a/tools/releasetools/test_ota_from_target_files.py b/tools/releasetools/test_ota_from_target_files.py
index 0948c61..5f6c5d0 100644
--- a/tools/releasetools/test_ota_from_target_files.py
+++ b/tools/releasetools/test_ota_from_target_files.py
@@ -19,7 +19,7 @@
import common
from ota_from_target_files import (
- _LoadOemDicts, BuildInfo, WriteFingerprintAssertion)
+ _LoadOemDicts, BuildInfo, GetPackageMetadata, WriteFingerprintAssertion)
class MockScriptWriter(object):
@@ -300,3 +300,179 @@
self.assertEqual('foo', oem_dict['xyz'])
self.assertEqual('bar', oem_dict['a.b.c'])
self.assertEqual('{}'.format(i), oem_dict['ro.build.index'])
+
+
+class OtaFromTargetFilesTest(unittest.TestCase):
+
+ TEST_TARGET_INFO_DICT = {
+ 'build.prop' : {
+ 'ro.product.device' : 'product-device',
+ 'ro.build.fingerprint' : 'build-fingerprint-target',
+ 'ro.build.version.incremental' : 'build-version-incremental-target',
+ 'ro.build.date.utc' : '1500000000',
+ },
+ }
+
+ TEST_SOURCE_INFO_DICT = {
+ 'build.prop' : {
+ 'ro.product.device' : 'product-device',
+ 'ro.build.fingerprint' : 'build-fingerprint-source',
+ 'ro.build.version.incremental' : 'build-version-incremental-source',
+ 'ro.build.date.utc' : '1400000000',
+ },
+ }
+
+ def setUp(self):
+ # Reset the global options as in ota_from_target_files.py.
+ common.OPTIONS.incremental_source = None
+ common.OPTIONS.downgrade = False
+ common.OPTIONS.timestamp = False
+ common.OPTIONS.wipe_user_data = False
+
+ def test_GetPackageMetadata_abOta_full(self):
+ target_info_dict = copy.deepcopy(self.TEST_TARGET_INFO_DICT)
+ target_info_dict['ab_update'] = 'true'
+ target_info = BuildInfo(target_info_dict, None)
+ metadata = GetPackageMetadata(target_info)
+ self.assertDictEqual(
+ {
+ 'ota-type' : 'AB',
+ 'ota-required-cache' : '0',
+ 'post-build' : 'build-fingerprint-target',
+ 'post-build-incremental' : 'build-version-incremental-target',
+ 'post-timestamp' : '1500000000',
+ 'pre-device' : 'product-device',
+ },
+ metadata)
+
+ def test_GetPackageMetadata_abOta_incremental(self):
+ target_info_dict = copy.deepcopy(self.TEST_TARGET_INFO_DICT)
+ target_info_dict['ab_update'] = 'true'
+ target_info = BuildInfo(target_info_dict, None)
+ source_info = BuildInfo(self.TEST_SOURCE_INFO_DICT, None)
+ common.OPTIONS.incremental_source = ''
+ metadata = GetPackageMetadata(target_info, source_info)
+ self.assertDictEqual(
+ {
+ 'ota-type' : 'AB',
+ 'ota-required-cache' : '0',
+ 'post-build' : 'build-fingerprint-target',
+ 'post-build-incremental' : 'build-version-incremental-target',
+ 'post-timestamp' : '1500000000',
+ 'pre-device' : 'product-device',
+ 'pre-build' : 'build-fingerprint-source',
+ 'pre-build-incremental' : 'build-version-incremental-source',
+ },
+ metadata)
+
+ def test_GetPackageMetadata_nonAbOta_full(self):
+ target_info = BuildInfo(self.TEST_TARGET_INFO_DICT, None)
+ metadata = GetPackageMetadata(target_info)
+ self.assertDictEqual(
+ {
+ 'ota-type' : 'BLOCK',
+ 'post-build' : 'build-fingerprint-target',
+ 'post-build-incremental' : 'build-version-incremental-target',
+ 'post-timestamp' : '1500000000',
+ 'pre-device' : 'product-device',
+ },
+ metadata)
+
+ def test_GetPackageMetadata_nonAbOta_incremental(self):
+ target_info = BuildInfo(self.TEST_TARGET_INFO_DICT, None)
+ source_info = BuildInfo(self.TEST_SOURCE_INFO_DICT, None)
+ common.OPTIONS.incremental_source = ''
+ metadata = GetPackageMetadata(target_info, source_info)
+ self.assertDictEqual(
+ {
+ 'ota-type' : 'BLOCK',
+ 'post-build' : 'build-fingerprint-target',
+ 'post-build-incremental' : 'build-version-incremental-target',
+ 'post-timestamp' : '1500000000',
+ 'pre-device' : 'product-device',
+ 'pre-build' : 'build-fingerprint-source',
+ 'pre-build-incremental' : 'build-version-incremental-source',
+ },
+ metadata)
+
+ def test_GetPackageMetadata_wipe(self):
+ target_info = BuildInfo(self.TEST_TARGET_INFO_DICT, None)
+ common.OPTIONS.wipe_user_data = True
+ metadata = GetPackageMetadata(target_info)
+ self.assertDictEqual(
+ {
+ 'ota-type' : 'BLOCK',
+ 'ota-wipe' : 'yes',
+ 'post-build' : 'build-fingerprint-target',
+ 'post-build-incremental' : 'build-version-incremental-target',
+ 'post-timestamp' : '1500000000',
+ 'pre-device' : 'product-device',
+ },
+ metadata)
+
+ @staticmethod
+ def _test_GetPackageMetadata_swapBuildTimestamps(target_info, source_info):
+ (target_info['build.prop']['ro.build.date.utc'],
+ source_info['build.prop']['ro.build.date.utc']) = (
+ source_info['build.prop']['ro.build.date.utc'],
+ target_info['build.prop']['ro.build.date.utc'])
+
+ def test_GetPackageMetadata_unintentionalDowngradeDetected(self):
+ target_info_dict = copy.deepcopy(self.TEST_TARGET_INFO_DICT)
+ source_info_dict = copy.deepcopy(self.TEST_SOURCE_INFO_DICT)
+ self._test_GetPackageMetadata_swapBuildTimestamps(
+ target_info_dict, source_info_dict)
+
+ target_info = BuildInfo(target_info_dict, None)
+ source_info = BuildInfo(source_info_dict, None)
+ common.OPTIONS.incremental_source = ''
+ self.assertRaises(RuntimeError, GetPackageMetadata, target_info,
+ source_info)
+
+ def test_GetPackageMetadata_downgrade(self):
+ target_info_dict = copy.deepcopy(self.TEST_TARGET_INFO_DICT)
+ source_info_dict = copy.deepcopy(self.TEST_SOURCE_INFO_DICT)
+ self._test_GetPackageMetadata_swapBuildTimestamps(
+ target_info_dict, source_info_dict)
+
+ target_info = BuildInfo(target_info_dict, None)
+ source_info = BuildInfo(source_info_dict, None)
+ common.OPTIONS.incremental_source = ''
+ common.OPTIONS.downgrade = True
+ common.OPTIONS.wipe_user_data = True
+ metadata = GetPackageMetadata(target_info, source_info)
+ self.assertDictEqual(
+ {
+ 'ota-downgrade' : 'yes',
+ 'ota-type' : 'BLOCK',
+ 'ota-wipe' : 'yes',
+ 'post-build' : 'build-fingerprint-target',
+ 'post-build-incremental' : 'build-version-incremental-target',
+ 'pre-device' : 'product-device',
+ 'pre-build' : 'build-fingerprint-source',
+ 'pre-build-incremental' : 'build-version-incremental-source',
+ },
+ metadata)
+
+ def test_GetPackageMetadata_overrideTimestamp(self):
+ target_info_dict = copy.deepcopy(self.TEST_TARGET_INFO_DICT)
+ source_info_dict = copy.deepcopy(self.TEST_SOURCE_INFO_DICT)
+ self._test_GetPackageMetadata_swapBuildTimestamps(
+ target_info_dict, source_info_dict)
+
+ target_info = BuildInfo(target_info_dict, None)
+ source_info = BuildInfo(source_info_dict, None)
+ common.OPTIONS.incremental_source = ''
+ common.OPTIONS.timestamp = True
+ metadata = GetPackageMetadata(target_info, source_info)
+ self.assertDictEqual(
+ {
+ 'ota-type' : 'BLOCK',
+ 'post-build' : 'build-fingerprint-target',
+ 'post-build-incremental' : 'build-version-incremental-target',
+ 'post-timestamp' : '1500000001',
+ 'pre-device' : 'product-device',
+ 'pre-build' : 'build-fingerprint-source',
+ 'pre-build-incremental' : 'build-version-incremental-source',
+ },
+ metadata)
diff --git a/tools/warn.py b/tools/warn.py
index 62feac3..f42fb96 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -1010,12 +1010,7 @@
'severity': Severity.HIGH,
'description':
'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
- 'patterns': [r".*: warning: \[GuardedByChecker\] .+"]},
- {'category': 'java',
- 'severity': Severity.HIGH,
- 'description':
- 'Java: Invalid @GuardedBy expression',
- 'patterns': [r".*: warning: \[GuardedByValidator\] .+"]},
+ 'patterns': [r".*: warning: \[GuardedBy\] .+"]},
{'category': 'java',
'severity': Severity.HIGH,
'description':