From 917acd67c736894551537c52f8eebc4ab8f96b95 Mon Sep 17 00:00:00 2001 From: Julien Desprez Date: Thu, 15 Dec 2022 18:56:49 -0800 Subject: [PATCH 01/85] Remove tradefed-no-fwk from suites Test: presubmit Bug: 262597958 Change-Id: I672533c475362f4438b5aefc108749be4cfc97df --- core/tasks/tools/compatibility.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/core/tasks/tools/compatibility.mk b/core/tasks/tools/compatibility.mk index a5f162af63..0af2570255 100644 --- a/core/tasks/tools/compatibility.mk +++ b/core/tasks/tools/compatibility.mk @@ -30,7 +30,6 @@ test_suite_subdir := android-$(test_suite_name) out_dir := $(HOST_OUT)/$(test_suite_name)/$(test_suite_subdir) test_artifacts := $(COMPATIBILITY.$(test_suite_name).FILES) test_tools := $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar \ - $(HOST_OUT_JAVA_LIBRARIES)/tradefed-no-fwk.jar \ $(HOST_OUT_JAVA_LIBRARIES)/tradefed-test-framework.jar \ $(HOST_OUT_JAVA_LIBRARIES)/loganalysis.jar \ $(HOST_OUT_JAVA_LIBRARIES)/compatibility-host-util.jar \ From 6e40ac20fd42833e7e582cd69cfc3ced0115a080 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 18 Jan 2023 13:47:11 -0800 Subject: [PATCH 02/85] Update PLATFORM_VERSION to VP1A Update PLATFORM_VERSION to VP1A. The codename is now VanillaIceCream. Bug: 264658905 Test: m checkbuild Change-Id: Ibc24c10cf040407d79662c1819beaf97da791efb --- core/version_defaults.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/version_defaults.mk b/core/version_defaults.mk index a3e274d838..543060d2b9 100644 --- a/core/version_defaults.mk +++ b/core/version_defaults.mk @@ -40,10 +40,10 @@ ifdef INTERNAL_BUILD_ID_MAKEFILE include $(INTERNAL_BUILD_ID_MAKEFILE) endif -DEFAULT_PLATFORM_VERSION := UP1A +DEFAULT_PLATFORM_VERSION := VP1A .KATI_READONLY := DEFAULT_PLATFORM_VERSION MIN_PLATFORM_VERSION := UP1A -MAX_PLATFORM_VERSION := UP1A +MAX_PLATFORM_VERSION := VP1A # The last stable version name of the platform that was released. During # development, this stays at that previous version, while the codename indicates @@ -54,6 +54,7 @@ PLATFORM_VERSION_LAST_STABLE := 13 # These are the current development codenames, if the build is not a final # release build. If this is a final release build, it is simply "REL". PLATFORM_VERSION_CODENAME.UP1A := UpsideDownCake +PLATFORM_VERSION_CODENAME.VP1A := VanillaIceCream # This is the user-visible version. In a final release build it should # be empty to use PLATFORM_VERSION as the user-visible version. For @@ -90,7 +91,7 @@ PLATFORM_VERSION_KNOWN_CODENAMES := \ Base Base11 Cupcake Donut Eclair Eclair01 EclairMr1 Froyo Gingerbread GingerbreadMr1 \ Honeycomb HoneycombMr1 HoneycombMr2 IceCreamSandwich IceCreamSandwichMr1 \ JellyBean JellyBeanMr1 JellyBeanMr2 Kitkat KitkatWatch Lollipop LollipopMr1 M N NMr1 O OMr1 P \ -Q R S Sv2 Tiramisu UpsideDownCake +Q R S Sv2 Tiramisu UpsideDownCake VanillaIceCream # Convert from space separated list to comma separated PLATFORM_VERSION_KNOWN_CODENAMES := \ From eea093d2ffd7f5a2fc27e81fc242f0c20301d45d Mon Sep 17 00:00:00 2001 From: Cynthia Wasonga Date: Tue, 24 Jan 2023 17:16:28 +0000 Subject: [PATCH 03/85] Add preinstallation configs for AOSP Files, Search and Keyboard Bug: 238970256 Bug: 267617358 Test: Verify app installation on device Change-Id: I08d238dfc61571fc9f575e7b72fbee6db418c90c --- ...led-packages-platform-handheld-product.xml | 26 +++++++++++++++---- ...lled-packages-platform-handheld-system.xml | 10 ++++++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/target/product/sysconfig/preinstalled-packages-platform-handheld-product.xml b/target/product/sysconfig/preinstalled-packages-platform-handheld-product.xml index 79c1565ee2..54add22f75 100644 --- a/target/product/sysconfig/preinstalled-packages-platform-handheld-product.xml +++ b/target/product/sysconfig/preinstalled-packages-platform-handheld-product.xml @@ -17,8 +17,11 @@ Documentation at frameworks/base/data/etc/preinstalled-packages-platform.xml --> - + + + + @@ -28,30 +31,43 @@ - + - + - + - + + + + + + + + + + + + + + diff --git a/target/product/sysconfig/preinstalled-packages-platform-handheld-system.xml b/target/product/sysconfig/preinstalled-packages-platform-handheld-system.xml index d25c17ada6..02b03f1aaa 100644 --- a/target/product/sysconfig/preinstalled-packages-platform-handheld-system.xml +++ b/target/product/sysconfig/preinstalled-packages-platform-handheld-system.xml @@ -17,7 +17,15 @@ Documentation at frameworks/base/data/etc/preinstalled-packages-platform.xml --> - + + + + + + + + + From 00d4d717313484f344ccba602cbc572d3943b672 Mon Sep 17 00:00:00 2001 From: Avichal Rakesh Date: Fri, 17 Feb 2023 01:19:21 +0000 Subject: [PATCH 04/85] Revert "Add DeviceAsWebcam to general handheld_system" This reverts commit 28b6a02300745d97bb658250eb21f68dccf36f88. Reason for revert: DeviceAsWebcam is not ready to ship. The target will be re-added once the service is more polished. Change-Id: I287d352782760427db2a66594e4f69f757ff1fb2 --- target/product/handheld_system.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/target/product/handheld_system.mk b/target/product/handheld_system.mk index 3009d6a4dd..2da1395c99 100644 --- a/target/product/handheld_system.mk +++ b/target/product/handheld_system.mk @@ -43,7 +43,6 @@ PRODUCT_PACKAGES += \ CaptivePortalLogin \ CertInstaller \ CredentialManager \ - DeviceAsWebcam \ DocumentsUI \ DownloadProviderUi \ EasterEgg \ From 1c8def4b0059ec25db85a4c6b2b8565f23a5ab0f Mon Sep 17 00:00:00 2001 From: kgui Date: Tue, 21 Feb 2023 19:23:18 +0800 Subject: [PATCH 05/85] Support collecting static code coverage data for all CTS-V APPs. An example coverage xml file is /cns/md-d/home/android-tooltopia-metrics-dremel/combined-coverage.xml. Bug: 270120253 Test: m cts-combined-xml-coverage locally verifies that the APPs are included. Change-Id: If013938d1b6a869e4a0d0dff62296bd4a218ed7c --- core/tasks/cts.mk | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk index c8b1183e28..90227d9db9 100644 --- a/core/tasks/cts.mk +++ b/core/tasks/cts.mk @@ -142,30 +142,30 @@ $(cts-system-api-xml-coverage-report) : $(android_cts_zip) $(cts_system_api_cove $(call generate-coverage-report-cts,"CTS System API Coverage Report - XML",\ $(PRIVATE_TEST_CASES),xml) -$(cts-verifier-coverage-report): PRIVATE_TEST_CASES := $(cts_verifier_apk) +$(cts-verifier-coverage-report): PRIVATE_TEST_CASES := $(foreach c, $(cts_verifier_apk) $(verifier-dir), $(c)) $(cts-verifier-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe) $(cts-verifier-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe) $(cts-verifier-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description) $(cts-verifier-coverage-report): PRIVATE_NAPI_XML_DESC := $(napi_xml_description) -$(cts-verifier-coverage-report) : $(cts_verifier_apk) $(cts_api_coverage_dependencies) | $(ACP) +$(cts-verifier-coverage-report) : $(cts_verifier_apk) $(verifier-zip) $(cts_api_coverage_dependencies) | $(ACP) $(call generate-coverage-report-cts,"CTS Verifier API Coverage Report",\ $(PRIVATE_TEST_CASES),html) -$(cts-combined-coverage-report): PRIVATE_TEST_CASES := $(foreach c, $(cts_verifier_apk) $(COMPATIBILITY_TESTCASES_OUT_cts), $(c)) +$(cts-combined-coverage-report): PRIVATE_TEST_CASES := $(foreach c, $(cts_verifier_apk) $(COMPATIBILITY_TESTCASES_OUT_cts) $(verifier-dir), $(c)) $(cts-combined-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe) $(cts-combined-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe) $(cts-combined-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description) $(cts-combined-coverage-report): PRIVATE_NAPI_XML_DESC := $(napi_xml_description) -$(cts-combined-coverage-report) : $(android_cts_zip) $(cts_verifier_apk) $(cts_api_coverage_dependencies) | $(ACP) +$(cts-combined-coverage-report) : $(android_cts_zip) $(cts_verifier_apk) $(verifier-zip) $(cts_api_coverage_dependencies) | $(ACP) $(call generate-coverage-report-cts,"CTS Combined API Coverage Report",\ $(PRIVATE_TEST_CASES),html) -$(cts-combined-xml-coverage-report): PRIVATE_TEST_CASES := $(foreach c, $(cts_verifier_apk) $(COMPATIBILITY_TESTCASES_OUT_cts), $(c)) +$(cts-combined-xml-coverage-report): PRIVATE_TEST_CASES := $(foreach c, $(cts_verifier_apk) $(COMPATIBILITY_TESTCASES_OUT_cts) $(verifier-dir), $(c)) $(cts-combined-xml-coverage-report): PRIVATE_CTS_API_COVERAGE_EXE := $(cts_api_coverage_exe) $(cts-combined-xml-coverage-report): PRIVATE_DEXDEPS_EXE := $(dexdeps_exe) $(cts-combined-xml-coverage-report): PRIVATE_API_XML_DESC := $(api_xml_description) $(cts-combined-xml-coverage-report): PRIVATE_NAPI_XML_DESC := $(napi_xml_description) -$(cts-combined-xml-coverage-report) : $(android_cts_zip) $(cts_verifier_apk) $(cts_api_coverage_dependencies) | $(ACP) +$(cts-combined-xml-coverage-report) : $(android_cts_zip) $(cts_verifier_apk) $(verifier-zip) $(cts_api_coverage_dependencies) | $(ACP) $(call generate-coverage-report-cts,"CTS Combined API Coverage Report - XML",\ $(PRIVATE_TEST_CASES),xml) @@ -234,3 +234,8 @@ dexdeps_exe := cts_api_coverage_exe := cts_verifier_apk := android_cts_zip := +cts-dir := +verifier-dir-name := +verifier-dir := +verifier-zip-name := +verifier-zip := From 6b87de0c414ffb9e442a9777f3b0b83d95201ed2 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Wed, 22 Feb 2023 08:34:58 -0800 Subject: [PATCH 06/85] Fix release name for branch(es) already on VIC. Bug: 260755259 Test: run locally Change-Id: I09363567fb85a5aed6003d0c518643374b11bea4 --- tools/finalization/environment.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/finalization/environment.sh b/tools/finalization/environment.sh index 6b20791fa7..983e19dc4a 100755 --- a/tools/finalization/environment.sh +++ b/tools/finalization/environment.sh @@ -5,7 +5,7 @@ set -ex export FINAL_BUG_ID='0' export FINAL_PLATFORM_CODENAME='UpsideDownCake' -export CURRENT_PLATFORM_CODENAME='UpsideDownCake' +export CURRENT_PLATFORM_CODENAME='VanillaIceCream' export FINAL_PLATFORM_CODENAME_JAVA='UPSIDE_DOWN_CAKE' export FINAL_PLATFORM_SDK_VERSION='34' export FINAL_PLATFORM_VERSION='14' From 4d291ec5ee2a8774e9c281a2a97f57320725b57d Mon Sep 17 00:00:00 2001 From: YoungJoon Yang Date: Wed, 18 Jan 2023 17:39:10 +0900 Subject: [PATCH 07/85] Adding BOARD_NON_AB_OTA_DISABLE_COMPRESSION Brotli decompression error occured during sideloading non A/B full OTA. The flag disable brotli compression for non A/B full OTA. The flag set if a device supports non A/B update. Bug: 248350283 Test: build and sideload the full ota package. (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:64f700aad93501edbcfb0d2fa81b3bacc2194a73) Merged-In: I1a7dcd0cbfc425629ec4a8b7dbe18f2937571c09 Change-Id: I1a7dcd0cbfc425629ec4a8b7dbe18f2937571c09 --- core/Makefile | 3 +++ core/board_config.mk | 5 +++++ tools/releasetools/common.py | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/Makefile b/core/Makefile index e1a08bfe2b..9fe209ff18 100644 --- a/core/Makefile +++ b/core/Makefile @@ -5441,6 +5441,9 @@ endif ifeq ($(TARGET_OTA_ALLOW_NON_AB),true) $(hide) echo "allow_non_ab=true" >> $@ endif +ifeq ($(BOARD_NON_AB_OTA_DISABLE_COMPRESSION),true) + $(hide) echo "board_non_ab_ota_disable_compression=true" >> $@ +endif ifdef BOARD_PREBUILT_DTBOIMAGE $(hide) echo "has_dtbo=true" >> $@ ifeq ($(BOARD_AVB_ENABLE),true) diff --git a/core/board_config.mk b/core/board_config.mk index af059730ea..66f42c7f94 100644 --- a/core/board_config.mk +++ b/core/board_config.mk @@ -954,6 +954,11 @@ ifneq ($(TARGET_OTA_ALLOW_NON_AB),true) endif endif +# For Non A/B full OTA, disable brotli compression. +ifeq ($(TARGET_OTA_ALLOW_NON_AB),true) + BOARD_NON_AB_OTA_DISABLE_COMPRESSION := true +endif + # Quick check for building generic OTA packages. Currently it only supports A/B OTAs. ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true) ifneq ($(AB_OTA_UPDATER),true) diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 1e87b9c930..e2a29f72d4 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -3403,7 +3403,7 @@ class BlockDifference(object): # compression_time: 75s | 265s | 719s # decompression_time: 15s | 25s | 25s - if not self.src: + if not self.src and not OPTIONS.info_dict.get("board_non_ab_ota_disable_compression"): brotli_cmd = ['brotli', '--quality=6', '--output={}.new.dat.br'.format(self.path), '{}.new.dat'.format(self.path)] From 6d7bf283adb7ad7a465ae817543325718e1d6095 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Mon, 27 Mar 2023 17:21:58 +0900 Subject: [PATCH 08/85] Add TARGET_USES_AOSP_FOR_WLAN soong variable It's set and used in many .mk files. Adding this to "wifi" soong config namespace helps migration of those .mk files into .bp files. Ignore-AOSP-First: Topic includes a project not in AOSP. Bug: 273376293 Test: m libwifi-hal libwifi-hal-qcom Change-Id: Ie0fad26305d50f70076b7e538fd1a7fa03e397cb --- core/board_config_wifi.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/board_config_wifi.mk b/core/board_config_wifi.mk index a7360992ae..8289bf2c5d 100644 --- a/core/board_config_wifi.mk +++ b/core/board_config_wifi.mk @@ -78,3 +78,6 @@ endif ifdef WIFI_SKIP_STATE_TOGGLE_OFF_ON_FOR_NAN $(call soong_config_set,wifi,wifi_skip_state_toggle_off_on_for_nan,true) endif +ifeq ($(strip $(TARGET_USES_AOSP_FOR_WLAN)),true) + $(call soong_config_set,wifi,target_uses_aosp_for_wlan,true) +endif \ No newline at end of file From 8021ccb4b84767b7dc3cfe4cdfe115b41b1ec4b0 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Thu, 13 Apr 2023 00:40:10 +0000 Subject: [PATCH 09/85] Switch master to "unfinalized" state. udc-dev change got automerged into master, we need to revert it. Bug: 243966946 Test: run locally Change-Id: I48c2d8c48c0a49d0267fb1a71cd27c2fe67b445c --- tools/finalization/environment.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/finalization/environment.sh b/tools/finalization/environment.sh index 8809f13743..4b002a3335 100755 --- a/tools/finalization/environment.sh +++ b/tools/finalization/environment.sh @@ -18,4 +18,4 @@ export FINAL_MAINLINE_EXTENSION='7' # 'unfinalized' - branch is in development state, # 'sdk' - SDK/API is finalized # 'rel' - branch is finalized, switched to REL -export FINAL_STATE='sdk' +export FINAL_STATE='unfinalized' From 9e91d2db1d7dbff01ca58c913b72a8a834aa567b Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Sun, 16 Apr 2023 21:22:04 -0700 Subject: [PATCH 10/85] Switch master to "half-finalized" mode in sync with udc-dev. Bug: 275409981 Test: run locally Change-Id: Ia3301ac93ae51ce7236ea007000d48ba72b15405 --- tools/finalization/environment.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/finalization/environment.sh b/tools/finalization/environment.sh index 4b002a3335..8809f13743 100755 --- a/tools/finalization/environment.sh +++ b/tools/finalization/environment.sh @@ -18,4 +18,4 @@ export FINAL_MAINLINE_EXTENSION='7' # 'unfinalized' - branch is in development state, # 'sdk' - SDK/API is finalized # 'rel' - branch is finalized, switched to REL -export FINAL_STATE='unfinalized' +export FINAL_STATE='sdk' From 576ca9f1621ea4e0196da062654b6f515fa2b111 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Wed, 26 Apr 2023 05:17:13 +0000 Subject: [PATCH 11/85] Mark master as VIC development branch. Test: ./build-step-1-and-m.sh Bug: 279615150 Change-Id: Idb485846345ea146c04c5ecf6eb4ab6eea122f9b --- tools/finalization/environment.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/finalization/environment.sh b/tools/finalization/environment.sh index 8809f13743..892361dd9c 100755 --- a/tools/finalization/environment.sh +++ b/tools/finalization/environment.sh @@ -2,20 +2,21 @@ set -ex -export FINAL_BUG_ID='275409981' +export FINAL_BUG_ID='0' # CI only -export FINAL_PLATFORM_CODENAME='UpsideDownCake' +export FINAL_PLATFORM_CODENAME='VanillaIceCream' export CURRENT_PLATFORM_CODENAME='VanillaIceCream' -export FINAL_PLATFORM_CODENAME_JAVA='UPSIDE_DOWN_CAKE' -export FINAL_PLATFORM_SDK_VERSION='34' -export FINAL_PLATFORM_VERSION='14' +export FINAL_PLATFORM_CODENAME_JAVA='VANILLA_ICE_CREAM' +export FINAL_BUILD_PREFIX='VP1A' +export FINAL_PLATFORM_VERSION='15' -export FINAL_BUILD_PREFIX='UP1A' - -export FINAL_MAINLINE_EXTENSION='7' +# Set arbitrary large values for CI. +# Feel free to randomize them once in a while to detect buggy version detection code. +export FINAL_PLATFORM_SDK_VERSION='97' +export FINAL_MAINLINE_EXTENSION='98' # Options: # 'unfinalized' - branch is in development state, # 'sdk' - SDK/API is finalized # 'rel' - branch is finalized, switched to REL -export FINAL_STATE='sdk' +export FINAL_STATE='unfinalized' From 0ad810849bf35f51ebbc9c45fdfe20acce4fcc07 Mon Sep 17 00:00:00 2001 From: SzuWei Lin Date: Mon, 15 May 2023 15:38:58 +0800 Subject: [PATCH 12/85] Support dynamic 64-bit drmserver 64-bit GSI requires support both 64_32-bit and 64-bit devices at the same time. Add a new variable TARGET_DYNAMIC_64_32_DRMSERVER to put drmserver_dynamic.rc into GSI. Which starts 64-bit drmserver if ro.zygote is zygote64. Otherwise, it keeps the original behavior to start 32-bit drmserver. Bug: 282603373 Test: make gsi_arm64-user; Check system/etc/init Test: make gsi_arm-user; Check systen/etc/init Change-Id: I874cee00a066086f565e044549ad40c6ab5d62b0 Merged-In: I874cee00a066086f565e044549ad40c6ab5d62b0 --- core/android_soong_config_vars.mk | 1 + target/board/generic_arm64/BoardConfig.mk | 2 ++ target/board/generic_x86_64/BoardConfig.mk | 2 ++ target/board/gsi_arm64/BoardConfig.mk | 2 ++ 4 files changed, 7 insertions(+) diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk index f2ff201ab5..995eefb875 100644 --- a/core/android_soong_config_vars.mk +++ b/core/android_soong_config_vars.mk @@ -27,6 +27,7 @@ $(call add_soong_config_namespace,ANDROID) # Add variables to the namespace below: $(call add_soong_config_var,ANDROID,TARGET_DYNAMIC_64_32_MEDIASERVER) +$(call add_soong_config_var,ANDROID,TARGET_DYNAMIC_64_32_DRMSERVER) $(call add_soong_config_var,ANDROID,TARGET_ENABLE_MEDIADRM_64) $(call add_soong_config_var,ANDROID,IS_TARGET_MIXED_SEPOLICY) ifeq ($(IS_TARGET_MIXED_SEPOLICY),true) diff --git a/target/board/generic_arm64/BoardConfig.mk b/target/board/generic_arm64/BoardConfig.mk index 40be80e413..e2d5fb4df8 100644 --- a/target/board/generic_arm64/BoardConfig.mk +++ b/target/board/generic_arm64/BoardConfig.mk @@ -54,6 +54,8 @@ endif # Include 64-bit mediaserver to support 64-bit only devices TARGET_DYNAMIC_64_32_MEDIASERVER := true +# Include 64-bit drmserver to support 64-bit only devices +TARGET_DYNAMIC_64_32_DRMSERVER := true include build/make/target/board/BoardConfigGsiCommon.mk diff --git a/target/board/generic_x86_64/BoardConfig.mk b/target/board/generic_x86_64/BoardConfig.mk index e7f2ae0072..36136f4b35 100755 --- a/target/board/generic_x86_64/BoardConfig.mk +++ b/target/board/generic_x86_64/BoardConfig.mk @@ -24,6 +24,8 @@ TARGET_2ND_ARCH_VARIANT := x86_64 # Include 64-bit mediaserver to support 64-bit only devices TARGET_DYNAMIC_64_32_MEDIASERVER := true +# Include 64-bit drmserver to support 64-bit only devices +TARGET_DYNAMIC_64_32_DRMSERVER := true include build/make/target/board/BoardConfigGsiCommon.mk diff --git a/target/board/gsi_arm64/BoardConfig.mk b/target/board/gsi_arm64/BoardConfig.mk index db95082e5f..7910b1da15 100644 --- a/target/board/gsi_arm64/BoardConfig.mk +++ b/target/board/gsi_arm64/BoardConfig.mk @@ -29,6 +29,8 @@ TARGET_2ND_CPU_VARIANT := generic # Include 64-bit mediaserver to support 64-bit only devices TARGET_DYNAMIC_64_32_MEDIASERVER := true +# Include 64-bit drmserver to support 64-bit only devices +TARGET_DYNAMIC_64_32_DRMSERVER := true # TODO(b/111434759, b/111287060) SoC specific hacks BOARD_ROOT_EXTRA_SYMLINKS += /vendor/lib/dsp:/dsp From 7b40aa8338ba85a58ee481fe6bafac2959f7112b Mon Sep 17 00:00:00 2001 From: Jeongik Cha Date: Thu, 27 Apr 2023 11:05:22 +0900 Subject: [PATCH 13/85] BUILD_NUMBER and BUILD_HOSTNAME doesn't affect kati regeneration * Extract BUILD_NUMBER, BUILD_HOSTNAME to file to avoid kati change * Handle FILE_NAME_TAG_PLACEHOLDER string in dist in build/make/packaging/distdir.mk Ignore-AOSP-First: there are internal use cases of FILE_NAME_TAG Test: check if kati isn't invoked even though BUILD_NUMBER, BUILD_HOSTNAME is changed Test: m && m, and check if the second m is no-op Bug: 278060169 Change-Id: I1b37760242853c1a145bad255d0bb15524234b25 --- Changes.md | 18 +++++++++ core/Makefile | 32 ++++++++-------- core/config.mk | 1 + core/host_java_library.mk | 2 - core/java.mk | 2 - core/main.mk | 51 +++++++++++--------------- core/sysprop.mk | 13 +++++-- core/tasks/sdk-addon.mk | 15 ++++---- core/tasks/tools/build_custom_image.mk | 3 ++ core/tasks/tools/compatibility.mk | 3 ++ core/tasks/with-license.mk | 6 ++- core/version_util.mk | 15 +------- packaging/distdir.mk | 6 ++- 13 files changed, 91 insertions(+), 76 deletions(-) diff --git a/Changes.md b/Changes.md index 6d20173c19..fc6701d7e5 100644 --- a/Changes.md +++ b/Changes.md @@ -505,6 +505,24 @@ $(call dist-for-goals,foo,bar/baz) will copy `bar/baz` into `$DIST_DIR/baz` when `m foo dist` is run. +#### FILE_NAME_TAG {#FILE_NAME_TAG} + +To embed the `BUILD_NUMBER` (or for local builds, `eng.${USER}`), include +`FILE_NAME_TAG_PLACEHOLDER` in the destination: + +``` make +# you can use dist-for-goals-with-filenametag function +$(call dist-for-goals-with-filenametag,foo,bar.zip) +# or use FILE_NAME_TAG_PLACEHOLDER manually +$(call dist-for-goals,foo,bar.zip:baz-FILE_NAME_TAG_PLACEHOLDER.zip) +``` + +Which will produce `$DIST_DIR/baz-1234567.zip` on build servers which set +`BUILD_NUMBER=1234567`, or `$DIST_DIR/baz-eng.builder.zip` for local builds. + +If you just want to append `BUILD_NUMBER` at the end of basename, use +`dist-for-goals-with-filenametag` instead of `dist-for-goals`. + #### Renames during copy Instead of specifying just a file, a destination name can be specified, diff --git a/core/Makefile b/core/Makefile index 9c08a3efa8..22c2716479 100644 --- a/core/Makefile +++ b/core/Makefile @@ -711,7 +711,7 @@ name := $(TARGET_PRODUCT) ifeq ($(TARGET_BUILD_TYPE),debug) name := $(name)_debug endif -name := $(name)-apkcerts-$(FILE_NAME_TAG) +name := $(name)-apkcerts intermediates := \ $(call intermediates-dir-for,PACKAGING,apkcerts) APKCERTS_FILE := $(intermediates)/$(name).txt @@ -5713,7 +5713,7 @@ name := $(TARGET_PRODUCT) ifeq ($(TARGET_BUILD_TYPE),debug) name := $(name)_debug endif -name := $(name)-target_files-$(FILE_NAME_TAG) +name := $(name)-target_files intermediates := $(call intermediates-dir-for,PACKAGING,target_files) BUILT_TARGET_FILES_DIR := $(intermediates)/$(name).zip.list @@ -6483,7 +6483,7 @@ $(call declare-container-license-deps,$(BUILT_TARGET_FILES_PACKAGE), $(INSTALLED $(BUILT_KERNEL_CONFIGS_FILE) \ $(BUILT_KERNEL_VERSION_FILE),$(BUILT_TARGET_FILES_PACKAGE):) -$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE)) +$(call dist-for-goals-with-filenametag, target-files-package, $(BUILT_TARGET_FILES_PACKAGE)) # ----------------------------------------------------------------- # NDK Sysroot Package @@ -6518,7 +6518,7 @@ product_name := $(TARGET_PRODUCT) ifeq ($(TARGET_BUILD_TYPE),debug) product_name := $(product_name)_debug endif -name := $(product_name)-ota-$(FILE_NAME_TAG) +name := $(product_name)-ota INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata @@ -6538,7 +6538,7 @@ $(call declare-container-license-deps,$(INTERNAL_OTA_PACKAGE_TARGET),$(BUILT_TAR otapackage: $(INTERNAL_OTA_PACKAGE_TARGET) ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true) -name := $(product_name)-ota-retrofit-$(FILE_NAME_TAG) +name := $(product_name)-ota-retrofit INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR) @@ -6559,7 +6559,7 @@ otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TAR endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),) -name := $(product_name)-partial-ota-$(FILE_NAME_TAG) +name := $(product_name)-partial-ota INTERNAL_OTA_PARTIAL_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR) @@ -6659,9 +6659,9 @@ ifeq ($(TARGET_BUILD_TYPE),debug) endif # The path to the zip file containing binaries with symbols. -SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name)-symbols-$(FILE_NAME_TAG).zip +SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name)-symbols.zip # The path to a file containing mappings from elf IDs to filenames. -SYMBOLS_MAPPING := $(PRODUCT_OUT)/$(name)-symbols-mapping-$(FILE_NAME_TAG).textproto +SYMBOLS_MAPPING := $(PRODUCT_OUT)/$(name)-symbols-mapping.textproto .KATI_READONLY := SYMBOLS_ZIP SYMBOLS_MAPPING # For apps_only build we'll establish the dependency later in build/make/core/main.mk. ifeq (,$(TARGET_BUILD_UNBUNDLED)) @@ -6736,7 +6736,7 @@ name := $(TARGET_PRODUCT) ifeq ($(TARGET_BUILD_TYPE),debug) name := $(name)_debug endif -name := $(name)-apps-$(FILE_NAME_TAG) +name := $(name)-apps APPS_ZIP := $(PRODUCT_OUT)/$(name).zip $(APPS_ZIP): $(FULL_SYSTEMIMAGE_DEPS) @@ -6787,9 +6787,9 @@ endif # EMMA_INSTRUMENT=true # # The path to the zip file containing proguard dictionaries. -PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip +PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict.zip # The path to the zip file containing mappings from dictionary hashes to filenames. -PROGUARD_DICT_MAPPING := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-mapping-$(FILE_NAME_TAG).textproto +PROGUARD_DICT_MAPPING := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-mapping.textproto .KATI_READONLY := PROGUARD_DICT_ZIP PROGUARD_DICT_MAPPING # For apps_only build we'll establish the dependency later in build/make/core/main.mk. ifeq (,$(TARGET_BUILD_UNBUNDLED)) @@ -6818,7 +6818,7 @@ endif #------------------------------------------------------------------ # A zip of Proguard usage files. # -PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage-$(FILE_NAME_TAG).zip +PROGUARD_USAGE_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage.zip # For apps_only build we'll establish the dependency later in build/make/core/main.mk. ifeq (,$(TARGET_BUILD_UNBUNDLED)) $(PROGUARD_USAGE_ZIP): \ @@ -6995,7 +6995,7 @@ name := $(TARGET_PRODUCT) ifeq ($(TARGET_BUILD_TYPE),debug) name := $(name)_debug endif -name := $(name)-img-$(FILE_NAME_TAG) +name := $(name)-img INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip @@ -7011,7 +7011,7 @@ $(call declare-container-license-deps,$(INTERNAL_UPDATE_PACKAGE_TARGET),$(BUILT_ .PHONY: updatepackage updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET) -$(call dist-for-goals,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET)) +$(call dist-for-goals-with-filenametag,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET)) # ----------------------------------------------------------------- @@ -7140,7 +7140,7 @@ INTERNAL_EMULATOR_PACKAGE_FILES += \ $(INSTALLED_SYSTEMIMAGE_TARGET) \ $(INSTALLED_USERDATAIMAGE_TARGET) -name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG) +name := $(TARGET_PRODUCT)-emulator INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip @@ -7168,7 +7168,7 @@ sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT) ifneq ($(HOST_OS),linux) $(error Building the monolithic SDK is only supported on Linux) endif -sdk_name := android-sdk_$(FILE_NAME_TAG) +sdk_name := android-sdk INTERNAL_SDK_HOST_OS_NAME := linux-$(SDK_HOST_ARCH) sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME) diff --git a/core/config.mk b/core/config.mk index 6ec63ebffd..78edeff258 100644 --- a/core/config.mk +++ b/core/config.mk @@ -856,6 +856,7 @@ endif .KATI_READONLY := MAINLINE_SEPOLICY_DEV_CERTIFICATES BUILD_NUMBER_FROM_FILE := $$(cat $(SOONG_OUT_DIR)/build_number.txt) +BUILD_HOSTNAME_FROM_FILE := $$(cat $(SOONG_OUT_DIR)/build_hostname.txt) BUILD_DATETIME_FROM_FILE := $$(cat $(BUILD_DATETIME_FILE)) # SEPolicy versions diff --git a/core/host_java_library.mk b/core/host_java_library.mk index 89aa53ce0c..8e063d0ae3 100644 --- a/core/host_java_library.mk +++ b/core/host_java_library.mk @@ -98,8 +98,6 @@ $(full_classes_combined_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_D $(full_classes_combined_jar): $(full_classes_compiled_jar) \ $(jar_manifest_file) \ $(full_static_java_libs) | $(MERGE_ZIPS) - $(if $(PRIVATE_JAR_MANIFEST), $(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \ - $(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf) $(MERGE_ZIPS) -j --ignore-duplicates $(if $(PRIVATE_JAR_MANIFEST),-m $(dir $@)/manifest.mf) \ $(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,-stripDir META-INF -zipToNotStrip $<) \ $@ $< $(PRIVATE_STATIC_JAVA_LIBRARIES) diff --git a/core/java.mk b/core/java.mk index b13ef4d403..6d8f23709e 100644 --- a/core/java.mk +++ b/core/java.mk @@ -296,8 +296,6 @@ $(full_classes_combined_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_D $(full_classes_combined_jar): $(full_classes_compiled_jar) \ $(jar_manifest_file) \ $(full_static_java_libs) | $(MERGE_ZIPS) - $(if $(PRIVATE_JAR_MANIFEST), $(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \ - $(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf) $(MERGE_ZIPS) -j --ignore-duplicates $(if $(PRIVATE_JAR_MANIFEST),-m $(dir $@)/manifest.mf) \ $(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,-stripDir META-INF -zipToNotStrip $<) \ $@ $< $(PRIVATE_STATIC_JAVA_LIBRARIES) diff --git a/core/main.mk b/core/main.mk index a747967347..36bfbfa02e 100644 --- a/core/main.mk +++ b/core/main.mk @@ -40,31 +40,23 @@ include $(BUILD_SYSTEM)/clang/config.mk # Write the build number to a file so it can be read back in # without changing the command line every time. Avoids rebuilds # when using ninja. -$(shell mkdir -p $(SOONG_OUT_DIR) && \ - echo -n $(BUILD_NUMBER) > $(SOONG_OUT_DIR)/build_number.tmp; \ - if ! cmp -s $(SOONG_OUT_DIR)/build_number.tmp $(SOONG_OUT_DIR)/build_number.txt; then \ - mv $(SOONG_OUT_DIR)/build_number.tmp $(SOONG_OUT_DIR)/build_number.txt; \ - else \ - rm $(SOONG_OUT_DIR)/build_number.tmp; \ - fi) BUILD_NUMBER_FILE := $(SOONG_OUT_DIR)/build_number.txt -.KATI_READONLY := BUILD_NUMBER_FILE $(KATI_obsolete_var BUILD_NUMBER,See https://android.googlesource.com/platform/build/+/master/Changes.md#BUILD_NUMBER) +BUILD_HOSTNAME_FILE := $(SOONG_OUT_DIR)/build_hostname.txt +$(KATI_obsolete_var BUILD_HOSTNAME,Use BUILD_HOSTNAME_FROM_FILE instead) +$(KATI_obsolete_var FILE_NAME_TAG,https://android.googlesource.com/platform/build/+/master/Changes.md#FILE_NAME_TAG) + $(BUILD_NUMBER_FILE): - touch $@ + touch -a $@ +$(BUILD_HOSTNAME_FILE): + touch -a $@ + +.KATI_RESTAT: $(BUILD_NUMBER_FILE) +.KATI_RESTAT: $(BUILD_HOSTNAME_FILE) DATE_FROM_FILE := date -d @$(BUILD_DATETIME_FROM_FILE) .KATI_READONLY := DATE_FROM_FILE -# Pick a reasonable string to use to identify files. -ifeq ($(strip $(HAS_BUILD_NUMBER)),false) - # BUILD_NUMBER has a timestamp in it, which means that - # it will change every time. Pick a stable value. - FILE_NAME_TAG := eng.$(BUILD_USERNAME) -else - FILE_NAME_TAG := $(file <$(BUILD_NUMBER_FILE)) -endif -.KATI_READONLY := FILE_NAME_TAG # Make an empty directory, which can be used to make empty jars EMPTY_DIRECTORY := $(OUT_DIR)/empty @@ -1751,15 +1743,15 @@ else ifneq ($(TARGET_BUILD_APPS),) endif $(PROGUARD_DICT_ZIP) : $(apps_only_installed_files) - $(call dist-for-goals,apps_only, $(PROGUARD_DICT_ZIP) $(PROGUARD_DICT_MAPPING)) + $(call dist-for-goals-with-filenametag,apps_only, $(PROGUARD_DICT_ZIP) $(PROGUARD_DICT_ZIP) $(PROGUARD_DICT_MAPPING)) $(call declare-container-license-deps,$(PROGUARD_DICT_ZIP),$(apps_only_installed_files),$(PRODUCT_OUT)/:/) $(PROGUARD_USAGE_ZIP) : $(apps_only_installed_files) - $(call dist-for-goals,apps_only, $(PROGUARD_USAGE_ZIP)) + $(call dist-for-goals-with-filenametag,apps_only, $(PROGUARD_USAGE_ZIP)) $(call declare-container-license-deps,$(PROGUARD_USAGE_ZIP),$(apps_only_installed_files),$(PRODUCT_OUT)/:/) $(SYMBOLS_ZIP) : $(apps_only_installed_files) - $(call dist-for-goals,apps_only, $(SYMBOLS_ZIP) $(SYMBOLS_MAPPING)) + $(call dist-for-goals-with-filenametag,apps_only, $(SYMBOLS_ZIP) $(SYMBOLS_MAPPING)) $(call declare-container-license-deps,$(SYMBOLS_ZIP),$(apps_only_installed_files),$(PRODUCT_OUT)/:/) $(COVERAGE_ZIP) : $(apps_only_installed_files) @@ -1805,10 +1797,9 @@ else ifeq ($(TARGET_BUILD_UNBUNDLED),$(TARGET_BUILD_UNBUNDLED_IMAGE)) # avoid disting targets that would cause building framework java sources, # which we want to avoid in an unbundled build. - $(call dist-for-goals, droidcore-unbundled, \ + $(call dist-for-goals-with-filenametag, droidcore-unbundled, \ $(INTERNAL_UPDATE_PACKAGE_TARGET) \ $(INTERNAL_OTA_PACKAGE_TARGET) \ - $(INTERNAL_OTA_METADATA) \ $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET) \ $(BUILT_RAMDISK_16K_TARGET) \ $(BUILT_KERNEL_16K_TARGET) \ @@ -1818,6 +1809,11 @@ else ifeq ($(TARGET_BUILD_UNBUNDLED),$(TARGET_BUILD_UNBUNDLED_IMAGE)) $(PROGUARD_DICT_ZIP) \ $(PROGUARD_DICT_MAPPING) \ $(PROGUARD_USAGE_ZIP) \ + $(BUILT_TARGET_FILES_PACKAGE) \ + ) + + $(call dist-for-goals, droidcore-unbundled, \ + $(INTERNAL_OTA_METADATA) \ $(COVERAGE_ZIP) \ $(INSTALLED_FILES_FILE) \ $(INSTALLED_FILES_JSON) \ @@ -1845,7 +1841,6 @@ else ifeq ($(TARGET_BUILD_UNBUNDLED),$(TARGET_BUILD_UNBUNDLED_IMAGE)) $(INSTALLED_ODM_BUILD_PROP_TARGET):build.prop-odm \ $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET):build.prop-system_ext \ $(INSTALLED_RAMDISK_BUILD_PROP_TARGET):build.prop-ramdisk \ - $(BUILT_TARGET_FILES_PACKAGE) \ $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ $(INSTALLED_MISC_INFO_TARGET) \ $(INSTALLED_RAMDISK_TARGET) \ @@ -1857,7 +1852,7 @@ else ifeq ($(TARGET_BUILD_UNBUNDLED),$(TARGET_BUILD_UNBUNDLED_IMAGE)) $(call dist-for-goals, droidcore-unbundled, $(f))) ifneq ($(ANDROID_BUILD_EMBEDDED),true) - $(call dist-for-goals, droidcore, \ + $(call dist-for-goals-with-filenametag, droidcore, \ $(APPS_ZIP) \ $(INTERNAL_EMULATOR_PACKAGE_TARGET) \ ) @@ -1957,10 +1952,8 @@ docs: $(ALL_DOCS) ifeq ($(HOST_OS),linux) ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET) sdk: $(ALL_SDK_TARGETS) -$(call dist-for-goals,sdk, \ - $(ALL_SDK_TARGETS) \ - $(INSTALLED_BUILD_PROP_TARGET) \ -) +$(call dist-for-goals-with-filenametag,sdk,$(ALL_SDK_TARGETS)) +$(call dist-for-goals,sdk,$(INSTALLED_BUILD_PROP_TARGET)) endif # umbrella targets to assit engineers in verifying builds diff --git a/core/sysprop.mk b/core/sysprop.mk index bd6f3d9fdf..cf4b1f64b4 100644 --- a/core/sysprop.mk +++ b/core/sysprop.mk @@ -174,7 +174,7 @@ ifeq (,$(strip $(BUILD_FINGERPRINT))) ifeq ($(strip $(HAS_BUILD_NUMBER)),false) BF_BUILD_NUMBER := $(BUILD_USERNAME)$$($(DATE_FROM_FILE) +%m%d%H%M) else - BF_BUILD_NUMBER := $(file <$(BUILD_NUMBER_FILE)) + BF_BUILD_NUMBER := $$(cat $(SOONG_OUT_DIR)/build_hostname.txt) endif BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BF_BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) endif @@ -196,6 +196,9 @@ ifeq (,$(strip $(BUILD_THUMBPRINT))) endif BUILD_THUMBPRINT_FILE := $(PRODUCT_OUT)/build_thumbprint.txt +ifeq ($(strip $(HAS_BUILD_NUMBER)),true) +$(BUILD_THUMBPRINT_FILE): $(BUILD_NUMBER_FILE) +endif ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_THUMBPRINT) >$(BUILD_THUMBPRINT_FILE) && grep " " $(BUILD_THUMBPRINT_FILE))) $(error BUILD_THUMBPRINT cannot contain spaces: "$(file <$(BUILD_THUMBPRINT_FILE))") endif @@ -260,7 +263,11 @@ $(strip $(subst _,-, $(firstword $(1)))) endef gen_from_buildinfo_sh := $(call intermediates-dir-for,PACKAGING,system_build_prop)/buildinfo.prop -$(gen_from_buildinfo_sh): $(INTERNAL_BUILD_ID_MAKEFILE) $(API_FINGERPRINT) | $(BUILD_DATETIME_FILE) $(BUILD_NUMBER_FILE) + +ifeq ($(strip $(HAS_BUILD_NUMBER)),true) +$(gen_from_buildinfo_sh): $(BUILD_NUMBER_FILE) +endif +$(gen_from_buildinfo_sh): $(INTERNAL_BUILD_ID_MAKEFILE) $(API_FINGERPRINT) $(BUILD_HOSTNAME_FILE) | $(BUILD_DATETIME_FILE) $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \ TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \ TARGET_DEVICE="$(TARGET_DEVICE)" \ @@ -271,7 +278,7 @@ $(gen_from_buildinfo_sh): $(INTERNAL_BUILD_ID_MAKEFILE) $(API_FINGERPRINT) | $(B BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \ DATE="$(DATE_FROM_FILE)" \ BUILD_USERNAME="$(BUILD_USERNAME)" \ - BUILD_HOSTNAME="$(BUILD_HOSTNAME)" \ + BUILD_HOSTNAME="$(BUILD_HOSTNAME_FROM_FILE)" \ BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \ BOARD_USE_VBMETA_DIGTEST_IN_FINGERPRINT="$(BOARD_USE_VBMETA_DIGTEST_IN_FINGERPRINT)" \ PLATFORM_VERSION="$(PLATFORM_VERSION)" \ diff --git a/core/tasks/sdk-addon.mk b/core/tasks/sdk-addon.mk index 5097f1266f..7acac72f1d 100644 --- a/core/tasks/sdk-addon.mk +++ b/core/tasks/sdk-addon.mk @@ -19,12 +19,13 @@ addon_name := $(PRODUCT_SDK_ADDON_NAME) ifneq ($(addon_name),) -addon_dir_leaf := $(addon_name)-$(FILE_NAME_TAG)-$(INTERNAL_SDK_HOST_OS_NAME) -addon_dir_img := $(addon_dir_leaf)-img -intermediates := $(HOST_OUT_INTERMEDIATES)/SDK_ADDON/$(addon_name)_intermediates -full_target := $(HOST_OUT_SDK_ADDON)/$(addon_dir_leaf).zip -full_target_img := $(HOST_OUT_SDK_ADDON)/$(addon_dir_img).zip -staging := $(intermediates) +addon_dir_leaf := $(addon_name)-$(INTERNAL_SDK_HOST_OS_NAME) +addon_dir_img := $(addon_dir_leaf)-img +intermediates := $(HOST_OUT_INTERMEDIATES)/SDK_ADDON/$(addon_name)_intermediates +full_target := $(HOST_OUT_SDK_ADDON)/$(addon_dir_leaf).zip +full_target_dist_name := $(addon_name)-FILE_NAME_TAG_PLACEHOLDER-$(INTERNAL_SDK_HOST_OS_NAME) +full_target_img := $(HOST_OUT_SDK_ADDON)/$(addon_dir_img).zip +staging := $(intermediates) sdk_addon_deps := files_to_copy := @@ -140,7 +141,7 @@ ADDON_SDK_IMG_ZIP := $(full_target_img) else # When not building an sdk_repo, just dist the addon zip file # as-is. -$(call dist-for-goals, sdk_addon, $(full_target)) +$(call dist-for-goals, sdk_addon, $(full_target):$(full_target_dist_name)) endif else # addon_name diff --git a/core/tasks/tools/build_custom_image.mk b/core/tasks/tools/build_custom_image.mk index 2626120eb0..ba97e8a626 100644 --- a/core/tasks/tools/build_custom_image.mk +++ b/core/tasks/tools/build_custom_image.mk @@ -105,6 +105,9 @@ ifeq (true,$(filter true, $(CUSTOM_IMAGE_AVB_HASH_ENABLE) $(CUSTOM_IMAGE_AVB_HAS else ifneq (,$(filter true, $(CUSTOM_IMAGE_AVB_HASH_ENABLE) $(CUSTOM_IMAGE_AVB_HASHTREE_ENABLE))) $(error Cannot set both CUSTOM_IMAGE_AVB_HASH_ENABLE and CUSTOM_IMAGE_AVB_HASHTREE_ENABLE to true) endif +ifeq ($(strip $(HAS_BUILD_NUMBER)),true) +$(my_built_custom_image): $(BUILD_NUMBER_FILE) +endif $(my_built_custom_image): $(INTERNAL_USERIMAGES_DEPS) $(my_built_modules) $(my_image_copy_files) $(my_custom_image_modules_dep) \ $(CUSTOM_IMAGE_DICT_FILE) @echo "Build image $@" diff --git a/core/tasks/tools/compatibility.mk b/core/tasks/tools/compatibility.mk index 8ae2a9ae5a..dd2305e7b9 100644 --- a/core/tasks/tools/compatibility.mk +++ b/core/tasks/tools/compatibility.mk @@ -118,6 +118,9 @@ $(compatibility_zip): PRIVATE_RESOURCES := $(compatibility_zip_resources) $(compatibility_zip): PRIVATE_JDK := $(test_suite_jdk) $(compatibility_zip): PRIVATE_tests_list := $(out_dir)-tests_list $(compatibility_zip): PRIVATE_tests_list_zip := $(compatibility_tests_list_zip) +ifeq ($(strip $(HAS_BUILD_NUMBER)),true) +$(compatibility_zip): $(BUILD_NUMBER_FILE) +endif $(compatibility_zip): $(compatibility_zip_deps) | $(ADB) $(ACP) # Make dir structure mkdir -p $(PRIVATE_OUT_DIR)/tools $(PRIVATE_OUT_DIR)/testcases diff --git a/core/tasks/with-license.mk b/core/tasks/with-license.mk index d41e77a1ce..5ca974a1a0 100644 --- a/core/tasks/with-license.mk +++ b/core/tasks/with-license.mk @@ -20,7 +20,8 @@ ifeq ($(TARGET_BUILD_TYPE),debug) name := $(name)_debug endif -name := $(name)-flashable-$(FILE_NAME_TAG)-with-license +dist_name := $(name)-flashable-FILE_NAME_TAG_PLACEHOLDER-with-license +name := $(name)-flashable-with-license with_license_intermediates := \ $(call intermediates-dir-for,PACKAGING,with_license) @@ -42,6 +43,7 @@ $(call declare-1p-container,$(license_image_input_zip),build) $(call declare-container-deps,$(license_image_input_zip),$(BUILT_TARGET_FILES_PACKAGE)) with_license_zip := $(PRODUCT_OUT)/$(name).sh +dist_name := $(dist_name).sh $(with_license_zip): PRIVATE_NAME := $(name) $(with_license_zip): PRIVATE_INPUT_ZIP := $(license_image_input_zip) $(with_license_zip): PRIVATE_VENDOR_BLOBS_LICENSE := $(VENDOR_BLOBS_LICENSE) @@ -51,7 +53,7 @@ $(with_license_zip): $(HOST_OUT_EXECUTABLES)/generate-self-extracting-archive $(HOST_OUT_EXECUTABLES)/generate-self-extracting-archive $@ \ $(PRIVATE_INPUT_ZIP) $(PRIVATE_NAME) $(PRIVATE_VENDOR_BLOBS_LICENSE) with-license : $(with_license_zip) -$(call dist-for-goals, with-license, $(with_license_zip)) +$(call dist-for-goals, with-license, $(with_license_zip):$(dist_name)) $(call declare-1p-container,$(with_license_zip),) $(call declare-container-license-deps,$(with_license_zip),$(license_image_input_zip),$(with_license_zip):) diff --git a/core/version_util.mk b/core/version_util.mk index 0a452968b4..604c260828 100644 --- a/core/version_util.mk +++ b/core/version_util.mk @@ -246,21 +246,10 @@ DATE := date -d @$(BUILD_DATETIME) # to soong_ui. $(KATI_obsolete_var BUILD_DATETIME,Use BUILD_DATETIME_FROM_FILE) -HAS_BUILD_NUMBER := true -ifndef BUILD_NUMBER - # BUILD_NUMBER should be set to the source control value that - # represents the current state of the source code. E.g., a - # perforce changelist number or a git hash. Can be an arbitrary string - # (to allow for source control that uses something other than numbers), - # but must be a single word and a valid file name. - # - # If no BUILD_NUMBER is set, create a useful "I am an engineering build - # from this date/time" value. Make it start with a non-digit so that - # anyone trying to parse it as an integer will probably get "0". - BUILD_NUMBER := eng.$(shell echo $${BUILD_USERNAME:0:6}).$(shell $(DATE) +%Y%m%d.%H%M%S) +ifndef HAS_BUILD_NUMBER HAS_BUILD_NUMBER := false endif -.KATI_READONLY := BUILD_NUMBER HAS_BUILD_NUMBER +.KATI_READONLY := HAS_BUILD_NUMBER ifndef PLATFORM_MIN_SUPPORTED_TARGET_SDK_VERSION # Used to set minimum supported target sdk version. Apps targeting sdk diff --git a/packaging/distdir.mk b/packaging/distdir.mk index 264a8b098c..c9508af323 100644 --- a/packaging/distdir.mk +++ b/packaging/distdir.mk @@ -18,10 +18,12 @@ DIST_GOAL_OUTPUT_PAIRS := DIST_SRC_DST_PAIRS := include $(KATI_PACKAGE_MK_DIR)/dist.mk +FILE_NAME_TAG := $(file <$(OUT_DIR)/file_name_tag.txt) +.KATI_READONLY := FILE_NAME_TAG $(foreach pair,$(DIST_GOAL_OUTPUT_PAIRS), \ $(eval goal := $(call word-colon,1,$(pair))) \ - $(eval output := $(call word-colon,2,$(pair))) \ + $(eval output := $(subst FILE_NAME_TAG_PLACEHOLDER,$(FILE_NAME_TAG),$(call word-colon,2,$(pair)))) \ $(eval .PHONY: _dist_$$(goal)) \ $(if $(call streq,$(DIST),true),\ $(eval _dist_$$(goal): $$(DIST_DIR)/$$(output)), \ @@ -37,7 +39,7 @@ endef ifeq ($(DIST),true) $(foreach pair,$(DIST_SRC_DST_PAIRS), \ $(eval src := $(call word-colon,1,$(pair))) \ - $(eval dst := $(DIST_DIR)/$(call word-colon,2,$(pair))) \ + $(eval dst := $(subst FILE_NAME_TAG_PLACEHOLDER,$(FILE_NAME_TAG),$(DIST_DIR)/$(call word-colon,2,$(pair)))) \ $(eval $(call copy-one-dist-file,$(src),$(dst)))) endif From 85eb46d9935a460cf271457713b8d408907363b6 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Fri, 9 Jun 2023 18:51:00 -0700 Subject: [PATCH 14/85] Clean up the API for release config in starlark Also gets the json summaries working again. Bug: 283477392 Test: Manual Change-Id: Iaeb840e96bd7fef2fa1492cb55d9688f7ca75858 --- core/Makefile | 20 +++--- core/release_config.bzl | 153 ++++++++++++++++++++++++---------------- core/release_config.mk | 142 ++++++++++++++++++++++++++++--------- 3 files changed, 212 insertions(+), 103 deletions(-) diff --git a/core/Makefile b/core/Makefile index 9fa3b601bf..f19844f24d 100644 --- a/core/Makefile +++ b/core/Makefile @@ -27,26 +27,28 @@ $(eval $(strip $(1)): PRIVATE_OUT := $(strip $(1))) $(eval $(strip $(1)): PRIVATE_FLAG_NAMES := $(strip $(2))) $(strip $(1)): mkdir -p $$(dir $$(PRIVATE_OUT)) - ( \ - echo '{' ; \ - echo 'flags: [' ; \ - $$(foreach flag, $$(PRIVATE_FLAG_NAMES), \ + echo '{' > $$(PRIVATE_OUT) + echo '"flags": [' >> $$(PRIVATE_OUT) + $$(foreach flag, $$(PRIVATE_FLAG_NAMES), \ + ( \ printf ' { "name": "%s", "value": "%s", ' \ '$$(flag)' \ '$$(_ALL_RELEASE_FLAGS.$$(flag).VALUE)' \ ; \ - printf '"set": "%s", "default": "%s", "declared": "%s", }' \ + printf '"set": "%s", "default": "%s", "declared": "%s" }' \ '$$(_ALL_RELEASE_FLAGS.$$(flag).SET_IN)' \ '$$(_ALL_RELEASE_FLAGS.$$(flag).DEFAULT)' \ '$$(_ALL_RELEASE_FLAGS.$$(flag).DECLARED_IN)' \ ; \ printf '$$(if $$(filter $$(lastword $$(PRIVATE_FLAG_NAMES)),$$(flag)),,$$(comma))\n' ; \ - ) \ - echo "]" ; \ - echo "}" \ - ) >> $$(PRIVATE_OUT) + ) >> $$(PRIVATE_OUT) \ + ) + echo "]" >> $$(PRIVATE_OUT) + echo "}" >> $$(PRIVATE_OUT) endef +_FLAG_PARTITIONS := product system system_ext vendor + $(foreach partition, $(_FLAG_PARTITIONS), \ $(eval BUILD_FLAG_SUMMARIES.$(partition) \ := $(TARGET_OUT_FLAGS)/$(partition)/etc/build_flags.json) \ diff --git a/core/release_config.bzl b/core/release_config.bzl index ecb9ec6022..61d8853ba1 100644 --- a/core/release_config.bzl +++ b/core/release_config.bzl @@ -20,71 +20,104 @@ _flag_partitions = [ "vendor", ] -def _combine_dicts_no_duplicate_keys(dicts): - result = {} - for d in dicts: - for k, v in d.items(): - if k in result: - fail("Duplicate key: " + k) - result[k] = v - return result +ALL = ["all"] +PRODUCT = ["product"] +SYSTEM = ["system"] +SYSTEM_EXT = ["system_ext"] +VENDOR = ["vendor"] -def release_config(target_release, flag_definitions, config_maps, fail_if_no_release_config = True): - result = { - "_ALL_RELEASE_FLAGS": [flag.name for flag in flag_definitions], +_valid_types = ["NoneType", "bool", "list", "string", "int"] + +def flag(name, partitions, default): + "Declare a flag." + if not partitions: + fail("At least 1 partition is required") + if not name.startswith("RELEASE_"): + fail("Release flag names must start with RELEASE_") + if " " in name or "\t" in name or "\n" in name: + fail("Flag names must not contain whitespace: \"" + name + "\"") + for partition in partitions: + if partition == "all": + if len(partitions) > 1: + fail("\"all\" can't be combined with other partitions: " + str(partitions)) + elif partition not in _flag_partitions: + fail("Invalid partition: " + partition + ", allowed partitions: " + + str(_flag_partitions)) + if type(default) not in _valid_types: + fail("Invalid type of default for flag \"" + name + "\" (" + type(default) + ")") + return { + "name": name, + "partitions": partitions, + "default": default } - all_flags = {} - for flag in flag_definitions: - if sorted(dir(flag)) != ["default", "name", "partitions"]: - fail("Flag structs must contain 3 fields: name, partitions, and default") - if not flag.partitions: - fail("At least 1 partition is required") - for partition in flag.partitions: - if partition == "all": - if len(flag.partitions) > 1: - fail("\"all\" can't be combined with other partitions: " + str(flag.partitions)) - elif partition not in _flag_partitions: - fail("Invalid partition: " + flag.partition + ", allowed partitions: " + str(_flag_partitions)) - if not flag.name.startswith("RELEASE_"): - fail("Release flag names must start with RELEASE_") - if " " in flag.name or "\t" in flag.name or "\n" in flag.name: - fail("Flag names must not contain whitespace.") - if flag.name in all_flags: - fail("Duplicate declaration of flag " + flag.name) - all_flags[flag.name] = True - default = flag.default - if type(default) == "bool": - default = "true" if default else "" - result["_ALL_RELEASE_FLAGS." + flag.name + ".PARTITIONS"] = flag.partitions - result["_ALL_RELEASE_FLAGS." + flag.name + ".DEFAULT"] = default - result["_ALL_RELEASE_FLAGS." + flag.name + ".VALUE"] = default +def value(name, value): + "Define the flag value for a particular configuration." + return { + "name": name, + "value": value, + } - # If TARGET_RELEASE is set, fail if there is no matching release config - # If it isn't set, no release config files will be included and all flags - # will get their default values. - if target_release: - config_map = _combine_dicts_no_duplicate_keys(config_maps) - if target_release not in config_map: - fail("No release config found for TARGET_RELEASE: " + target_release + ". Available releases are: " + str(config_map.keys())) - release_config = config_map[target_release] - if sorted(dir(release_config)) != ["flags", "release_version"]: - fail("A release config must be a struct with a flags and release_version fields") - result["_RELEASE_VERSION"] = release_config.release_version - for flag in release_config.flags: - if sorted(dir(flag)) != ["name", "value"]: - fail("A flag must be a struct with name and value fields, got: " + str(sorted(dir(flag)))) - if flag.name not in all_flags: - fail("Undeclared build flag: " + flag.name) - value = flag.value - if type(value) == "bool": - value = "true" if value else "" - result["_ALL_RELEASE_FLAGS." + flag.name + ".VALUE"] = value - elif fail_if_no_release_config: - fail("FAIL_IF_NO_RELEASE_CONFIG was set and TARGET_RELEASE was not") + +def _format_value(val): + "Format the starlark type correctly for make" + if type(val) == "NoneType": + return "" + elif type(val) == "bool": + return "true" if val else "" else: - # No TARGET_RELEASE means release version 0 - result["_RELEASE_VERSION"] = 0 + return val + + +def release_config(all_flags, all_values): + "Return the make variables that should be set for this release config." + # Validate flags + flag_names = [] + for flag in all_flags: + if flag["name"] in flag_names: + fail(flag["declared_in"] + ": Duplicate declaration of flag " + flag["name"]) + flag_names.append(flag["name"]) + + # Record which flags go on which partition + partitions = {} + for flag in all_flags: + for partition in flag["partitions"]: + if partition == "all": + for partition in _flag_partitions: + partitions.setdefault(partition, []).append(flag["name"]) + else: + partitions.setdefault(partition, []).append(flag["name"]) + + # Validate values + values = {} + for value in all_values: + if value["name"] not in flag_names: + fail(value["set_in"] + ": Value set for undeclared build flag: " + value["name"]) + values[value["name"]] = value + + # Collect values + result = { + "_ALL_RELEASE_FLAGS": sorted(flag_names), + } + for partition, names in partitions.items(): + result["_ALL_RELEASE_FLAGS.PARTITIONS." + partition] = names + for flag in all_flags: + if flag["name"] in values: + val = values[flag["name"]]["value"] + set_in = values[flag["name"]]["set_in"] + if type(val) not in _valid_types: + fail("Invalid type of value for flag \"" + flag["name"] + "\" (" + type(val) + ")") + else: + val = flag["default"] + set_in = flag["declared_in"] + val = _format_value(val) + result[flag["name"]] = val + result["_ALL_RELEASE_FLAGS." + flag["name"] + ".PARTITIONS"] = flag["partitions"] + result["_ALL_RELEASE_FLAGS." + flag["name"] + ".DEFAULT"] = _format_value(flag["default"]) + result["_ALL_RELEASE_FLAGS." + flag["name"] + ".VALUE"] = val + result["_ALL_RELEASE_FLAGS." + flag["name"] + ".DECLARED_IN"] = flag["declared_in"] + result["_ALL_RELEASE_FLAGS." + flag["name"] + ".SET_IN"] = set_in return result + diff --git a/core/release_config.mk b/core/release_config.mk index ce57855aae..3cd8b4103b 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -12,6 +12,104 @@ # See the License for the specific language governing permissions and # limitations under the License. + +# ----------------------------------------------------------------- +# Choose the flag files +# ----------------------------------------------------------------- +# Do this first, because we're going to unset TARGET_RELEASE before +# including anyone, so they don't start making conditionals based on it. +# This logic is in make because starlark doesn't understand optional +# vendor files. + +# If this is a google source tree, restrict it to only the one file +# which has OWNERS control. If it isn't let others define their own. +# TODO: Remove wildcard for build/release one when all branch manifests +# have updated. +config_map_files := $(wildcard build/release/release_config_map.mk) \ + $(if $(wildcard vendor/google/release/release_config_map.mk), \ + vendor/google/release/release_config_map.mk, \ + $(sort \ + $(wildcard device/*/release/release_config_map.mk) \ + $(wildcard device/*/*/release/release_config_map.mk) \ + $(wildcard vendor/*/release/release_config_map.mk) \ + $(wildcard vendor/*/*/release/release_config_map.mk) \ + ) \ + ) + +# $1 config name +# $2 release config files +define declare-release-config + $(eval # No duplicates) + $(if $(filter $(_all_release_configs), $(strip $(1))), \ + $(error declare-release-config: config $(strip $(1)) declared in: $(_included) Previously declared here: $(_all_release_configs.$(strip $(1)).DECLARED_IN)) \ + ) + $(eval # Must have release config files) + $(if $(strip $(2)),, \ + $(error declare-release-config: config $(strip $(1)) must have release config files) \ + ) + $(eval _all_release_configs := $(sort $(_all_release_configs) $(strip $(1)))) + $(eval _all_release_configs.$(strip $(1)).DECLARED_IN := $(_included)) + $(eval _all_release_configs.$(strip $(1)).FILES := $(strip $(2))) +endef + +# Include the config map files +$(foreach f, $(config_map_files), \ + $(eval _included := $(f)) \ + $(eval include $(f)) \ +) + +# If TARGET_RELEASE is set, fail if there is no matching release config +# If it isn't set, no release config files will be included and all flags +# will get their default values. +ifneq ($(TARGET_RELEASE),) +ifeq ($(filter $(_all_release_configs), $(TARGET_RELEASE)),) + $(error No release config found for TARGET_RELEASE: $(TARGET_RELEASE). Available releases are: $(_all_release_configs)) +else + # Choose flag files + # Don't sort this, use it in the order they gave us. + flag_value_files := $(_all_release_configs.$(TARGET_RELEASE).FILES) +endif +else +# Useful for finding scripts etc that aren't passing or setting TARGET_RELEASE +ifneq ($(FAIL_IF_NO_RELEASE_CONFIG),) + $(error FAIL_IF_NO_RELEASE_CONFIG was set and TARGET_RELEASE was not) +endif +flag_value_files := +endif + +# Unset variables so they can't use them +define declare-release-config +$(error declare-release-config can only be called from inside release_config_map.mk files) +endef + +# TODO: Remove this check after enough people have sourced lunch that we don't +# need to worry about it trying to do get_build_vars TARGET_RELEASE. Maybe after ~9/2023 +ifneq ($(CALLED_FROM_SETUP),true) +define TARGET_RELEASE +$(error TARGET_RELEASE may not be accessed directly. Use individual flags.) +endef +else +TARGET_RELEASE:= +endif +.KATI_READONLY := TARGET_RELEASE + + +$(foreach config, $(_all_release_configs), \ + $(eval _all_release_configs.$(config).DECLARED_IN:= ) \ + $(eval _all_release_configs.$(config).FILES:= ) \ +) +_all_release_configs:= +config_map_files:= + + +# ----------------------------------------------------------------- +# Flag declarations and values +# ----------------------------------------------------------------- +# This part is in starlark. We generate a root starlark file that loads +# all of the flags declaration files that we found, and the flag_value_files +# that we chose from the config map above. Then we run that, and load the +# results of that into the make environment. + # If this is a google source tree, restrict it to only the one file # which has OWNERS control. If it isn't let others define their own. # TODO: Remove wildcard for build/release one when all branch manifests @@ -26,43 +124,25 @@ flag_declaration_files := $(wildcard build/release/build_flags.bzl) \ $(wildcard vendor/*/*/release/build_flags.bzl) \ ) \ ) -config_map_files := $(wildcard build/release/release_config_map.bzl) \ - $(if $(wildcard vendor/google/release/release_config_map.bzl), \ - vendor/google/release/release_config_map.bzl, \ - $(sort \ - $(wildcard device/*/release/release_config_map.bzl) \ - $(wildcard device/*/*/release/release_config_map.bzl) \ - $(wildcard vendor/*/release/release_config_map.bzl) \ - $(wildcard vendor/*/*/release/release_config_map.bzl) \ - ) \ - ) + # Because starlark can't find files with $(wildcard), write an entrypoint starlark script that # contains the result of the above wildcards for the starlark code to use. filename_to_starlark=$(subst /,_,$(subst .,_,$(1))) _c:=load("//build/make/core/release_config.bzl", "release_config") -_c+=$(foreach f,$(flag_declaration_files),$(newline)load("//$(f)", flags_$(call filename_to_starlark,$(f)) = "flags")) -_c+=$(foreach f,$(config_map_files),$(newline)load("//$(f)", config_maps_$(call filename_to_starlark,$(f)) = "config_maps")) -_c+=$(newline)all_flags = [] $(foreach f,$(flag_declaration_files),+ flags_$(call filename_to_starlark,$(f))) -_c+=$(newline)all_config_maps = [$(foreach f,$(config_map_files),config_maps_$(call filename_to_starlark,$(f))$(comma))] -_c+=$(newline)target_release = "$(TARGET_RELEASE)" -_c+=$(newline)fail_if_no_release_config = True if "$(FAIL_IF_NO_RELEASE_CONFIG)" else False -_c+=$(newline)variables_to_export_to_make = release_config(target_release, all_flags, all_config_maps, fail_if_no_release_config) +_c+=$(newline)def add(d, k, v): +_c+=$(newline)$(space)d = dict(d) +_c+=$(newline)$(space)d[k] = v +_c+=$(newline)$(space)return d +_c+=$(foreach f,$(flag_declaration_files),$(newline)load("$(f)", flags_$(call filename_to_starlark,$(f)) = "flags")) +_c+=$(newline)all_flags = [] $(foreach f,$(flag_declaration_files),+ [add(x, "declared_in", "$(f)") for x in flags_$(call filename_to_starlark,$(f))]) +_c+=$(foreach f,$(flag_value_files),$(newline)load("//$(f)", values_$(call filename_to_starlark,$(f)) = "values")) +_c+=$(newline)all_values = [] $(foreach f,$(flag_value_files),+ [add(x, "set_in", "$(f)") for x in values_$(call filename_to_starlark,$(f))]) +_c+=$(newline)variables_to_export_to_make = release_config(all_flags, all_values) $(file >$(OUT_DIR)/release_config_entrypoint.bzl,$(_c)) _c:= filename_to_starlark:= -# TODO: Remove this check after enough people have sourced lunch that we don't -# need to worry about it trying to do get_build_vars TARGET_RELEASE. Maybe after ~9/2023 -ifneq ($(CALLED_FROM_SETUP),true) -define TARGET_RELEASE -$(error TARGET_RELEASE may not be accessed directly. Use individual flags.) -endef -else -TARGET_RELEASE:= -endif -.KATI_READONLY := TARGET_RELEASE - # Exclude the entrypoint file as a dependency (by passing it as the 2nd argument) so that we don't # rerun kati every build. Kati will replay the $(file) command that generates it every build, # updating its timestamp. @@ -71,9 +151,3 @@ endif # outside of the source tree. $(call run-starlark,$(OUT_DIR)/release_config_entrypoint.bzl,$(OUT_DIR)/release_config_entrypoint.bzl,--allow_external_entrypoint) -# Set the flag values, and don't allow any one to modify them. -$(foreach flag, $(_ALL_RELEASE_FLAGS), \ - $(eval $(flag) := $(_ALL_RELEASE_FLAGS.$(flag).VALUE)) \ - $(eval .KATI_READONLY := $(flag)) \ -) - From 22b1c022c92ee011c424c07520a25d3de95afb1f Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Mon, 5 Jun 2023 16:43:55 -0700 Subject: [PATCH 15/85] Make RELEASE_PLATFORM_VERSION a release config flag to set platform version. Bug: 282838389 Test: Treehugger Change-Id: Ic6dacbdee7d2408aa8b25b4df59bf9bbc566d747 --- core/envsetup.mk | 4 ++-- core/version_defaults.mk | 3 +-- core/version_util.mk | 10 +++++----- tests/lunch_tests.sh | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/envsetup.mk b/core/envsetup.mk index 3e19198557..f5a2022cda 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -66,7 +66,7 @@ $(strip \ $(if $(filter $(ALL_VERSIONS),$(2)),, $(error Invalid MAX_PLATFORM_VERSION '$(2)')) $(if $(filter $(ALL_VERSIONS),$(3)),, - $(error Invalid DEFAULT_PLATFORM_VERSION '$(3)')) + $(error Invalid RELEASE_PLATFORM_VERSION '$(3)')) $(eval allowed_versions_ := $(call find_and_earlier,$(ALL_VERSIONS),$(2))) @@ -77,7 +77,7 @@ $(strip \ $(filter-out $(call find_and_earlier,$(allowed_versions_),$(1)),$(allowed_versions_))) $(if $(filter $(allowed_versions_),$(3)),, - $(error DEFAULT_PLATFORM_VERSION '$(3)' must be between MIN_PLATFORM_VERSION '$(1)' and MAX_PLATFORM_VERSION '$(2)')) + $(error RELEASE_PLATFORM_VERSION '$(3)' must be between MIN_PLATFORM_VERSION '$(1)' and MAX_PLATFORM_VERSION '$(2)')) $(allowed_versions_)) endef diff --git a/core/version_defaults.mk b/core/version_defaults.mk index 4d1e3dfb0a..69e70511e0 100644 --- a/core/version_defaults.mk +++ b/core/version_defaults.mk @@ -40,8 +40,7 @@ ifdef INTERNAL_BUILD_ID_MAKEFILE include $(INTERNAL_BUILD_ID_MAKEFILE) endif -DEFAULT_PLATFORM_VERSION := VP1A -.KATI_READONLY := DEFAULT_PLATFORM_VERSION +# Set release configuration. The default resides in build/release/build_flags.mk. MIN_PLATFORM_VERSION := UP1A MAX_PLATFORM_VERSION := VP1A diff --git a/core/version_util.mk b/core/version_util.mk index 604c260828..f37f2d7c2d 100644 --- a/core/version_util.mk +++ b/core/version_util.mk @@ -14,17 +14,17 @@ # limitations under the License. # -# - ALLOWED_VERSIONS := $(call allowed-platform-versions,\ $(MIN_PLATFORM_VERSION),\ $(MAX_PLATFORM_VERSION),\ - $(DEFAULT_PLATFORM_VERSION)) + $(RELEASE_PLATFORM_VERSION)) -ifndef TARGET_PLATFORM_VERSION - TARGET_PLATFORM_VERSION := $(DEFAULT_PLATFORM_VERSION) +ifdef TARGET_PLATFORM_VERSION + $(error Do not set TARGET_PLATFORM_VERSION directly. Use RELEASE_PLATFORM_VERSION. value: $(TARGET_PLATFORM_VERSION)) endif +TARGET_PLATFORM_VERSION := $(RELEASE_PLATFORM_VERSION) + ifeq (,$(filter $(ALLOWED_VERSIONS), $(TARGET_PLATFORM_VERSION))) $(warning Invalid TARGET_PLATFORM_VERSION '$(TARGET_PLATFORM_VERSION)', must be one of) $(error $(ALLOWED_VERSIONS)) diff --git a/tests/lunch_tests.sh b/tests/lunch_tests.sh index 4285d13cc4..9b142ee6ab 100755 --- a/tests/lunch_tests.sh +++ b/tests/lunch_tests.sh @@ -28,7 +28,7 @@ function check_lunch [ "$TARGET_PLATFORM_VERSION" = "$4" ] || ( echo "lunch $1: expected TARGET_PLATFORM_VERSION='$4', got '$TARGET_PLATFORM_VERSION'" && exit 1 ) ) -default_version=$(get_build_var DEFAULT_PLATFORM_VERSION) +default_version=$(get_build_var RELEASE_PLATFORM_VERSION) # lunch tests check_lunch "aosp_arm64" "aosp_arm64" "eng" "" From 9afc20f110522f62f9ba7d8840c76f2db2754c69 Mon Sep 17 00:00:00 2001 From: Mitch Phillips Date: Mon, 26 Jun 2023 08:08:55 +0000 Subject: [PATCH 16/85] Merge "[MTE] [gnu make] Add memtag_globals as a sanitizer target." am: 61ce7afb21 am: 49211348ea am: c6076a3bb6 Original change: https://android-review.googlesource.com/c/platform/build/+/2625936 Bug: b/288828741 1. There was a topic that contained this build system glue, and a dependent change in external/cronet. 2. external/cronet is setup to automerge into udc-mainline-prod from aosp. 3. The build system isn't. 4. Boom because of the missing dependency. The build system glue should be low-risk, and I'd like to unbrick the build, and so merging this here on the desires of the cronet team. Follow ups to come in that bug. Change-Id: I3ab9dd553e2d83c5cffbf0744f9c298b1ce766db Merged-In: I44c239ba907a90a355c46e12afbbbe96bb2e4426 Signed-off-by: Automerger Merge Worker (cherry picked from commit c77b68f30d9ccf2ec122ad20952dff7119a14538) --- core/config_sanitizers.mk | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk index ebce4c2a4e..9823d7d521 100644 --- a/core/config_sanitizers.mk +++ b/core/config_sanitizers.mk @@ -176,6 +176,7 @@ endif ifneq ($(filter address,$(my_sanitize)),) my_sanitize := $(filter-out cfi,$(my_sanitize)) my_sanitize := $(filter-out memtag_stack,$(my_sanitize)) + my_sanitize := $(filter-out memtag_globals,$(my_sanitize)) my_sanitize := $(filter-out memtag_heap,$(my_sanitize)) my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag)) endif @@ -183,8 +184,8 @@ endif # Disable memtag for host targets. Host executables in AndroidMk files are # deprecated, but some partners still have them floating around. ifdef LOCAL_IS_HOST_MODULE - my_sanitize := $(filter-out memtag_heap memtag_stack,$(my_sanitize)) - my_sanitize_diag := $(filter-out memtag_heap memtag_stack,$(my_sanitize_diag)) + my_sanitize := $(filter-out memtag_heap memtag_stack memtag_globals,$(my_sanitize)) + my_sanitize_diag := $(filter-out memtag_heap memtag_stack memtag_globals,$(my_sanitize_diag)) endif # Disable sanitizers which need the UBSan runtime for host targets. @@ -219,11 +220,13 @@ ifneq ($(filter arm x86 x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),) my_sanitize := $(filter-out hwaddress,$(my_sanitize)) my_sanitize := $(filter-out memtag_heap,$(my_sanitize)) my_sanitize := $(filter-out memtag_stack,$(my_sanitize)) + my_sanitize := $(filter-out memtag_globals,$(my_sanitize)) endif ifneq ($(filter hwaddress,$(my_sanitize)),) my_sanitize := $(filter-out address,$(my_sanitize)) my_sanitize := $(filter-out memtag_stack,$(my_sanitize)) + my_sanitize := $(filter-out memtag_globals,$(my_sanitize)) my_sanitize := $(filter-out memtag_heap,$(my_sanitize)) my_sanitize := $(filter-out thread,$(my_sanitize)) my_sanitize := $(filter-out cfi,$(my_sanitize)) @@ -240,7 +243,7 @@ ifneq ($(filter hwaddress,$(my_sanitize)),) endif endif -ifneq ($(filter memtag_heap memtag_stack,$(my_sanitize)),) +ifneq ($(filter memtag_heap memtag_stack memtag_globals,$(my_sanitize)),) ifneq ($(filter memtag_heap,$(my_sanitize_diag)),) my_cflags += -fsanitize-memtag-mode=sync my_sanitize_diag := $(filter-out memtag_heap,$(my_sanitize_diag)) @@ -269,6 +272,14 @@ ifneq ($(filter memtag_stack,$(my_sanitize)),) my_sanitize := $(filter-out memtag_stack,$(my_sanitize)) endif +ifneq ($(filter memtag_globals,$(my_sanitize)),) + my_cflags += -fsanitize=memtag-globals + # TODO(mitchp): For now, enable memtag-heap with memtag-globals because the + # linker isn't new enough + # (https://reviews.llvm.org/differential/changeset/?ref=4243566). + my_sanitize := $(filter-out memtag_globals,$(my_sanitize)) +endif + # TSAN is not supported on 32-bit architectures. For non-multilib cases, make # its use an error. For multilib cases, don't use it for the 32-bit case. ifneq ($(filter thread,$(my_sanitize)),) From 23c36d95196b7a5ebca2ee7c81a1ee169a912667 Mon Sep 17 00:00:00 2001 From: Mark White Date: Mon, 26 Jun 2023 13:07:30 +0000 Subject: [PATCH 17/85] m framework-minus-apex should not build services Bug: 288868053 Test: verified services not built in build.trace.gz Ignore-AOSP-First: change in topic with internal-first projects Change-Id: I9ab58d551a7446e328412af27a94d760d6f0cb67 --- target/product/base_system.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/target/product/base_system.mk b/target/product/base_system.mk index 617e34b400..14ed3a33f0 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -97,6 +97,7 @@ PRODUCT_PACKAGES += \ flags_health_check \ framework-graphics \ framework-minus-apex \ + framework-minus-apex-install-dependencies \ framework-res \ framework-sysconfig.xml \ fsck.erofs \ From 4741a4efe9349050e2ce21a7e9f17927128ad00c Mon Sep 17 00:00:00 2001 From: Chuong Hoang Date: Fri, 30 Jun 2023 04:44:23 +0000 Subject: [PATCH 18/85] Add brightness-related `TARGET_RECOVERY_UI_` properties Bug: 221048336 Test: combined with the other CL in same topic, observed recovery brightness updated correctly according to variables set in BoardConfig. (cherry picked from https://android-review.googlesource.com/q/commit:b684a13c1c85772bb9547f1d9481609d73fc6d54) Merged-In: Iebad0753079414a5e11bce04008ee405c8d03580 Change-Id: Iebad0753079414a5e11bce04008ee405c8d03580 --- core/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/Makefile b/core/Makefile index b32be0ab8e..38ea1494ed 100644 --- a/core/Makefile +++ b/core/Makefile @@ -2471,7 +2471,11 @@ $(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \ TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \ TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \ TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \ - TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset + TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset \ + TARGET_RECOVERY_UI_BRIGHTNESS_FILE:brightness_file \ + TARGET_RECOVERY_UI_MAX_BRIGHTNESS_FILE:max_brightness_file \ + TARGET_RECOVERY_UI_BRIGHTNESS_NORMAL:brightness_normal_percent \ + TARGET_RECOVERY_UI_BRIGHTNESS_DIMMED:brightness_dimmed_percent # Parses the given list of build variables and writes their values as build properties if defined. # For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`, From 015a2c6dfc16467c426cf01f0c6ed3312c55122e Mon Sep 17 00:00:00 2001 From: Gurpreet Singh Date: Fri, 7 Jul 2023 16:46:33 +0000 Subject: [PATCH 19/85] Bump SDK Extension version to 8 This bump includes Adservices, Extservices and Mediaprovider. Bug: 290366486 Test: The build passes Ignore-AOSP-first: SDKs are finalized outside of AOSP Change-Id: I91e49cbd1b3a1abc30a9dfcf76980d5205292c76 --- core/version_defaults.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/version_defaults.mk b/core/version_defaults.mk index 8dc425760f..4442b10729 100644 --- a/core/version_defaults.mk +++ b/core/version_defaults.mk @@ -79,7 +79,7 @@ endif .KATI_READONLY := PLATFORM_SDK_VERSION # This is the sdk extension version of this tree. -PLATFORM_SDK_EXTENSION_VERSION := 7 +PLATFORM_SDK_EXTENSION_VERSION := 8 .KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION # This is the sdk extension version that PLATFORM_SDK_VERSION ships with. From f0898eae0755cf5c66a72dda14aab28760e51639 Mon Sep 17 00:00:00 2001 From: Amith Dsouza Date: Mon, 10 Jul 2023 14:53:40 +0000 Subject: [PATCH 20/85] Update BUILD_ID Master branch has been renamed to main, the build id needs to reflect this change. Ignore-AOSP-First: Merge conflict resolutions Bug: 290400015 Change-Id: I740ef3225c4c291ef7313d3ff1fe5d78389497f5 --- core/build_id.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/build_id.mk b/core/build_id.mk index 2f9c3f3bf1..bed839f57c 100644 --- a/core/build_id.mk +++ b/core/build_id.mk @@ -18,4 +18,4 @@ # (like "CRB01"). It must be a single word, and is # capitalized by convention. -BUILD_ID=MASTER +BUILD_ID=MAIN From 722ff3a64d04247c430bb274585b13d36f70e66e Mon Sep 17 00:00:00 2001 From: Gurpreet Singh Date: Wed, 12 Jul 2023 15:33:44 +0000 Subject: [PATCH 21/85] Revert "Bump SDK Extension version to 8" Revert submission 23984964-ext-v8 Reason for revert: Adservices API surface has changed. Hence, need to re-do the finalization with the new API surface. Reverted changes: /q/submissionid:23984964-ext-v8 Change-Id: I273a26c00f764862e742be0d93eccef21d317eb7 --- core/version_defaults.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/version_defaults.mk b/core/version_defaults.mk index 4442b10729..8dc425760f 100644 --- a/core/version_defaults.mk +++ b/core/version_defaults.mk @@ -79,7 +79,7 @@ endif .KATI_READONLY := PLATFORM_SDK_VERSION # This is the sdk extension version of this tree. -PLATFORM_SDK_EXTENSION_VERSION := 8 +PLATFORM_SDK_EXTENSION_VERSION := 7 .KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION # This is the sdk extension version that PLATFORM_SDK_VERSION ships with. From e3578da5888243613d561acc37256ee7335f0396 Mon Sep 17 00:00:00 2001 From: Gurpreet Singh Date: Thu, 13 Jul 2023 16:04:27 +0000 Subject: [PATCH 22/85] Bump SDK Extension version to 8 This bump includes Adservices, Extservices and Mediaprovider. Bug: 290366486 Test: The build passes Ignore-AOSP-first: SDKs are finalized outside of AOSP Change-Id: I01564c7bccb63f328752bd3d0e70cebfafa560db --- core/version_defaults.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/version_defaults.mk b/core/version_defaults.mk index 8dc425760f..4442b10729 100644 --- a/core/version_defaults.mk +++ b/core/version_defaults.mk @@ -79,7 +79,7 @@ endif .KATI_READONLY := PLATFORM_SDK_VERSION # This is the sdk extension version of this tree. -PLATFORM_SDK_EXTENSION_VERSION := 7 +PLATFORM_SDK_EXTENSION_VERSION := 8 .KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION # This is the sdk extension version that PLATFORM_SDK_VERSION ships with. From 762ff79970099b46c05c03f21c765d17bd29a996 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 23 Jun 2023 16:17:54 -0700 Subject: [PATCH 23/85] Support transitive resource packages from Soong Soong is improving resource handling by not squashing resources from all dependencies into every android_library. This causes problems when the android_library is exported to Make, as Make is still using the old squashing behavior. Add a file to every static java library that lists the resource packages of its transitive dependencies. For modules defined in Andorid.mk files leave the file empty, but for Soong modules populate it with the list of transtiive dependencies. Pass the contents all of the files from direct dependencies to aapt2 link to include any transitive dependencies. Ignore-AOSP-First: merge conflict Bug: 284023594 Test: m Dialer Change-Id: I4e8ace497d701a9645a62dd5a6ac12e9a6830dcf --- core/aapt2.mk | 5 ++++- core/clear_vars.mk | 1 + core/definitions.mk | 2 ++ core/soong_java_prebuilt.mk | 11 +++++++++++ core/static_java_library.mk | 6 ++++++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/core/aapt2.mk b/core/aapt2.mk index 7b17df4a9c..0e23477967 100644 --- a/core/aapt2.mk +++ b/core/aapt2.mk @@ -68,6 +68,8 @@ $(my_res_resources_flat) $(my_overlay_resources_flat) $(my_resources_flata) $(my # support for it. my_static_library_resources := $(foreach l, $(call reverse-list,$(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),\ $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/package-res.apk) +my_static_library_transitive_resource_packages_lists := $(foreach l, $(call reverse-list,$(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),\ + $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/transitive-res-packages) my_static_library_extra_packages := $(foreach l, $(call reverse-list,$(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),\ $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/extra_packages) my_shared_library_resources := $(foreach l, $(LOCAL_SHARED_ANDROID_LIBRARIES),\ @@ -95,6 +97,7 @@ $(my_res_package): PRIVATE_ASSET_DIRS := $(my_asset_dirs) $(my_res_package): PRIVATE_JAVA_GEN_DIR := $(intermediates.COMMON)/aapt2 $(my_res_package): PRIVATE_SRCJAR := $(my_srcjar) $(my_res_package): PRIVATE_STATIC_LIBRARY_EXTRA_PACKAGES := $(my_static_library_extra_packages) +$(my_res_package): PRIVATE_STATIC_LIBRARY_TRANSITIVE_RES_PACKAGES_LISTS := $(my_static_library_transitive_resource_packages_lists) $(my_res_package): PRIVATE_AAPT_EXTRA_PACKAGES := $(aapt_extra_packages) $(my_res_package): .KATI_IMPLICIT_OUTPUTS := $(my_srcjar) $(aapt_extra_packages) @@ -117,7 +120,7 @@ ifdef proguard_options_file $(my_res_package): .KATI_IMPLICIT_OUTPUTS += $(proguard_options_file) endif -$(my_res_package): $(full_android_manifest) $(my_static_library_resources) $(my_shared_library_resources) +$(my_res_package): $(full_android_manifest) $(my_static_library_resources) $(my_static_library_transitive_resource_packages_lists) $(my_shared_library_resources) $(my_res_package): $(my_full_asset_paths) $(my_res_package): $(my_res_resources_flat) $(my_overlay_resources_flat) \ $(my_resources_flata) $(my_static_library_resources) $(my_static_library_extra_packages) \ diff --git a/core/clear_vars.mk b/core/clear_vars.mk index bb7ba1b377..ef3263aeb0 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -297,6 +297,7 @@ LOCAL_SOONG_MODULE_TYPE := LOCAL_SOONG_PROGUARD_DICT := LOCAL_SOONG_PROGUARD_USAGE_ZIP := LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE := +LOCAL_SOONG_TRANSITIVE_RES_PACKAGES := LOCAL_SOONG_DEVICE_RRO_DIRS := LOCAL_SOONG_PRODUCT_RRO_DIRS := LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES := diff --git a/core/definitions.mk b/core/definitions.mk index 2484f1e053..462c9689c9 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2377,6 +2377,7 @@ rm -rf $(PRIVATE_JAVA_GEN_DIR) mkdir -p $(PRIVATE_JAVA_GEN_DIR) $(call dump-words-to-file,$(PRIVATE_RES_FLAT),$(dir $@)aapt2-flat-list) $(call dump-words-to-file,$(PRIVATE_OVERLAY_FLAT),$(dir $@)aapt2-flat-overlay-list) +cat $(PRIVATE_STATIC_LIBRARY_TRANSITIVE_RES_PACKAGES_LISTS) | sort -u | tr '\n' ' ' > $(dir $@)aapt2-transitive-overlay-list $(hide) $(AAPT2) link -o $@ \ $(PRIVATE_AAPT_FLAGS) \ $(if $(PRIVATE_STATIC_LIBRARY_EXTRA_PACKAGES),$$(cat $(PRIVATE_STATIC_LIBRARY_EXTRA_PACKAGES))) \ @@ -2396,6 +2397,7 @@ $(hide) $(AAPT2) link -o $@ \ $(addprefix --rename-manifest-package ,$(PRIVATE_MANIFEST_PACKAGE_NAME)) \ $(addprefix --rename-instrumentation-target-package ,$(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \ -R \@$(dir $@)aapt2-flat-overlay-list \ + -R \@$(dir $@)aapt2-transitive-overlay-list \ \@$(dir $@)aapt2-flat-list $(SOONG_ZIP) -o $(PRIVATE_SRCJAR) -C $(PRIVATE_JAVA_GEN_DIR) -D $(PRIVATE_JAVA_GEN_DIR) $(EXTRACT_JAR_PACKAGES) -i $(PRIVATE_SRCJAR) -o $(PRIVATE_AAPT_EXTRA_PACKAGES) --prefix '--extra-packages ' diff --git a/core/soong_java_prebuilt.mk b/core/soong_java_prebuilt.mk index a8f475fd9a..c7c6a119dd 100644 --- a/core/soong_java_prebuilt.mk +++ b/core/soong_java_prebuilt.mk @@ -99,6 +99,17 @@ ifdef LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_res_package)) + my_transitive_res_packages := $(intermediates.COMMON)/transitive-res-packages + $(my_transitive_res_packages): PRIVATE_TRANSITIVE_RES_PACKAGES := $(filter-out $(LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE),$(LOCAL_SOONG_TRANSITIVE_RES_PACKAGES)) + $(my_transitive_res_packages): + @echo Write transitive resource package list $@ + rm -f $@ + touch $@ + $(foreach f,$(PRIVATE_TRANSITIVE_RES_PACKAGES),\ + echo "$f" >> $@; ) + + $(call add-dependency,$(my_res_package),$(my_transitive_res_packages)) + my_proguard_flags := $(intermediates.COMMON)/export_proguard_flags $(my_proguard_flags): $(LOCAL_SOONG_EXPORT_PROGUARD_FLAGS) @echo "Export proguard flags: $@" diff --git a/core/static_java_library.mk b/core/static_java_library.mk index 4053985a3a..4a72a1fc31 100644 --- a/core/static_java_library.mk +++ b/core/static_java_library.mk @@ -127,6 +127,12 @@ framework_res_package_export := \ endif endif +# transitive-res-packages is only populated for Soong modules for now, but needs +# to exist so that other Make modules can depend on it. Create an empty file. +my_transitive_res_packages := $(intermediates.COMMON)/transitive-res-packages +$(my_transitive_res_packages): + touch $@ + import_proguard_flag_files := $(strip $(foreach l,$(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\ $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/export_proguard_flags)) $(intermediates.COMMON)/export_proguard_flags: $(import_proguard_flag_files) $(addprefix $(LOCAL_PATH)/,$(LOCAL_EXPORT_PROGUARD_FLAG_FILES)) From d4639705bdf86c8b8c1607719eab4f5791e236fe Mon Sep 17 00:00:00 2001 From: Hung-ying Tyan Date: Fri, 14 Jul 2023 08:56:17 +0000 Subject: [PATCH 24/85] GSI: add VNDK 34/remove VNDK 29 Ignore-AOSP-First: Android U hasn't been published to AOSP yet Bug: 291204040 Test: boot GSI on U Pixel Change-Id: I04c50ca03a6ebd9b371a35f66faf5ea7861c6ca5 --- target/product/gsi_release.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/product/gsi_release.mk b/target/product/gsi_release.mk index e39af92ae5..fbd07dbab6 100644 --- a/target/product/gsi_release.mk +++ b/target/product/gsi_release.mk @@ -60,11 +60,11 @@ PRODUCT_COPY_FILES += \ # Support additional VNDK snapshots PRODUCT_EXTRA_VNDK_VERSIONS := \ - 29 \ 30 \ 31 \ 32 \ 33 \ + 34 \ # Do not build non-GSI partition images. PRODUCT_BUILD_CACHE_IMAGE := false From 17cde0f0821cd3872244abcbb6ed0c68d47882b6 Mon Sep 17 00:00:00 2001 From: My Name Date: Thu, 3 Aug 2023 04:43:52 +0000 Subject: [PATCH 25/85] Bump SDK Extension version to 9 This bump includes adServices. Bug: 294222367 Test: The build passes Ignore-AOSP-first: Finalization is not performed in AOSP Change-Id: Ifd08720db98a36e8140b3b2e10b710c531a456b4 --- core/version_defaults.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/version_defaults.mk b/core/version_defaults.mk index c5a7f42182..5470a471e9 100644 --- a/core/version_defaults.mk +++ b/core/version_defaults.mk @@ -79,7 +79,7 @@ endif .KATI_READONLY := PLATFORM_SDK_VERSION # This is the sdk extension version of this tree. -PLATFORM_SDK_EXTENSION_VERSION := 8 +PLATFORM_SDK_EXTENSION_VERSION := 9 .KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION # This is the sdk extension version that PLATFORM_SDK_VERSION ships with. From 38bd8b10f998e4df37e33e359b28cb2fe635cad6 Mon Sep 17 00:00:00 2001 From: Carlos Martinez Romero Date: Thu, 3 Aug 2023 18:43:05 +0000 Subject: [PATCH 26/85] Add sfdo to the build. Bug: 269188249 Test: Built and run it. Ignore-AOSP-First: sfdo is developed on main as it depends on surfaceflinger which is developed on that branch Change-Id: Ief58aa028adca7adfec8d3f97fef2f6b4925dae3 --- target/product/base_system.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/target/product/base_system.mk b/target/product/base_system.mk index 889fc9f5af..51e8abc6f5 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -265,6 +265,7 @@ PRODUCT_PACKAGES += \ services \ settings \ SettingsProvider \ + sfdo \ sgdisk \ Shell \ shell_and_utilities_system \ From 3678d665ecf7063b1664357827ac85323acdb554 Mon Sep 17 00:00:00 2001 From: Jigar Thakkar Date: Fri, 11 Aug 2023 18:51:55 +0000 Subject: [PATCH 27/85] Prevent pre-installation of platform apps on private space This change adds do-not-install tags for certain platform apps to stop pre-installing them in private space. Ignore-AOSP-First: Changes in topics with internal-only projects Bug: 289017904 Test: Manually tested on device Change-Id: I2195b727c9cb4bc713a31f41d9e7537c379c6405 --- .../sysconfig/preinstalled-packages-platform-aosp-product.xml | 1 + .../preinstalled-packages-platform-generic-system.xml | 1 + .../preinstalled-packages-platform-handheld-product.xml | 4 ++++ .../preinstalled-packages-platform-telephony-product.xml | 1 + 4 files changed, 7 insertions(+) diff --git a/target/product/sysconfig/preinstalled-packages-platform-aosp-product.xml b/target/product/sysconfig/preinstalled-packages-platform-aosp-product.xml index 1295e1c726..d3e2808ada 100644 --- a/target/product/sysconfig/preinstalled-packages-platform-aosp-product.xml +++ b/target/product/sysconfig/preinstalled-packages-platform-aosp-product.xml @@ -27,5 +27,6 @@ + diff --git a/target/product/sysconfig/preinstalled-packages-platform-generic-system.xml b/target/product/sysconfig/preinstalled-packages-platform-generic-system.xml index e2482e1ad3..ef8056f16b 100644 --- a/target/product/sysconfig/preinstalled-packages-platform-generic-system.xml +++ b/target/product/sysconfig/preinstalled-packages-platform-generic-system.xml @@ -24,6 +24,7 @@ + diff --git a/target/product/sysconfig/preinstalled-packages-platform-handheld-product.xml b/target/product/sysconfig/preinstalled-packages-platform-handheld-product.xml index 54add22f75..536c35b671 100644 --- a/target/product/sysconfig/preinstalled-packages-platform-handheld-product.xml +++ b/target/product/sysconfig/preinstalled-packages-platform-handheld-product.xml @@ -29,6 +29,7 @@ + @@ -42,6 +43,7 @@ + @@ -56,6 +58,7 @@ + @@ -64,6 +67,7 @@ + diff --git a/target/product/sysconfig/preinstalled-packages-platform-telephony-product.xml b/target/product/sysconfig/preinstalled-packages-platform-telephony-product.xml index cc1c135fd7..67a2a01c1c 100644 --- a/target/product/sysconfig/preinstalled-packages-platform-telephony-product.xml +++ b/target/product/sysconfig/preinstalled-packages-platform-telephony-product.xml @@ -24,6 +24,7 @@ + From a7044079e2dca46166cd94df15c25b33eb47c879 Mon Sep 17 00:00:00 2001 From: Harshit Mahajan Date: Tue, 15 Aug 2023 13:36:36 +0000 Subject: [PATCH 28/85] [CrashRecovery] Add module to BCP and SSCP Adding framework-crashrecovery to Bootclasspath and service-crashrecovery to System Server Classpath. Bug: b/289203818 Test: NA Ignore-AOSP-First: Module will be currently built internally Change-Id: I488730c04ba361955344f2c41a265836923307a6 --- target/product/base_system.mk | 1 + target/product/default_art_config.mk | 2 ++ 2 files changed, 3 insertions(+) diff --git a/target/product/base_system.mk b/target/product/base_system.mk index 889fc9f5af..038b8cc61a 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -55,6 +55,7 @@ PRODUCT_PACKAGES += \ com.android.btservices \ com.android.configinfrastructure \ com.android.conscrypt \ + com.android.crashrecovery \ com.android.devicelock \ com.android.extservices \ com.android.healthfitness \ diff --git a/target/product/default_art_config.mk b/target/product/default_art_config.mk index 2f32310489..251ad74d48 100644 --- a/target/product/default_art_config.mk +++ b/target/product/default_art_config.mk @@ -65,6 +65,7 @@ PRODUCT_APEX_BOOT_JARS := \ com.android.btservices:framework-bluetooth \ com.android.configinfrastructure:framework-configinfrastructure \ com.android.conscrypt:conscrypt \ + com.android.crashrecovery:framework-crashrecovery \ com.android.devicelock:framework-devicelock \ com.android.healthfitness:framework-healthfitness \ com.android.i18n:core-icu4j \ @@ -93,6 +94,7 @@ PRODUCT_APEX_SYSTEM_SERVER_JARS := \ com.android.appsearch:service-appsearch \ com.android.art:service-art \ com.android.configinfrastructure:service-configinfrastructure \ + com.android.crashrecovery:service-crashrecovery \ com.android.healthfitness:service-healthfitness \ com.android.media:service-media-s \ com.android.ondevicepersonalization:service-ondevicepersonalization \ From d7d9884f179f5408de48ba2bc1f9bd6a31d7d4b7 Mon Sep 17 00:00:00 2001 From: Mark White Date: Sun, 6 Aug 2023 00:11:10 +0000 Subject: [PATCH 29/85] Created empty framework-location non-updatable module Ignore-AOSP-First: Change in topic with internal-first projects Bug: 289776578 Test: presubmit Change-Id: I4955fdb127830fecf1f24e027c9bfaeaa87fc8c2 --- target/product/base_system.mk | 1 + target/product/default_art_config.mk | 1 + 2 files changed, 2 insertions(+) diff --git a/target/product/base_system.mk b/target/product/base_system.mk index 889fc9f5af..171c686c31 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -96,6 +96,7 @@ PRODUCT_PACKAGES += \ ExtShared \ flags_health_check \ framework-graphics \ + framework-location \ framework-minus-apex \ framework-minus-apex-install-dependencies \ framework-res \ diff --git a/target/product/default_art_config.mk b/target/product/default_art_config.mk index 2f32310489..0f05092c2f 100644 --- a/target/product/default_art_config.mk +++ b/target/product/default_art_config.mk @@ -50,6 +50,7 @@ PRODUCT_TEST_ONLY_ART_BOOT_IMAGE_JARS := \ PRODUCT_BOOT_JARS += \ framework-minus-apex \ framework-graphics \ + framework-location \ ext \ telephony-common \ voip-common \ From 8a2e3c9b9143057d7bfee7378e64f11d58a4989e Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Thu, 24 Aug 2023 12:07:37 -0700 Subject: [PATCH 30/85] Remove vndk-29 symlinks from allowlist ag/24061450 removed version 29 from PRODUCT_EXTRA_VNDK_VERSIONS on internal only, meaning these symlinks aren't generated anymore. Ignore-AOSP-First: To match ag/24061450 Fixes: 296972684 Test: lunch gsi_tv_arm-userdebug, m nothing Change-Id: If9dfb9cafb6cf1a65df1af5b444c9b0b9c61bfe7 --- target/product/gsi_release.mk | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/target/product/gsi_release.mk b/target/product/gsi_release.mk index df5017c25a..836d3cd028 100644 --- a/target/product/gsi_release.mk +++ b/target/product/gsi_release.mk @@ -32,11 +32,7 @@ BUILDING_GSI := true # and the vndk apex's compat symlinks PRODUCT_ARTIFACT_PATH_REQUIREMENT_ALLOWED_LIST += \ system/product/% \ - system/system_ext/% \ - system/lib/vndk-29 \ - system/lib/vndk-sp-29 \ - system/lib64/vndk-29 \ - system/lib64/vndk-sp-29 + system/system_ext/% # GSI should always support up-to-date platform features. # Keep this value at the latest API level to ensure latest build system From e30a7397580405e509a60c4aa257c3e6731f1e0f Mon Sep 17 00:00:00 2001 From: My Name Date: Thu, 31 Aug 2023 17:34:55 +0000 Subject: [PATCH 31/85] Bump SDK Extension version to 10 This bump includes HealthConnect, Tethering, AppSearch and AdServices Bug: 298437362 Test: The build passes Ignore-AOSP-first: Finalization is not performed in AOSP Change-Id: I3251856e69722cc06da543d5e3535e9d7701eeb8 --- core/version_defaults.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/version_defaults.mk b/core/version_defaults.mk index 773a8fd171..77957d2bd4 100644 --- a/core/version_defaults.mk +++ b/core/version_defaults.mk @@ -79,7 +79,7 @@ endif .KATI_READONLY := PLATFORM_SDK_VERSION # This is the sdk extension version of this tree. -PLATFORM_SDK_EXTENSION_VERSION := 9 +PLATFORM_SDK_EXTENSION_VERSION := 10 .KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION # This is the sdk extension version that PLATFORM_SDK_VERSION ships with. From f3f27c5936d090626763ac03c2851c9686c9dce4 Mon Sep 17 00:00:00 2001 From: Jordan Demeulenaere Date: Mon, 7 Aug 2023 13:38:27 +0200 Subject: [PATCH 32/85] Enable Compose in SystemUI Bug: 238993727 Bug: 242040009 Test: Manual. See http://go/sysui-compose-performance-results for details on performance analysis. Test: Platinium tests passed on Forrest. See http://go/abtd-run/L56600000962427117 Ignore-AOSP-First: We need to submit this together with a bunch of other SystemUI CLs. Change-Id: I62efad92bd1940db3524214eac2deef6d356c235 --- core/android_soong_config_vars.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk index 2df014349a..3890443f29 100644 --- a/core/android_soong_config_vars.mk +++ b/core/android_soong_config_vars.mk @@ -142,8 +142,8 @@ endif SYSTEMUI_OPTIMIZE_JAVA ?= true $(call add_soong_config_var,ANDROID,SYSTEMUI_OPTIMIZE_JAVA) -# Disable Compose in SystemUI by default. -SYSTEMUI_USE_COMPOSE ?= false +# Enable Compose in SystemUI by default. +SYSTEMUI_USE_COMPOSE ?= true $(call add_soong_config_var,ANDROID,SYSTEMUI_USE_COMPOSE) ifdef PRODUCT_AVF_ENABLED From e74b12cd7b823a9f6ce12f0a7d5b6654a4e892ae Mon Sep 17 00:00:00 2001 From: Dennis Shen Date: Tue, 5 Sep 2023 19:11:30 +0000 Subject: [PATCH 33/85] update sever_configurable_flags to vndk true Bug: 297419706 Change-Id: I46a8d9e35d28ad9eb7e305465e537dcf23e523f4 Ignore-AOSP-First: need to submit to git main first to resolve merge conflict, will used merged in in aosp change --- target/product/gsi/current.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/product/gsi/current.txt b/target/product/gsi/current.txt index 9ff886e46e..1304409111 100644 --- a/target/product/gsi/current.txt +++ b/target/product/gsi/current.txt @@ -138,6 +138,7 @@ VNDK-core: libwifi-system-iface.so VNDK-core: libxml2.so VNDK-core: libyuv.so VNDK-core: libziparchive.so +VNDK-core: server_configurable_flags.so VNDK-private: libblas.so VNDK-private: libcompiler_rt.so VNDK-private: libft2.so @@ -208,3 +209,4 @@ VNDK-product: libxml2.so VNDK-product: libyuv.so VNDK-product: libz.so VNDK-product: libziparchive.so +VNDK-product: server_configurable_flags.so From 6605eca7dd6dc8f27b6bb79939f1f0cacda64ca7 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Thu, 7 Sep 2023 23:47:04 -0700 Subject: [PATCH 34/85] Format release_config.bzl Test: Presubmits Change-Id: Id043c1e67cafe120ec1b7af4eaac03f8beaa660e --- core/release_config.bzl | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core/release_config.bzl b/core/release_config.bzl index 8091af3daa..a2f59e63a8 100644 --- a/core/release_config.bzl +++ b/core/release_config.bzl @@ -85,17 +85,16 @@ def flag(name, partitions, default): if len(partitions) > 1: fail("\"all\" can't be combined with other partitions: " + str(partitions)) elif partition not in _flag_partitions: - fail("Invalid partition: " + partition + ", allowed partitions: " - + str(_flag_partitions)) + fail("Invalid partition: " + partition + ", allowed partitions: " + + str(_flag_partitions)) if type(default) not in _valid_types: fail("Invalid type of default for flag \"" + name + "\" (" + type(default) + ")") return { "name": name, "partitions": partitions, - "default": default + "default": default, } - def value(name, value): "Define the flag value for a particular configuration." return { @@ -103,7 +102,6 @@ def value(name, value): "value": value, } - def _format_value(val): "Format the starlark type correctly for make" if type(val) == "NoneType": @@ -113,7 +111,6 @@ def _format_value(val): else: return val - def release_config(all_flags, all_values): "Return the make variables that should be set for this release config." validate(all_flags, _all_flags_schema) @@ -168,4 +165,3 @@ def release_config(all_flags, all_values): result["_ALL_RELEASE_FLAGS." + flag["name"] + ".SET_IN"] = set_in return result - From c5255203c7818ac6cc7bcfa229ba26560c8dffc6 Mon Sep 17 00:00:00 2001 From: Gurpreet Singh Date: Fri, 8 Sep 2023 13:23:41 +0000 Subject: [PATCH 35/85] Add OWNERS for sdk extensions version updates Our team performs the mainline sdk releases and has to update the sdk extensions version on every release. Adding people who are involved in the sdk ext release process so that changes related to sdk extensions version updates can be approved by our team. We will only be approving changes which updates sdk extensions version. Bug: N/A Test: N/A (cherry picked from https://android-review.googlesource.com/q/commit:3b3e686d8bd21d522b77568357efdb6589ac13b3) Merged-In: I42755dbae7054161f56e789b57e064084eebc7c7 Change-Id: I42755dbae7054161f56e789b57e064084eebc7c7 --- core/OWNERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/OWNERS b/core/OWNERS index eb1d5c3c46..88f6d068bb 100644 --- a/core/OWNERS +++ b/core/OWNERS @@ -5,3 +5,5 @@ per-file proguard*.flags = jdduke@google.com # For version updates per-file version_defaults.mk = aseaton@google.com,lubomir@google.com,pscovanner@google.com,bkhalife@google.com,jainne@google.com +# For sdk extensions version updates +per-file version_defaults.mk = amhk@google.com,gurpreetgs@google.com,mkhokhlova@google.com,robertogil@google.com From e8a9b9b94390e0695bee369c0b7261cde4b76db6 Mon Sep 17 00:00:00 2001 From: Victor Hsieh Date: Fri, 29 Sep 2023 11:20:19 -0700 Subject: [PATCH 36/85] Add preinstalled-packages-strict-signature.xml to build Please refer to the topic change for context. Ignore-AOSP-First: new file added in the internal branch Bug: 277344944 Test: m Change-Id: I09dd6b152c3a4b4e884132885d72f97e805797f8 --- target/product/base_system.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/target/product/base_system.mk b/target/product/base_system.mk index 37e57da111..b0e408b095 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -243,6 +243,7 @@ PRODUCT_PACKAGES += \ pppd \ preinstalled-packages-asl-files.xml \ preinstalled-packages-platform.xml \ + preinstalled-packages-strict-signature.xml \ printflags \ privapp-permissions-platform.xml \ prng_seeder \ From c2b45030ce9878bca612410b019b9f7fe1e7211e Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Tue, 3 Oct 2023 23:29:32 +0000 Subject: [PATCH 37/85] Update Security String to 2023-12-01 Bug: 302612466 Change-Id: I887e3dff893647d8f43ead564887df6f3086381a Merged-In: I887e3dff893647d8f43ead564887df6f3086381a Ignore-AOSP-First: Internal first as its needed for preparing the release --- core/version_defaults.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/version_defaults.mk b/core/version_defaults.mk index cf34f39483..acaf345fda 100644 --- a/core/version_defaults.mk +++ b/core/version_defaults.mk @@ -240,7 +240,7 @@ ifndef PLATFORM_SECURITY_PATCH # It must be of the form "YYYY-MM-DD" on production devices. # It must match one of the Android Security Patch Level strings of the Public Security Bulletins. # If there is no $PLATFORM_SECURITY_PATCH set, keep it empty. - PLATFORM_SECURITY_PATCH := 2023-11-01 + PLATFORM_SECURITY_PATCH := 2023-12-01 endif .KATI_READONLY := PLATFORM_SECURITY_PATCH From e62001953f330c036993d029533f04dc82ba091b Mon Sep 17 00:00:00 2001 From: sergiuferentz Date: Mon, 25 Sep 2023 15:04:30 +0000 Subject: [PATCH 38/85] Bump android.hardware.graphics.common V4->V5 Test: Build Ignore-AOSP-First: changes in topics with internal-first/internal-only projects Bug: 291142745 Change-Id: Iefb2ebc22f622d8e97f8a878f972d8b354aa1b7d --- target/product/gsi/current.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/product/gsi/current.txt b/target/product/gsi/current.txt index 1304409111..be4894841f 100644 --- a/target/product/gsi/current.txt +++ b/target/product/gsi/current.txt @@ -23,7 +23,7 @@ LLNDK: libvulkan.so VNDK-SP: android.hardware.common-V2-ndk.so VNDK-SP: android.hardware.common.fmq-V1-ndk.so VNDK-SP: android.hardware.graphics.allocator-V2-ndk.so -VNDK-SP: android.hardware.graphics.common-V4-ndk.so +VNDK-SP: android.hardware.graphics.common-V5-ndk.so VNDK-SP: android.hardware.graphics.common@1.0.so VNDK-SP: android.hardware.graphics.common@1.1.so VNDK-SP: android.hardware.graphics.common@1.2.so From 47cd7202ec2e95c8a45242baf61aa65d422032ca Mon Sep 17 00:00:00 2001 From: Jan Sebechlebsky Date: Wed, 4 Oct 2023 11:31:09 +0200 Subject: [PATCH 39/85] Add Virtual Camera HAL service to base_system. ... following instructions to add new binary using build flags. Bug: 301023410 Test: mm Ignore-AOSP-First: Virtual Camera HAL target is not merged in AOSP. Change-Id: I83b6a33775c763671eb2ab11e5fca9b12676b1bc --- target/product/base_system.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/product/base_system.mk b/target/product/base_system.mk index b0e408b095..99e8e26930 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -296,6 +296,8 @@ PRODUCT_PACKAGES += \ wifi.rc \ wm \ +PRODUCT_PACKAGES += $(RELEASE_PACKAGE_VIRTUAL_CAMERA) + # These packages are not used on Android TV ifneq ($(PRODUCT_IS_ATV),true) PRODUCT_PACKAGES += \ From 2701f2875baa7e8dd04fc06db9691022819706af Mon Sep 17 00:00:00 2001 From: Pranav Gupta Date: Wed, 21 Jun 2023 21:16:35 +0000 Subject: [PATCH 40/85] DO NOT MERGE: Enable mainline prebuilts for device targets Ignore-AOSP-First: Android Mainline prebuilts are not used for AOSP targets Bug: 286892268 Test: pre-submit (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:20545fcf21f8af77e5899f7c6ca4837b05dd20f2) Merged-In: I6f89f47a8e545e563b184cdc9395eddd49950228 Change-Id: I6f89f47a8e545e563b184cdc9395eddd49950228 --- core/android_soong_config_vars.mk | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk index d09b7167ea..e8331a2e9f 100644 --- a/core/android_soong_config_vars.mk +++ b/core/android_soong_config_vars.mk @@ -36,7 +36,7 @@ $(call add_soong_config_var,ANDROID,PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT) # Default behavior for the tree wrt building modules or using prebuilts. This # can always be overridden by setting the environment variable # MODULE_BUILD_FROM_SOURCE. -BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true +BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := false ifneq ($(SANITIZE_TARGET)$(EMMA_INSTRUMENT_FRAMEWORK),) # Always use sources when building the framework with Java coverage or @@ -45,6 +45,18 @@ ifneq ($(SANITIZE_TARGET)$(EMMA_INSTRUMENT_FRAMEWORK),) BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true endif +ifneq ($(CLANG_COVERAGE)$(NATIVE_COVERAGE_PATHS),) + # Always use sources when building with clang coverage and native coverage. + # It is possible that there are certain situations when building with coverage + # would work with prebuilts, e.g. when the coverage is not being applied to + # modules for which we provide prebuilts. Unfortunately, determining that + # would require embedding knowledge of which coverage paths affect which + # modules here. That would duplicate a lot of information, add yet another + # location module authors have to update and complicate the logic here. + # For nowe we will just always build from sources when doing coverage builds. + BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true +endif + # ART does not provide linux_bionic variants needed for products that # set HOST_CROSS_OS=linux_bionic. ifeq (linux_bionic,${HOST_CROSS_OS}) From 0d277eb65dae22592ef523915f5002ce5334d83e Mon Sep 17 00:00:00 2001 From: Alyssa Ketpreechasawat Date: Thu, 21 Sep 2023 17:49:42 +0000 Subject: [PATCH 41/85] Use build flag RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE to enable/disable module build from prebuilts. This will allow us to enable/disable module build from prebuilts based on different release config. Ignore-AOSP-First: Specific to enabling prebuilts in trunk stable Bug: 293101517 Test: m (use prebuilts when building next and build from source when building trunk) Change-Id: Ie81e033e9d4ac9c0221b796e7e46bcc117ceadbb --- core/android_soong_config_vars.mk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk index e8331a2e9f..99f8c431af 100644 --- a/core/android_soong_config_vars.mk +++ b/core/android_soong_config_vars.mk @@ -36,7 +36,12 @@ $(call add_soong_config_var,ANDROID,PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT) # Default behavior for the tree wrt building modules or using prebuilts. This # can always be overridden by setting the environment variable # MODULE_BUILD_FROM_SOURCE. -BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := false +BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := $(RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE) +# TODO(b/301454934): The value from build flag is set to empty when use `False` +# The condition below can be removed after the issue get sorted. +ifeq (,$(BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE)) + BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := false +endif ifneq ($(SANITIZE_TARGET)$(EMMA_INSTRUMENT_FRAMEWORK),) # Always use sources when building the framework with Java coverage or From b419e50c8328de3af990c04ed50eac518eb0aeae Mon Sep 17 00:00:00 2001 From: Alyssa Ketpreechasawat Date: Fri, 6 Oct 2023 03:42:34 +0000 Subject: [PATCH 42/85] Revert "Add RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE in config." Revert submission 2761821-suppress-hiddenapi-check Reason for revert: have some typo - break next build Reverted changes: /q/submissionid:2761821-suppress-hiddenapi-check (cherry picked from https://android-review.googlesource.com/q/commit:55702a7fb49af4e1fbbefea6a6dd6defecaf7065) Merged-In: I24f91b77f76cf0950d407aee3dedc30412213d00 Change-Id: I24f91b77f76cf0950d407aee3dedc30412213d00 --- core/soong_config.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/soong_config.mk b/core/soong_config.mk index e541c123df..90b47a0e6b 100644 --- a/core/soong_config.mk +++ b/core/soong_config.mk @@ -316,8 +316,6 @@ $(call add_json_str, ReleaseVersion, $(_RELEASE_VERSION)) $(call add_json_str, ReleaseAconfigValueSets, $(RELEASE_ACONFIG_VALUE_SETS)) $(call add_json_str, ReleaseAconfigFlagDefaultPermission, $(RELEASE_ACONFIG_FLAG_DEFAULT_PERMISSION)) -$(call add_json_bool, ReleaseDefaultModuleBuildFromSource, $(RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE)) - $(call add_json_bool, KeepVndk, $(filter true,$(KEEP_VNDK))) $(call add_json_bool, CheckVendorSeappViolations, $(filter true,$(CHECK_VENDOR_SEAPP_VIOLATIONS))) From a2e2dda76a3dfcd7fd42c3006423827b5aecb3ff Mon Sep 17 00:00:00 2001 From: Zhi Dou Date: Fri, 6 Oct 2023 07:15:28 +0000 Subject: [PATCH 43/85] aconfig: add @UnsupportedAppUsage to methods in generated flags The java generated flags are marked as @hide which breaks CTS. To unblock CTS test add @UnsupportedAppUsage to expose the methods. Test: atest aconfig.test.flags Bug: 301272559 Ignore-AOSP-First: Need to commit with changes in internal main. This change will be cherry picked to AOSP once merged in main Change-Id: I897573c054e70fc6e093869ba6d416c38f81e28f --- tools/aconfig/src/codegen_java.rs | 35 +++++++++++++++++++ .../FakeFeatureFlagsImpl.java.template | 3 ++ .../templates/FeatureFlags.java.template | 3 ++ .../templates/FeatureFlagsImpl.java.template | 4 +++ tools/aconfig/templates/Flags.java.template | 4 +++ 5 files changed, 49 insertions(+) diff --git a/tools/aconfig/src/codegen_java.rs b/tools/aconfig/src/codegen_java.rs index c4fc405a61..43c2ecfc36 100644 --- a/tools/aconfig/src/codegen_java.rs +++ b/tools/aconfig/src/codegen_java.rs @@ -118,21 +118,30 @@ mod tests { const EXPECTED_FEATUREFLAGS_COMMON_CONTENT: &str = r#" package com.android.aconfig.test; + // TODO(b/303773055): Remove the annotation after access issue is resolved. + import android.compat.annotation.UnsupportedAppUsage; /** @hide */ public interface FeatureFlags { @com.android.aconfig.annotations.AssumeFalseForR8 + @UnsupportedAppUsage boolean disabledRo(); + @UnsupportedAppUsage boolean disabledRw(); @com.android.aconfig.annotations.AssumeTrueForR8 + @UnsupportedAppUsage boolean enabledFixedRo(); @com.android.aconfig.annotations.AssumeTrueForR8 + @UnsupportedAppUsage boolean enabledRo(); + @UnsupportedAppUsage boolean enabledRw(); } "#; const EXPECTED_FLAG_COMMON_CONTENT: &str = r#" package com.android.aconfig.test; + // TODO(b/303773055): Remove the annotation after access issue is resolved. + import android.compat.annotation.UnsupportedAppUsage; /** @hide */ public final class Flags { /** @hide */ @@ -147,20 +156,25 @@ mod tests { public static final String FLAG_ENABLED_RW = "com.android.aconfig.test.enabled_rw"; @com.android.aconfig.annotations.AssumeFalseForR8 + @UnsupportedAppUsage public static boolean disabledRo() { return FEATURE_FLAGS.disabledRo(); } + @UnsupportedAppUsage public static boolean disabledRw() { return FEATURE_FLAGS.disabledRw(); } @com.android.aconfig.annotations.AssumeTrueForR8 + @UnsupportedAppUsage public static boolean enabledFixedRo() { return FEATURE_FLAGS.enabledFixedRo(); } @com.android.aconfig.annotations.AssumeTrueForR8 + @UnsupportedAppUsage public static boolean enabledRo() { return FEATURE_FLAGS.enabledRo(); } + @UnsupportedAppUsage public static boolean enabledRw() { return FEATURE_FLAGS.enabledRw(); } @@ -168,6 +182,8 @@ mod tests { const EXPECTED_FAKEFEATUREFLAGSIMPL_CONTENT: &str = r#" package com.android.aconfig.test; + // TODO(b/303773055): Remove the annotation after access issue is resolved. + import android.compat.annotation.UnsupportedAppUsage; import java.util.HashMap; import java.util.Map; /** @hide */ @@ -176,22 +192,27 @@ mod tests { resetAll(); } @Override + @UnsupportedAppUsage public boolean disabledRo() { return getValue(Flags.FLAG_DISABLED_RO); } @Override + @UnsupportedAppUsage public boolean disabledRw() { return getValue(Flags.FLAG_DISABLED_RW); } @Override + @UnsupportedAppUsage public boolean enabledFixedRo() { return getValue(Flags.FLAG_ENABLED_FIXED_RO); } @Override + @UnsupportedAppUsage public boolean enabledRo() { return getValue(Flags.FLAG_ENABLED_RO); } @Override + @UnsupportedAppUsage public boolean enabledRw() { return getValue(Flags.FLAG_ENABLED_RW); } @@ -241,14 +262,18 @@ mod tests { let expect_featureflagsimpl_content = r#" package com.android.aconfig.test; + // TODO(b/303773055): Remove the annotation after access issue is resolved. + import android.compat.annotation.UnsupportedAppUsage; import android.provider.DeviceConfig; /** @hide */ public final class FeatureFlagsImpl implements FeatureFlags { @Override + @UnsupportedAppUsage public boolean disabledRo() { return false; } @Override + @UnsupportedAppUsage public boolean disabledRw() { return getValue( "aconfig_test", @@ -257,14 +282,17 @@ mod tests { ); } @Override + @UnsupportedAppUsage public boolean enabledFixedRo() { return true; } @Override + @UnsupportedAppUsage public boolean enabledRo() { return true; } @Override + @UnsupportedAppUsage public boolean enabledRw() { return getValue( "aconfig_test", @@ -346,29 +374,36 @@ mod tests { "#; let expect_featureflagsimpl_content = r#" package com.android.aconfig.test; + // TODO(b/303773055): Remove the annotation after access issue is resolved. + import android.compat.annotation.UnsupportedAppUsage; /** @hide */ public final class FeatureFlagsImpl implements FeatureFlags { @Override + @UnsupportedAppUsage public boolean disabledRo() { throw new UnsupportedOperationException( "Method is not implemented."); } @Override + @UnsupportedAppUsage public boolean disabledRw() { throw new UnsupportedOperationException( "Method is not implemented."); } @Override + @UnsupportedAppUsage public boolean enabledFixedRo() { throw new UnsupportedOperationException( "Method is not implemented."); } @Override + @UnsupportedAppUsage public boolean enabledRo() { throw new UnsupportedOperationException( "Method is not implemented."); } @Override + @UnsupportedAppUsage public boolean enabledRw() { throw new UnsupportedOperationException( "Method is not implemented."); diff --git a/tools/aconfig/templates/FakeFeatureFlagsImpl.java.template b/tools/aconfig/templates/FakeFeatureFlagsImpl.java.template index d2cea952f9..72a896f997 100644 --- a/tools/aconfig/templates/FakeFeatureFlagsImpl.java.template +++ b/tools/aconfig/templates/FakeFeatureFlagsImpl.java.template @@ -1,4 +1,6 @@ package {package_name}; +// TODO(b/303773055): Remove the annotation after access issue is resolved. +import android.compat.annotation.UnsupportedAppUsage; import java.util.HashMap; import java.util.Map; @@ -11,6 +13,7 @@ public class FakeFeatureFlagsImpl implements FeatureFlags \{ {{ for item in class_elements}} @Override + @UnsupportedAppUsage public boolean {item.method_name}() \{ return getValue(Flags.FLAG_{item.flag_name_constant_suffix}); } diff --git a/tools/aconfig/templates/FeatureFlags.java.template b/tools/aconfig/templates/FeatureFlags.java.template index 9350d60bec..02305e69fe 100644 --- a/tools/aconfig/templates/FeatureFlags.java.template +++ b/tools/aconfig/templates/FeatureFlags.java.template @@ -1,4 +1,6 @@ package {package_name}; +// TODO(b/303773055): Remove the annotation after access issue is resolved. +import android.compat.annotation.UnsupportedAppUsage; /** @hide */ public interface FeatureFlags \{ @@ -10,6 +12,7 @@ public interface FeatureFlags \{ @com.android.aconfig.annotations.AssumeFalseForR8 {{ -endif- }} {{ endif }} + @UnsupportedAppUsage boolean {item.method_name}(); {{ endfor }} } diff --git a/tools/aconfig/templates/FeatureFlagsImpl.java.template b/tools/aconfig/templates/FeatureFlagsImpl.java.template index 3913fa4ea3..1620dfe85d 100644 --- a/tools/aconfig/templates/FeatureFlagsImpl.java.template +++ b/tools/aconfig/templates/FeatureFlagsImpl.java.template @@ -1,4 +1,6 @@ package {package_name}; +// TODO(b/303773055): Remove the annotation after access issue is resolved. +import android.compat.annotation.UnsupportedAppUsage; {{ if not is_test_mode }} {{ if is_read_write- }} import android.provider.DeviceConfig; @@ -7,6 +9,7 @@ import android.provider.DeviceConfig; public final class FeatureFlagsImpl implements FeatureFlags \{ {{ for item in class_elements}} @Override + @UnsupportedAppUsage public boolean {item.method_name}() \{ {{ -if item.is_read_write }} return getValue( @@ -49,6 +52,7 @@ public final class FeatureFlagsImpl implements FeatureFlags \{ public final class FeatureFlagsImpl implements FeatureFlags \{ {{ for item in class_elements}} @Override + @UnsupportedAppUsage public boolean {item.method_name}() \{ throw new UnsupportedOperationException( "Method is not implemented."); diff --git a/tools/aconfig/templates/Flags.java.template b/tools/aconfig/templates/Flags.java.template index 39024a8f74..66c4c5a114 100644 --- a/tools/aconfig/templates/Flags.java.template +++ b/tools/aconfig/templates/Flags.java.template @@ -1,5 +1,8 @@ package {package_name}; +// TODO(b/303773055): Remove the annotation after access issue is resolved. +import android.compat.annotation.UnsupportedAppUsage; + /** @hide */ public final class Flags \{ {{- for item in class_elements}} @@ -14,6 +17,7 @@ public final class Flags \{ @com.android.aconfig.annotations.AssumeFalseForR8 {{ -endif- }} {{ endif }} + @UnsupportedAppUsage public static boolean {item.method_name}() \{ return FEATURE_FLAGS.{item.method_name}(); } From 22f5d3abc6b0fcbb04f1a5c1c0ab02b78a47f1ef Mon Sep 17 00:00:00 2001 From: Sam Dubey Date: Mon, 9 Oct 2023 13:49:41 +0000 Subject: [PATCH 44/85] Revert "Use build flag RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE ..." Revert submission 24055201-next-prebuilts-enable Reason for revert: Breaking PM platinum tests b/304247444 Reverted changes: /q/submissionid:24055201-next-prebuilts-enable Change-Id: Icee311fc4be85916849e37d19a0b2ec78259753c --- core/android_soong_config_vars.mk | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk index 99f8c431af..e8331a2e9f 100644 --- a/core/android_soong_config_vars.mk +++ b/core/android_soong_config_vars.mk @@ -36,12 +36,7 @@ $(call add_soong_config_var,ANDROID,PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT) # Default behavior for the tree wrt building modules or using prebuilts. This # can always be overridden by setting the environment variable # MODULE_BUILD_FROM_SOURCE. -BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := $(RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE) -# TODO(b/301454934): The value from build flag is set to empty when use `False` -# The condition below can be removed after the issue get sorted. -ifeq (,$(BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE)) - BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := false -endif +BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := false ifneq ($(SANITIZE_TARGET)$(EMMA_INSTRUMENT_FRAMEWORK),) # Always use sources when building the framework with Java coverage or From 3abb16981d4e531362bf379b70e8275d8a66bd0e Mon Sep 17 00:00:00 2001 From: Sam Dubey Date: Mon, 9 Oct 2023 13:49:41 +0000 Subject: [PATCH 45/85] Revert "DO NOT MERGE: Enable mainline prebuilts for device targets" Revert submission 24055201-next-prebuilts-enable Reason for revert: Breaking PM platinum tests b/304247444 Reverted changes: /q/submissionid:24055201-next-prebuilts-enable Change-Id: Ie3e8453585af2799e7a0b2191934e678661ea689 --- core/android_soong_config_vars.mk | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk index e8331a2e9f..d09b7167ea 100644 --- a/core/android_soong_config_vars.mk +++ b/core/android_soong_config_vars.mk @@ -36,7 +36,7 @@ $(call add_soong_config_var,ANDROID,PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT) # Default behavior for the tree wrt building modules or using prebuilts. This # can always be overridden by setting the environment variable # MODULE_BUILD_FROM_SOURCE. -BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := false +BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true ifneq ($(SANITIZE_TARGET)$(EMMA_INSTRUMENT_FRAMEWORK),) # Always use sources when building the framework with Java coverage or @@ -45,18 +45,6 @@ ifneq ($(SANITIZE_TARGET)$(EMMA_INSTRUMENT_FRAMEWORK),) BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true endif -ifneq ($(CLANG_COVERAGE)$(NATIVE_COVERAGE_PATHS),) - # Always use sources when building with clang coverage and native coverage. - # It is possible that there are certain situations when building with coverage - # would work with prebuilts, e.g. when the coverage is not being applied to - # modules for which we provide prebuilts. Unfortunately, determining that - # would require embedding knowledge of which coverage paths affect which - # modules here. That would duplicate a lot of information, add yet another - # location module authors have to update and complicate the logic here. - # For nowe we will just always build from sources when doing coverage builds. - BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true -endif - # ART does not provide linux_bionic variants needed for products that # set HOST_CROSS_OS=linux_bionic. ifeq (linux_bionic,${HOST_CROSS_OS}) From 175196045017545a484b25132bb79506cccf51f2 Mon Sep 17 00:00:00 2001 From: Pedro Loureiro Date: Mon, 9 Oct 2023 20:04:49 +0000 Subject: [PATCH 46/85] Revert "Revert "DO NOT MERGE: Enable mainline prebuilts for devi..." Revert submission 24991927-revert-24055201-next-prebuilts-enable-LJUEEMOUMW Reason for revert: Root cause fixed Reverted changes: /q/submissionid:24991927-revert-24055201-next-prebuilts-enable-LJUEEMOUMW Change-Id: I7b37e431d991f8a68364cf8f4e6b07030dff0469 --- core/android_soong_config_vars.mk | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk index d09b7167ea..e8331a2e9f 100644 --- a/core/android_soong_config_vars.mk +++ b/core/android_soong_config_vars.mk @@ -36,7 +36,7 @@ $(call add_soong_config_var,ANDROID,PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT) # Default behavior for the tree wrt building modules or using prebuilts. This # can always be overridden by setting the environment variable # MODULE_BUILD_FROM_SOURCE. -BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true +BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := false ifneq ($(SANITIZE_TARGET)$(EMMA_INSTRUMENT_FRAMEWORK),) # Always use sources when building the framework with Java coverage or @@ -45,6 +45,18 @@ ifneq ($(SANITIZE_TARGET)$(EMMA_INSTRUMENT_FRAMEWORK),) BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true endif +ifneq ($(CLANG_COVERAGE)$(NATIVE_COVERAGE_PATHS),) + # Always use sources when building with clang coverage and native coverage. + # It is possible that there are certain situations when building with coverage + # would work with prebuilts, e.g. when the coverage is not being applied to + # modules for which we provide prebuilts. Unfortunately, determining that + # would require embedding knowledge of which coverage paths affect which + # modules here. That would duplicate a lot of information, add yet another + # location module authors have to update and complicate the logic here. + # For nowe we will just always build from sources when doing coverage builds. + BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := true +endif + # ART does not provide linux_bionic variants needed for products that # set HOST_CROSS_OS=linux_bionic. ifeq (linux_bionic,${HOST_CROSS_OS}) From a01a4c9d782131264e8295be95b469562f1c8530 Mon Sep 17 00:00:00 2001 From: Pedro Loureiro Date: Mon, 9 Oct 2023 20:04:49 +0000 Subject: [PATCH 47/85] Revert "Revert "Use build flag RELEASE_DEFAULT_MODULE_BUILD_FROM..." Revert submission 24991927-revert-24055201-next-prebuilts-enable-LJUEEMOUMW Reason for revert: Root cause fixed Reverted changes: /q/submissionid:24991927-revert-24055201-next-prebuilts-enable-LJUEEMOUMW Change-Id: I547176490129d6fbe7d1b05d6a7aed91b9fcadd1 --- core/android_soong_config_vars.mk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk index e8331a2e9f..99f8c431af 100644 --- a/core/android_soong_config_vars.mk +++ b/core/android_soong_config_vars.mk @@ -36,7 +36,12 @@ $(call add_soong_config_var,ANDROID,PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT) # Default behavior for the tree wrt building modules or using prebuilts. This # can always be overridden by setting the environment variable # MODULE_BUILD_FROM_SOURCE. -BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := false +BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := $(RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE) +# TODO(b/301454934): The value from build flag is set to empty when use `False` +# The condition below can be removed after the issue get sorted. +ifeq (,$(BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE)) + BRANCH_DEFAULT_MODULE_BUILD_FROM_SOURCE := false +endif ifneq ($(SANITIZE_TARGET)$(EMMA_INSTRUMENT_FRAMEWORK),) # Always use sources when building the framework with Java coverage or From 3e88b3a8fc4744c9e9b3165392f453016de095e1 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Mon, 9 Oct 2023 19:57:10 +0000 Subject: [PATCH 48/85] handheld_system: Replace NFC app with NFC apex Bug: 303286040 Test: Compiles (cherry picked from https://android-review.googlesource.com/q/commit:4719a59f2798eb72f1b9f2b8a3d1753f1ee5dd98) Merged-In: Id451b2de566bfba73d89b95b33a99cefbdb4ea6f Change-Id: Id451b2de566bfba73d89b95b33a99cefbdb4ea6f --- target/product/handheld_system.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/product/handheld_system.mk b/target/product/handheld_system.mk index d5c2a87c07..b2064fa0e3 100644 --- a/target/product/handheld_system.mk +++ b/target/product/handheld_system.mk @@ -40,6 +40,7 @@ PRODUCT_PACKAGES += \ BuiltInPrintService \ CalendarProvider \ cameraserver \ + com.android.nfcservices \ CameraExtensionsProxy \ CaptivePortalLogin \ CertInstaller \ @@ -57,7 +58,6 @@ PRODUCT_PACKAGES += \ MmsService \ MtpService \ MusicFX \ - NfcNci \ PacProcessor \ preinstalled-packages-platform-handheld-system.xml \ PrintRecommendationService \ From 27ea10920b98a84da3d625f132afdb96c0dae495 Mon Sep 17 00:00:00 2001 From: Jag Ghoshal Date: Mon, 25 Sep 2023 20:58:25 +0000 Subject: [PATCH 49/85] Add mediaprovider to the list of individually toggleable modules. This is safe since GTS tests already exist to check for mandatory modules, which this module is a part of. Bug:294190883 Change-Id: I3b5853f8e56c2fb9cfe7f492cf0b753819c55213 Ignore-AOSP-First: changes in topics with internal-first/internal-only projects. --- core/android_soong_config_vars.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk index 6bac52b5ee..29238d569b 100644 --- a/core/android_soong_config_vars.mk +++ b/core/android_soong_config_vars.mk @@ -128,6 +128,7 @@ INDIVIDUALLY_TOGGLEABLE_PREBUILT_MODULES := \ rkpd \ uwb \ wifi \ + mediaprovider \ $(foreach m, $(INDIVIDUALLY_TOGGLEABLE_PREBUILT_MODULES),\ $(if $(call soong_config_get,$(m)_module,source_build),,\ From 4ebb041135643382a5e03ae160ff3373db192f48 Mon Sep 17 00:00:00 2001 From: Lokesh Kumar Goel Date: Mon, 16 Oct 2023 04:35:55 +0000 Subject: [PATCH 50/85] Update Security String to 2023-12-01 Bug: 302612466 Change-Id: I887e3dff893647d8f43ead564887df6f3086381a Merged-In: I887e3dff893647d8f43ead564887df6f3086381a Ignore-AOSP-First: Internal first as its needed for preparing the release --- core/version_defaults.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/version_defaults.mk b/core/version_defaults.mk index 1ab04e372e..3460e39dcd 100644 --- a/core/version_defaults.mk +++ b/core/version_defaults.mk @@ -104,7 +104,7 @@ ifndef PLATFORM_SECURITY_PATCH # It must be of the form "YYYY-MM-DD" on production devices. # It must match one of the Android Security Patch Level strings of the Public Security Bulletins. # If there is no $PLATFORM_SECURITY_PATCH set, keep it empty. - PLATFORM_SECURITY_PATCH := 2023-11-05 + PLATFORM_SECURITY_PATCH := 2023-12-01 endif include $(BUILD_SYSTEM)/version_util.mk From bc2a9157da72faf095a0a25d13f2a250e436ef92 Mon Sep 17 00:00:00 2001 From: Ted Bauer Date: Mon, 16 Oct 2023 15:39:01 -0400 Subject: [PATCH 51/85] Make aconfig proto lite library available to ConfigInfra. Bug: 298391955 Test: m Ignore-AOSP-First: in topic with internal-first changes Change-Id: Icac70b0e20f1009f9f960177695472b0fa06987c --- tools/aconfig/Android.bp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/aconfig/Android.bp b/tools/aconfig/Android.bp index 02fc57cb74..f7a46f0f8e 100644 --- a/tools/aconfig/Android.bp +++ b/tools/aconfig/Android.bp @@ -13,6 +13,10 @@ java_library { type: "lite", }, sdk_version: "current", + min_sdk_version: "UpsideDownCake", + apex_available: [ + "com.android.configinfrastructure" + ] } java_library_host { From 5c1187e22fd9bdb7bfcbe5dccea69732716db501 Mon Sep 17 00:00:00 2001 From: Wei Li Date: Mon, 16 Oct 2023 16:22:34 -0700 Subject: [PATCH 52/85] Add zip2zip as a data dependency of releasetools_common so it is built with releasetools_common and other python_binary_host modules depend on releasetools_common. Bug: 303082945 Test: CIs Test: "m dev_sign_bundle" on internal udc branch and check zip2zip is built too. (cherry picked from https://android-review.googlesource.com/q/commit:6437bae07c9510bfaa61908c1255a17e55c65742) Merged-In: Iad5aa401de39516876714c854dc07aeba2f234e5 Change-Id: Iad5aa401de39516876714c854dc07aeba2f234e5 --- tools/releasetools/Android.bp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/releasetools/Android.bp b/tools/releasetools/Android.bp index 1240872a9e..d07292a082 100644 --- a/tools/releasetools/Android.bp +++ b/tools/releasetools/Android.bp @@ -236,6 +236,9 @@ python_library_host { "rangelib.py", "sparse_img.py", ], + data: [ + ":zip2zip", + ], // Only the tools that are referenced directly are listed as required modules. For example, // `avbtool` is not here, as the script always uses the one from info_dict['avb_avbtool']. required: [ @@ -251,7 +254,6 @@ python_library_host { "signapk", "toybox", "unpack_bootimg", - "zip2zip", ], } From a998b43d2024a2bb8b58da499de067a08972aced Mon Sep 17 00:00:00 2001 From: Liana Kazanova Date: Wed, 18 Oct 2023 18:11:00 +0000 Subject: [PATCH 53/85] Revert "Make aconfig proto lite library available to ConfigInfra." Revert submission 25064730-notif-only-on-aconfig Reason for revert: Potential culprit for b/306183683 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted Reverted changes: /q/submissionid:25064730-notif-only-on-aconfig Change-Id: Ib944d32a7564a5c393943387c1be6a2b5ffcdeca --- tools/aconfig/Android.bp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/aconfig/Android.bp b/tools/aconfig/Android.bp index f7a46f0f8e..02fc57cb74 100644 --- a/tools/aconfig/Android.bp +++ b/tools/aconfig/Android.bp @@ -13,10 +13,6 @@ java_library { type: "lite", }, sdk_version: "current", - min_sdk_version: "UpsideDownCake", - apex_available: [ - "com.android.configinfrastructure" - ] } java_library_host { From c85ab8d6ef906076c0dc630625776d9131f98b0d Mon Sep 17 00:00:00 2001 From: Ted Bauer Date: Mon, 23 Oct 2023 16:36:35 +0000 Subject: [PATCH 54/85] Revert "Revert "Make aconfig proto lite library available to Con..." Revert submission 25105561-revert-25064730-notif-only-on-aconfig-XXIRRMSTBN Reason for revert: reverted for unrelated failure, see b/306183683 Reverted changes: /q/submissionid:25105561-revert-25064730-notif-only-on-aconfig-XXIRRMSTBN Change-Id: I9f38b65ec3a665ebde0cebb30fc506f08cd408e0 --- tools/aconfig/Android.bp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/aconfig/Android.bp b/tools/aconfig/Android.bp index 02fc57cb74..f7a46f0f8e 100644 --- a/tools/aconfig/Android.bp +++ b/tools/aconfig/Android.bp @@ -13,6 +13,10 @@ java_library { type: "lite", }, sdk_version: "current", + min_sdk_version: "UpsideDownCake", + apex_available: [ + "com.android.configinfrastructure" + ] } java_library_host { From 3cd02ac4d21626738730d0b7306cfebe45cad638 Mon Sep 17 00:00:00 2001 From: Edgar Arriaga Date: Mon, 23 Oct 2023 18:44:00 +0000 Subject: [PATCH 55/85] Add pintool binary to system partition Ignore-AOSP-First: as pintool binary is releasing with next android version. Bug: 297095632 Change-Id: Ia641579d16c826d118c555bf110a8af65bc5b4b0 --- target/product/base_system.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/target/product/base_system.mk b/target/product/base_system.mk index b0e408b095..50c38576c9 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -238,6 +238,7 @@ PRODUCT_PACKAGES += \ perfetto \ ping \ ping6 \ + pintool \ platform.xml \ pm \ pppd \ From ec689ff2eb10fc5dee199e40d39fd50c2fd8a9e3 Mon Sep 17 00:00:00 2001 From: tyiu Date: Wed, 4 Oct 2023 17:51:02 +0000 Subject: [PATCH 56/85] Add config for FULL_SYSTEM_OPTIMIZE_JAVA FULL_SYSTEM_OPTIMIZE_JAVA allows device to enable full system java optimization. Bug: 300514883 Test: local m Ignore-AOSP-First: Changes for wear and other form-factors Change-Id: Iba0a546ef2b721b929b791c6a9e6c854e9bec909 --- core/android_soong_config_vars.mk | 6 ++++++ core/config.mk | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk index a81d168d53..ab87e8f2fe 100644 --- a/core/android_soong_config_vars.mk +++ b/core/android_soong_config_vars.mk @@ -198,7 +198,13 @@ else ifneq (platform:services,$(lastword $(PRODUCT_SYSTEM_SERVER_JARS))) else SYSTEM_OPTIMIZE_JAVA ?= true endif + +ifeq (true,$(FULL_SYSTEM_OPTIMIZE_JAVA)) + SYSTEM_OPTIMIZE_JAVA := true +endif + $(call add_soong_config_var,ANDROID,SYSTEM_OPTIMIZE_JAVA) +$(call add_soong_config_var,ANDROID,FULL_SYSTEM_OPTIMIZE_JAVA) # Check for SupplementalApi module. ifeq ($(wildcard packages/modules/SupplementalApi),) diff --git a/core/config.mk b/core/config.mk index 196f07c0a3..7006e54da2 100644 --- a/core/config.mk +++ b/core/config.mk @@ -1308,3 +1308,9 @@ DEFAULT_DATA_OUT_MODULES := ltp $(ltp_packages) .KATI_READONLY := DEFAULT_DATA_OUT_MODULES include $(BUILD_SYSTEM)/dumpvar.mk + +ifeq (true,$(FULL_SYSTEM_OPTIMIZE_JAVA)) +ifeq (false,$(SYSTEM_OPTIMIZE_JAVA)) +$(error SYSTEM_OPTIMIZE_JAVA must be enabled when FULL_SYSTEM_OPTIMIZE_JAVA is enabled) +endif +endif From c40f31641b859380d7f4208a29b2b69359ee636f Mon Sep 17 00:00:00 2001 From: Jeff Hamilton Date: Thu, 19 Oct 2023 04:54:15 +0000 Subject: [PATCH 57/85] Move most version variable out to relase configs. This allows finer control of the version variables per release config, and removes a lot of computed logic in favor of just directly setting the values. Bug: 306702353 Test: lunch -next-userdebug && m -j98 Change-Id: I9edc7171d124f0cfa540fea6f0e06ba877910444 Ignore-AOSP-First: Changes in internal projects first. --- core/all_versions.bzl | 23 ----- core/envsetup.mk | 43 ++------- core/tasks/cts.mk | 2 +- core/version_defaults.mk | 111 ------------------------ core/version_util.mk | 182 +++++++++++++++++---------------------- 5 files changed, 89 insertions(+), 272 deletions(-) delete mode 100644 core/all_versions.bzl delete mode 100644 core/version_defaults.mk diff --git a/core/all_versions.bzl b/core/all_versions.bzl deleted file mode 100644 index 33da673431..0000000000 --- a/core/all_versions.bzl +++ /dev/null @@ -1,23 +0,0 @@ -# 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -_all_versions = ["OPR1", "OPD1", "OPD2", "OPM1", "OPM2", "PPR1", "PPD1", "PPD2", "PPM1", "PPM2", "QPR1"] + [ - version + subversion - for version in ["Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] - for subversion in ["P1A", "P1B", "P2A", "P2B", "D1A", "D1B", "D2A", "D2B", "Q1A", "Q1B", "Q2A", "Q2B", "Q3A", "Q3B"] -] - -variables_to_export_to_make = { - "ALL_VERSIONS": _all_versions, -} diff --git a/core/envsetup.mk b/core/envsetup.mk index 091c2e3050..7ddbf32766 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -51,44 +51,15 @@ endef include $(BUILD_SYSTEM)/release_config.mk # --------------------------------------------------------------- -# defines ALL_VERSIONS -$(call run-starlark,build/make/core/all_versions.bzl) +# Set up version information +include $(BUILD_SYSTEM)/version_util.mk -# Filters ALL_VERSIONS down to the range [$1, $2], and errors if $1 > $2 or $3 is -# not in [$1, $2] -# $(1): min platform version -# $(2): max platform version -# $(3): default platform version -define allowed-platform-versions -$(strip \ - $(if $(filter $(ALL_VERSIONS),$(1)),, - $(error Invalid MIN_PLATFORM_VERSION '$(1)')) - $(if $(filter $(ALL_VERSIONS),$(2)),, - $(error Invalid MAX_PLATFORM_VERSION '$(2)')) - $(if $(filter $(ALL_VERSIONS),$(3)),, - $(error Invalid RELEASE_PLATFORM_VERSION '$(3)')) +# This used to be calculated, but is now fixed and not expected +# to change over time anymore. New code attempting to use a +# variable like IS_AT_LAST_* should instead use a +# build system flag. - $(eval allowed_versions_ := $(call find_and_earlier,$(ALL_VERSIONS),$(2))) - - $(if $(filter $(allowed_versions_),$(1)),, - $(error MIN_PLATFORM_VERSION '$(1)' must be before MAX_PLATFORM_VERSION '$(2)')) - - $(eval allowed_versions_ := $(1) \ - $(filter-out $(call find_and_earlier,$(allowed_versions_),$(1)),$(allowed_versions_))) - - $(if $(filter $(allowed_versions_),$(3)),, - $(error RELEASE_PLATFORM_VERSION '$(3)' must be between MIN_PLATFORM_VERSION '$(1)' and MAX_PLATFORM_VERSION '$(2)')) - - $(allowed_versions_)) -endef - -#$(warning $(call allowed-platform-versions,OPR1,PPR1,OPR1)) -#$(warning $(call allowed-platform-versions,OPM1,PPR1,OPR1)) - -# Set up version information. -include $(BUILD_SYSTEM)/version_defaults.mk - -ENABLED_VERSIONS := $(call find_and_earlier,$(ALL_VERSIONS),$(TARGET_PLATFORM_VERSION)) +ENABLED_VERSIONS := "OPR1 OPD1 OPD2 OPM1 OPM2 PPR1 PPD1 PPD2 PPM1 PPM2 QPR1 QP1A QP1B QP2A QP2B QD1A QD1B QD2A QD2B QQ1A QQ1B QQ2A QQ2B QQ3A QQ3B RP1A RP1B RP2A RP2B RD1A RD1B RD2A RD2B RQ1A RQ1B RQ2A RQ2B RQ3A RQ3B SP1A SP1B SP2A SP2B SD1A SD1B SD2A SD2B SQ1A SQ1B SQ2A SQ2B SQ3A SQ3B TP1A TP1B TP2A TP2B TD1A TD1B TD2A TD2B TQ1A TQ1B TQ2A TQ2B TQ3A TQ3B UP1A UP1B UP2A UP2B UD1A UD1B UD2A UD2B UQ1A UQ1B UQ2A UQ2B UQ3A UQ3B" $(foreach v,$(ENABLED_VERSIONS), \ $(eval IS_AT_LEAST_$(v) := true)) diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk index d05640ced1..b9f0988740 100644 --- a/core/tasks/cts.mk +++ b/core/tasks/cts.mk @@ -37,7 +37,7 @@ ifneq (,$(wildcard cts/)) cts_platform_release_path := cts/tests/tests/os/assets/platform_releases.txt cts_platform_release_string := $(shell cat $(cts_platform_release_path)) - ifeq ($(RELEASE_PLATFORM_VERSION_CODENAME_REL),) + ifneq (REL,$(PLATFORM_VERSION_CODENAME)) ifeq (,$(findstring $(PLATFORM_VERSION),$(cts_platform_version_string))) define error_msg ============================================================ diff --git a/core/version_defaults.mk b/core/version_defaults.mk deleted file mode 100644 index 8c0b7d98b2..0000000000 --- a/core/version_defaults.mk +++ /dev/null @@ -1,111 +0,0 @@ -# -# Copyright (C) 2008 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# -# Handle various build version information. -# -# Guarantees that the following are defined: -# PLATFORM_VERSION -# PLATFORM_DISPLAY_VERSION -# PLATFORM_SDK_VERSION -# PLATFORM_VERSION_CODENAME -# DEFAULT_APP_TARGET_SDK -# BUILD_ID -# BUILD_NUMBER -# PLATFORM_SECURITY_PATCH -# PLATFORM_VNDK_VERSION -# PLATFORM_SYSTEMSDK_VERSIONS -# - -# Look for an optional file containing overrides of the defaults, -# but don't cry if we don't find it. We could just use -include, but -# the build.prop target also wants INTERNAL_BUILD_ID_MAKEFILE to be set -# if the file exists. -# -INTERNAL_BUILD_ID_MAKEFILE := $(wildcard $(BUILD_SYSTEM)/build_id.mk) -ifdef INTERNAL_BUILD_ID_MAKEFILE - include $(INTERNAL_BUILD_ID_MAKEFILE) -endif - -# Set release configuration. The default resides in build/release/build_flags.mk. -MIN_PLATFORM_VERSION := UP1A -MAX_PLATFORM_VERSION := VP1A - -# The last stable version name of the platform that was released. During -# development, this stays at that previous version, while the codename indicates -# further work based on the previous version. -PLATFORM_VERSION_LAST_STABLE := 14 -.KATI_READONLY := PLATFORM_VERSION_LAST_STABLE - -# These are the current development codenames, if the build is not a final -# release build. If this is a final release build, it is simply "REL". -# Note that this may be overridden by RELEASE_VERSION_CODENAME_REL in -# version_util.mk. -PLATFORM_VERSION_CODENAME.UP1A := UpsideDownCake -PLATFORM_VERSION_CODENAME.VP1A := VanillaIceCream - -# This is the user-visible version. In a final release build it should -# be empty to use PLATFORM_VERSION as the user-visible version. For -# a preview release it can be set to a user-friendly value like `12 Preview 1` -PLATFORM_DISPLAY_VERSION := - -ifndef PLATFORM_SDK_VERSION - # This is the canonical definition of the SDK version, which defines - # the set of APIs and functionality available in the platform. It - # is a single integer that increases monotonically as updates to - # the SDK are released. It should only be incremented when the APIs for - # the new release are frozen (so that developers don't write apps against - # intermediate builds). During development, this number remains at the - # SDK version the branch is based on and PLATFORM_VERSION_CODENAME holds - # the code-name of the new development work. - - # When you increment the PLATFORM_SDK_VERSION please ensure you also - # clear out the following text file of all older PLATFORM_VERSION's: - # cts/tests/tests/os/assets/platform_versions.txt - PLATFORM_SDK_VERSION := 34 -endif -.KATI_READONLY := PLATFORM_SDK_VERSION - -# This is the sdk extension version of this tree. -PLATFORM_SDK_EXTENSION_VERSION := 10 -.KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION - -# This is the sdk extension version that PLATFORM_SDK_VERSION ships with. -PLATFORM_BASE_SDK_EXTENSION_VERSION := $(PLATFORM_SDK_EXTENSION_VERSION) -.KATI_READONLY := PLATFORM_BASE_SDK_EXTENSION_VERSION - -# This are all known codenames. -PLATFORM_VERSION_KNOWN_CODENAMES := \ -Base Base11 Cupcake Donut Eclair Eclair01 EclairMr1 Froyo Gingerbread GingerbreadMr1 \ -Honeycomb HoneycombMr1 HoneycombMr2 IceCreamSandwich IceCreamSandwichMr1 \ -JellyBean JellyBeanMr1 JellyBeanMr2 Kitkat KitkatWatch Lollipop LollipopMr1 M N NMr1 O OMr1 P \ -Q R S Sv2 Tiramisu UpsideDownCake VanillaIceCream - -# Convert from space separated list to comma separated -PLATFORM_VERSION_KNOWN_CODENAMES := \ - $(call normalize-comma-list,$(PLATFORM_VERSION_KNOWN_CODENAMES)) -.KATI_READONLY := PLATFORM_VERSION_KNOWN_CODENAMES - -ifndef PLATFORM_SECURITY_PATCH - # Used to indicate the security patch that has been applied to the device. - # It must signify that the build includes all security patches issued up through the designated Android Public Security Bulletin. - # It must be of the form "YYYY-MM-DD" on production devices. - # It must match one of the Android Security Patch Level strings of the Public Security Bulletins. - # If there is no $PLATFORM_SECURITY_PATCH set, keep it empty. - PLATFORM_SECURITY_PATCH := 2023-12-05 -endif - -include $(BUILD_SYSTEM)/version_util.mk diff --git a/core/version_util.mk b/core/version_util.mk index 0cc3442238..dfa0277993 100644 --- a/core/version_util.mk +++ b/core/version_util.mk @@ -14,119 +14,99 @@ # limitations under the License. # -ALLOWED_VERSIONS := $(call allowed-platform-versions,\ - $(MIN_PLATFORM_VERSION),\ - $(MAX_PLATFORM_VERSION),\ - $(RELEASE_PLATFORM_VERSION)) + +# +# Handle various build version information. +# +# Guarantees that the following are defined: +# PLATFORM_VERSION +# PLATFORM_DISPLAY_VERSION +# PLATFORM_SDK_VERSION +# PLATFORM_SDK_EXTENSION_VERSION +# PLATFORM_VERSION_CODENAME +# DEFAULT_APP_TARGET_SDK +# BUILD_ID +# BUILD_NUMBER +# PLATFORM_SECURITY_PATCH +# PLATFORM_VNDK_VERSION +# PLATFORM_SYSTEMSDK_VERSIONS +# PLATFORM_VERSION_LAST_STABLE +# + +# Look for an optional file containing overrides of the defaults, +# but don't cry if we don't find it. We could just use -include, but +# the build.prop target also wants INTERNAL_BUILD_ID_MAKEFILE to be set +# if the file exists. +# +INTERNAL_BUILD_ID_MAKEFILE := $(wildcard $(BUILD_SYSTEM)/build_id.mk) +ifdef INTERNAL_BUILD_ID_MAKEFILE + include $(INTERNAL_BUILD_ID_MAKEFILE) +endif ifdef TARGET_PLATFORM_VERSION $(error Do not set TARGET_PLATFORM_VERSION directly. Use RELEASE_PLATFORM_VERSION. value: $(TARGET_PLATFORM_VERSION)) endif - TARGET_PLATFORM_VERSION := $(RELEASE_PLATFORM_VERSION) - -ifeq (,$(filter $(ALLOWED_VERSIONS), $(TARGET_PLATFORM_VERSION))) - $(warning Invalid TARGET_PLATFORM_VERSION '$(TARGET_PLATFORM_VERSION)', must be one of) - $(error $(ALLOWED_VERSIONS)) -endif -ALLOWED_VERSIONS := -MIN_PLATFORM_VERSION := -MAX_PLATFORM_VERSION := - .KATI_READONLY := TARGET_PLATFORM_VERSION -# Default versions for each TARGET_PLATFORM_VERSION -# TODO: PLATFORM_VERSION, PLATFORM_SDK_VERSION, etc. should be conditional -# on this - -# This is the canonical definition of the platform version, -# which is the version that we reveal to the end user. -# Update this value when the platform version changes (rather -# than overriding it somewhere else). Can be an arbitrary string. - -# When you change PLATFORM_VERSION for a given PLATFORM_SDK_VERSION -# please add that PLATFORM_VERSION as well as clean up obsolete PLATFORM_VERSION's -# in the following text file: -# cts/tests/tests/os/assets/platform_versions.txt - -# Note that there should be one PLATFORM_VERSION and PLATFORM_VERSION_CODENAME -# entry for each unreleased API level, regardless of -# MIN_PLATFORM_VERSION/MAX_PLATFORM_VERSION. PLATFORM_VERSION is used to -# generate the range of allowed SDK versions, so it must have an entry for every -# unreleased API level targetable by this branch, not just those that are valid -# lunch targets for this branch. - -# Release config flag to override the current version to REL. Note that the -# codename can also be locked to REL by setting it in versino_defaults.mk. -ifneq ($(RELEASE_PLATFORM_VERSION_CODENAME_REL),) - PLATFORM_VERSION_CODENAME.$(TARGET_PLATFORM_VERSION) := REL +ifdef PLATFORM_SECURITY_PATCH + $(error Do not set PLATFORM_SECURITY_PATCH directly. Use RELEASE_PLATFORM_SECURITY_PATCH. value: $(PLATFORM_SECURITY_PATCH)) endif +PLATFORM_SECURITY_PATCH := $(RELEASE_PLATFORM_SECURITY_PATCH) +.KATI_READONLY := PLATFORM_SECURITY_PATCH -PLATFORM_VERSION_CODENAME := $(PLATFORM_VERSION_CODENAME.$(TARGET_PLATFORM_VERSION)) -ifndef PLATFORM_VERSION_CODENAME - # PLATFORM_VERSION_CODENAME falls back to TARGET_PLATFORM_VERSION - PLATFORM_VERSION_CODENAME := $(TARGET_PLATFORM_VERSION) +ifdef PLATFORM_SDK_VERSION + $(error Do not set PLATFORM_SDK_VERSION directly. Use RELEASE_PLATFORM_SDK_VERSION. value: $(PLATFORM_SDK_VERSION)) endif +PLATFORM_SDK_VERSION := $(RELEASE_PLATFORM_SDK_VERSION) +.KATI_READONLY := PLATFORM_SDK_VERSION -# This is all of the *active* development codenames. -# This confusing name is needed because -# all_codenames has been baked into build.prop for ages. -# -# Should be either the same as PLATFORM_VERSION_CODENAME or a comma-separated -# list of additional codenames after PLATFORM_VERSION_CODENAME. -PLATFORM_VERSION_ALL_CODENAMES := - -# Build a list of all active code names. Avoid duplicates, and stop when we -# reach a codename that matches PLATFORM_VERSION_CODENAME (anything beyond -# that is not included in our build). -_versions_in_target := \ - $(call find_and_earlier,$(ALL_VERSIONS),$(TARGET_PLATFORM_VERSION)) -$(foreach version,$(_versions_in_target),\ - $(eval _codename := $(PLATFORM_VERSION_CODENAME.$(version)))\ - $(if $(filter $(_codename),$(PLATFORM_VERSION_ALL_CODENAMES)),,\ - $(eval PLATFORM_VERSION_ALL_CODENAMES += $(_codename)))) - -# And the list of actually all the codenames that are in preview. The -# ALL_CODENAMES variable is sort of a lie for historical reasons and only -# includes codenames up to and including the currently active codename, whereas -# this variable also includes future codenames. For example, while AOSP is still -# merging into U, but V development has started, ALL_CODENAMES will only be U, -# but ALL_PREVIEW_CODENAMES will be U and V. -# -# REL is filtered out of the list. The codename of the current release is -# replaced by "REL" when the build is configured as a release rather than a -# preview. For example, PLATFORM_VERSION_CODENAME.UpsideDownCake will be "REL" -# rather than UpsideDownCake in a -next target when the upcoming release is -# UpsideDownCake. "REL" is a codename (and android.os.Build relies on this: -# https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/android/os/Build.java;l=484-487;drc=316e3d16c9f34212f3beace7695289651d15a071), -# so it should be in PLATFORM_VERSION_ALL_CODENAMES, but it definitely is not a -# preview codename. -PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := -$(foreach version,$(ALL_VERSIONS),\ - $(eval _codename := $(PLATFORM_VERSION_CODENAME.$(version)))\ - $(if $(filter REL,$(_codename)),,\ - $(if $(filter $(_codename),$(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)),,\ - $(eval PLATFORM_VERSION_ALL_PREVIEW_CODENAMES += $(_codename))))) - -# And convert from space separated to comma separated. -PLATFORM_VERSION_ALL_CODENAMES := \ - $(subst $(space),$(comma),$(strip $(PLATFORM_VERSION_ALL_CODENAMES))) -PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := \ - $(subst $(space),$(comma),$(strip $(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES))) - -.KATI_READONLY := \ - PLATFORM_VERSION_CODENAME \ - PLATFORM_VERSION_ALL_CODENAMES \ - PLATFORM_VERSION_ALL_PREVIEW_CODENAMES \ - -ifneq (REL,$(PLATFORM_VERSION_CODENAME)) - codenames := \ - $(subst $(comma),$(space),$(strip $(PLATFORM_VERSION_KNOWN_CODENAMES))) - ifeq ($(filter $(PLATFORM_VERSION_CODENAME),$(codenames)),) - $(error '$(PLATFORM_VERSION_CODENAME)' is not in '$(codenames)'. \ - Add PLATFORM_VERSION_CODENAME to PLATFORM_VERSION_KNOWN_CODENAMES) - endif +ifdef PLATFORM_SDK_EXTENSION_VERSION + $(error Do not set PLATFORM_SDK_EXTENSION_VERSION directly. Use RELEASE_PLATFORM_SDK_EXTENSION_VERSION. value: $(PLATFORM_SDK_EXTENSION_VERSION)) endif +PLATFORM_SDK_EXTENSION_VERSION := $(RELEASE_PLATFORM_SDK_EXTENSION_VERSION) +.KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION + +# This is the sdk extension version that PLATFORM_SDK_VERSION ships with. +PLATFORM_BASE_SDK_EXTENSION_VERSION := $(PLATFORM_SDK_EXTENSION_VERSION) +.KATI_READONLY := PLATFORM_BASE_SDK_EXTENSION_VERSION + +ifdef PLATFORM_VERSION_CODENAME + $(error Do not set PLATFORM_VERSION_CODENAME directly. Use RELEASE_PLATFORM_VERSION. value: $(PLATFORM_VERSION_CODENAME)) +endif +PLATFORM_VERSION_CODENAME := $(RELEASE_PLATFORM_VERSION_CODENAME) +.KATI_READONLY := PLATFORM_VERSION_CODENAME + +ifdef PLATFORM_VERSION_ALL_CODENAMES + $(error Do not set PLATFORM_VERSION_ALL_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_CODENAMES. value: $(PLATFORM_VERSION_ALL_CODENAMES)) +endif +PLATFORM_VERSION_ALL_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_CODENAMES) +.KATI_READONLY := PLATFORM_VERSION_ALL_CODENAMES + +ifdef PLATFORM_VERSION_ALL_PREVIEW_CODENAMES + $(error Do not set PLATFORM_VERSION_ALL_PREVIEW_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES. value: $(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)) +endif +PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES) +.KATI_READONLY := PLATFORM_VERSION_ALL_PREVIEW_CODENAMES + +ifdef PLATFORM_VERSION_LAST_STABLE + $(error Do not set PLATFORM_VERSION_LAST_STABLE directly. Use RELEASE_PLATFORM_VERSION_LAST_STABLE. value: $(PLATFORM_VERSION_CODENAME)) +endif +PLATFORM_VERSION_LAST_STABLE := $(RELEASE_PLATFORM_VERSION_LAST_STABLE) +.KATI_READONLY := PLATFORM_VERSION_LAST_STABLE + + +# This are all known codenames. Should this move into the release config? +PLATFORM_VERSION_KNOWN_CODENAMES := \ +Base Base11 Cupcake Donut Eclair Eclair01 EclairMr1 Froyo Gingerbread GingerbreadMr1 \ +Honeycomb HoneycombMr1 HoneycombMr2 IceCreamSandwich IceCreamSandwichMr1 \ +JellyBean JellyBeanMr1 JellyBeanMr2 Kitkat KitkatWatch Lollipop LollipopMr1 M N NMr1 O OMr1 P \ +Q R S Sv2 Tiramisu UpsideDownCake VanillaIceCream + +# Convert from space separated list to comma separated +PLATFORM_VERSION_KNOWN_CODENAMES := \ + $(call normalize-comma-list,$(PLATFORM_VERSION_KNOWN_CODENAMES)) +.KATI_READONLY := PLATFORM_VERSION_KNOWN_CODENAMES ifndef PLATFORM_VERSION ifeq (REL,$(PLATFORM_VERSION_CODENAME)) From 80e3995c6135a3f49d477f1ff6f12ac608b190eb Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Fri, 20 Oct 2023 19:58:17 +0000 Subject: [PATCH 58/85] Remove viewcompiler binary inclusion Compiled views did not ship and is being removed. Remove the associated binary reference from default inclusion. Bug: 158121974 Test: m Change-Id: I5e64259d258b15ee999522a7b62becc1cd3a6ed1 Ignore-AOSP-First: In topic with internal-first projects --- target/product/base_system.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/product/base_system.mk b/target/product/base_system.mk index 36d4ae97f6..a44661c235 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -288,7 +288,6 @@ PRODUCT_PACKAGES += \ uncrypt \ usbd \ vdc \ - viewcompiler \ voip-common \ vold \ watchdogd \ @@ -386,7 +385,6 @@ PRODUCT_HOST_PACKAGES += \ unwind_info \ unwind_reg_info \ unwind_symbols \ - viewcompiler \ tzdata_host \ tzdata_host_tzdata_apex \ tzlookup.xml_host_tzdata_apex \ From 69b38b52b672a952eb1a72c937f7a7d9929fec63 Mon Sep 17 00:00:00 2001 From: Orhan Uysal Date: Tue, 24 Oct 2023 09:03:22 +0000 Subject: [PATCH 59/85] Revert "Move most version variable out to relase configs." Revert submission 25118098-ap11 Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.corp.google.com/builds/quarterdeck?branch=git_aosp-main-future&target=errorprone-trunk_staging&lkgb=10993884&lkbb=10995208&fkbb=10994141, bug b/307480895 Reverted changes: /q/submissionid:25118098-ap11 Change-Id: I2bc1fc4a9e92a3c4cf8acba3dbaaf61e6fb0774e --- core/all_versions.bzl | 23 +++++ core/envsetup.mk | 43 +++++++-- core/tasks/cts.mk | 2 +- core/version_defaults.mk | 111 ++++++++++++++++++++++++ core/version_util.mk | 182 ++++++++++++++++++++++----------------- 5 files changed, 272 insertions(+), 89 deletions(-) create mode 100644 core/all_versions.bzl create mode 100644 core/version_defaults.mk diff --git a/core/all_versions.bzl b/core/all_versions.bzl new file mode 100644 index 0000000000..33da673431 --- /dev/null +++ b/core/all_versions.bzl @@ -0,0 +1,23 @@ +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +_all_versions = ["OPR1", "OPD1", "OPD2", "OPM1", "OPM2", "PPR1", "PPD1", "PPD2", "PPM1", "PPM2", "QPR1"] + [ + version + subversion + for version in ["Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] + for subversion in ["P1A", "P1B", "P2A", "P2B", "D1A", "D1B", "D2A", "D2B", "Q1A", "Q1B", "Q2A", "Q2B", "Q3A", "Q3B"] +] + +variables_to_export_to_make = { + "ALL_VERSIONS": _all_versions, +} diff --git a/core/envsetup.mk b/core/envsetup.mk index 7ddbf32766..091c2e3050 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -51,15 +51,44 @@ endef include $(BUILD_SYSTEM)/release_config.mk # --------------------------------------------------------------- -# Set up version information -include $(BUILD_SYSTEM)/version_util.mk +# defines ALL_VERSIONS +$(call run-starlark,build/make/core/all_versions.bzl) -# This used to be calculated, but is now fixed and not expected -# to change over time anymore. New code attempting to use a -# variable like IS_AT_LAST_* should instead use a -# build system flag. +# Filters ALL_VERSIONS down to the range [$1, $2], and errors if $1 > $2 or $3 is +# not in [$1, $2] +# $(1): min platform version +# $(2): max platform version +# $(3): default platform version +define allowed-platform-versions +$(strip \ + $(if $(filter $(ALL_VERSIONS),$(1)),, + $(error Invalid MIN_PLATFORM_VERSION '$(1)')) + $(if $(filter $(ALL_VERSIONS),$(2)),, + $(error Invalid MAX_PLATFORM_VERSION '$(2)')) + $(if $(filter $(ALL_VERSIONS),$(3)),, + $(error Invalid RELEASE_PLATFORM_VERSION '$(3)')) -ENABLED_VERSIONS := "OPR1 OPD1 OPD2 OPM1 OPM2 PPR1 PPD1 PPD2 PPM1 PPM2 QPR1 QP1A QP1B QP2A QP2B QD1A QD1B QD2A QD2B QQ1A QQ1B QQ2A QQ2B QQ3A QQ3B RP1A RP1B RP2A RP2B RD1A RD1B RD2A RD2B RQ1A RQ1B RQ2A RQ2B RQ3A RQ3B SP1A SP1B SP2A SP2B SD1A SD1B SD2A SD2B SQ1A SQ1B SQ2A SQ2B SQ3A SQ3B TP1A TP1B TP2A TP2B TD1A TD1B TD2A TD2B TQ1A TQ1B TQ2A TQ2B TQ3A TQ3B UP1A UP1B UP2A UP2B UD1A UD1B UD2A UD2B UQ1A UQ1B UQ2A UQ2B UQ3A UQ3B" + $(eval allowed_versions_ := $(call find_and_earlier,$(ALL_VERSIONS),$(2))) + + $(if $(filter $(allowed_versions_),$(1)),, + $(error MIN_PLATFORM_VERSION '$(1)' must be before MAX_PLATFORM_VERSION '$(2)')) + + $(eval allowed_versions_ := $(1) \ + $(filter-out $(call find_and_earlier,$(allowed_versions_),$(1)),$(allowed_versions_))) + + $(if $(filter $(allowed_versions_),$(3)),, + $(error RELEASE_PLATFORM_VERSION '$(3)' must be between MIN_PLATFORM_VERSION '$(1)' and MAX_PLATFORM_VERSION '$(2)')) + + $(allowed_versions_)) +endef + +#$(warning $(call allowed-platform-versions,OPR1,PPR1,OPR1)) +#$(warning $(call allowed-platform-versions,OPM1,PPR1,OPR1)) + +# Set up version information. +include $(BUILD_SYSTEM)/version_defaults.mk + +ENABLED_VERSIONS := $(call find_and_earlier,$(ALL_VERSIONS),$(TARGET_PLATFORM_VERSION)) $(foreach v,$(ENABLED_VERSIONS), \ $(eval IS_AT_LEAST_$(v) := true)) diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk index b9f0988740..d05640ced1 100644 --- a/core/tasks/cts.mk +++ b/core/tasks/cts.mk @@ -37,7 +37,7 @@ ifneq (,$(wildcard cts/)) cts_platform_release_path := cts/tests/tests/os/assets/platform_releases.txt cts_platform_release_string := $(shell cat $(cts_platform_release_path)) - ifneq (REL,$(PLATFORM_VERSION_CODENAME)) + ifeq ($(RELEASE_PLATFORM_VERSION_CODENAME_REL),) ifeq (,$(findstring $(PLATFORM_VERSION),$(cts_platform_version_string))) define error_msg ============================================================ diff --git a/core/version_defaults.mk b/core/version_defaults.mk new file mode 100644 index 0000000000..8c0b7d98b2 --- /dev/null +++ b/core/version_defaults.mk @@ -0,0 +1,111 @@ +# +# Copyright (C) 2008 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# Handle various build version information. +# +# Guarantees that the following are defined: +# PLATFORM_VERSION +# PLATFORM_DISPLAY_VERSION +# PLATFORM_SDK_VERSION +# PLATFORM_VERSION_CODENAME +# DEFAULT_APP_TARGET_SDK +# BUILD_ID +# BUILD_NUMBER +# PLATFORM_SECURITY_PATCH +# PLATFORM_VNDK_VERSION +# PLATFORM_SYSTEMSDK_VERSIONS +# + +# Look for an optional file containing overrides of the defaults, +# but don't cry if we don't find it. We could just use -include, but +# the build.prop target also wants INTERNAL_BUILD_ID_MAKEFILE to be set +# if the file exists. +# +INTERNAL_BUILD_ID_MAKEFILE := $(wildcard $(BUILD_SYSTEM)/build_id.mk) +ifdef INTERNAL_BUILD_ID_MAKEFILE + include $(INTERNAL_BUILD_ID_MAKEFILE) +endif + +# Set release configuration. The default resides in build/release/build_flags.mk. +MIN_PLATFORM_VERSION := UP1A +MAX_PLATFORM_VERSION := VP1A + +# The last stable version name of the platform that was released. During +# development, this stays at that previous version, while the codename indicates +# further work based on the previous version. +PLATFORM_VERSION_LAST_STABLE := 14 +.KATI_READONLY := PLATFORM_VERSION_LAST_STABLE + +# These are the current development codenames, if the build is not a final +# release build. If this is a final release build, it is simply "REL". +# Note that this may be overridden by RELEASE_VERSION_CODENAME_REL in +# version_util.mk. +PLATFORM_VERSION_CODENAME.UP1A := UpsideDownCake +PLATFORM_VERSION_CODENAME.VP1A := VanillaIceCream + +# This is the user-visible version. In a final release build it should +# be empty to use PLATFORM_VERSION as the user-visible version. For +# a preview release it can be set to a user-friendly value like `12 Preview 1` +PLATFORM_DISPLAY_VERSION := + +ifndef PLATFORM_SDK_VERSION + # This is the canonical definition of the SDK version, which defines + # the set of APIs and functionality available in the platform. It + # is a single integer that increases monotonically as updates to + # the SDK are released. It should only be incremented when the APIs for + # the new release are frozen (so that developers don't write apps against + # intermediate builds). During development, this number remains at the + # SDK version the branch is based on and PLATFORM_VERSION_CODENAME holds + # the code-name of the new development work. + + # When you increment the PLATFORM_SDK_VERSION please ensure you also + # clear out the following text file of all older PLATFORM_VERSION's: + # cts/tests/tests/os/assets/platform_versions.txt + PLATFORM_SDK_VERSION := 34 +endif +.KATI_READONLY := PLATFORM_SDK_VERSION + +# This is the sdk extension version of this tree. +PLATFORM_SDK_EXTENSION_VERSION := 10 +.KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION + +# This is the sdk extension version that PLATFORM_SDK_VERSION ships with. +PLATFORM_BASE_SDK_EXTENSION_VERSION := $(PLATFORM_SDK_EXTENSION_VERSION) +.KATI_READONLY := PLATFORM_BASE_SDK_EXTENSION_VERSION + +# This are all known codenames. +PLATFORM_VERSION_KNOWN_CODENAMES := \ +Base Base11 Cupcake Donut Eclair Eclair01 EclairMr1 Froyo Gingerbread GingerbreadMr1 \ +Honeycomb HoneycombMr1 HoneycombMr2 IceCreamSandwich IceCreamSandwichMr1 \ +JellyBean JellyBeanMr1 JellyBeanMr2 Kitkat KitkatWatch Lollipop LollipopMr1 M N NMr1 O OMr1 P \ +Q R S Sv2 Tiramisu UpsideDownCake VanillaIceCream + +# Convert from space separated list to comma separated +PLATFORM_VERSION_KNOWN_CODENAMES := \ + $(call normalize-comma-list,$(PLATFORM_VERSION_KNOWN_CODENAMES)) +.KATI_READONLY := PLATFORM_VERSION_KNOWN_CODENAMES + +ifndef PLATFORM_SECURITY_PATCH + # Used to indicate the security patch that has been applied to the device. + # It must signify that the build includes all security patches issued up through the designated Android Public Security Bulletin. + # It must be of the form "YYYY-MM-DD" on production devices. + # It must match one of the Android Security Patch Level strings of the Public Security Bulletins. + # If there is no $PLATFORM_SECURITY_PATCH set, keep it empty. + PLATFORM_SECURITY_PATCH := 2023-12-05 +endif + +include $(BUILD_SYSTEM)/version_util.mk diff --git a/core/version_util.mk b/core/version_util.mk index dfa0277993..0cc3442238 100644 --- a/core/version_util.mk +++ b/core/version_util.mk @@ -14,99 +14,119 @@ # limitations under the License. # - -# -# Handle various build version information. -# -# Guarantees that the following are defined: -# PLATFORM_VERSION -# PLATFORM_DISPLAY_VERSION -# PLATFORM_SDK_VERSION -# PLATFORM_SDK_EXTENSION_VERSION -# PLATFORM_VERSION_CODENAME -# DEFAULT_APP_TARGET_SDK -# BUILD_ID -# BUILD_NUMBER -# PLATFORM_SECURITY_PATCH -# PLATFORM_VNDK_VERSION -# PLATFORM_SYSTEMSDK_VERSIONS -# PLATFORM_VERSION_LAST_STABLE -# - -# Look for an optional file containing overrides of the defaults, -# but don't cry if we don't find it. We could just use -include, but -# the build.prop target also wants INTERNAL_BUILD_ID_MAKEFILE to be set -# if the file exists. -# -INTERNAL_BUILD_ID_MAKEFILE := $(wildcard $(BUILD_SYSTEM)/build_id.mk) -ifdef INTERNAL_BUILD_ID_MAKEFILE - include $(INTERNAL_BUILD_ID_MAKEFILE) -endif +ALLOWED_VERSIONS := $(call allowed-platform-versions,\ + $(MIN_PLATFORM_VERSION),\ + $(MAX_PLATFORM_VERSION),\ + $(RELEASE_PLATFORM_VERSION)) ifdef TARGET_PLATFORM_VERSION $(error Do not set TARGET_PLATFORM_VERSION directly. Use RELEASE_PLATFORM_VERSION. value: $(TARGET_PLATFORM_VERSION)) endif + TARGET_PLATFORM_VERSION := $(RELEASE_PLATFORM_VERSION) + +ifeq (,$(filter $(ALLOWED_VERSIONS), $(TARGET_PLATFORM_VERSION))) + $(warning Invalid TARGET_PLATFORM_VERSION '$(TARGET_PLATFORM_VERSION)', must be one of) + $(error $(ALLOWED_VERSIONS)) +endif +ALLOWED_VERSIONS := +MIN_PLATFORM_VERSION := +MAX_PLATFORM_VERSION := + .KATI_READONLY := TARGET_PLATFORM_VERSION -ifdef PLATFORM_SECURITY_PATCH - $(error Do not set PLATFORM_SECURITY_PATCH directly. Use RELEASE_PLATFORM_SECURITY_PATCH. value: $(PLATFORM_SECURITY_PATCH)) +# Default versions for each TARGET_PLATFORM_VERSION +# TODO: PLATFORM_VERSION, PLATFORM_SDK_VERSION, etc. should be conditional +# on this + +# This is the canonical definition of the platform version, +# which is the version that we reveal to the end user. +# Update this value when the platform version changes (rather +# than overriding it somewhere else). Can be an arbitrary string. + +# When you change PLATFORM_VERSION for a given PLATFORM_SDK_VERSION +# please add that PLATFORM_VERSION as well as clean up obsolete PLATFORM_VERSION's +# in the following text file: +# cts/tests/tests/os/assets/platform_versions.txt + +# Note that there should be one PLATFORM_VERSION and PLATFORM_VERSION_CODENAME +# entry for each unreleased API level, regardless of +# MIN_PLATFORM_VERSION/MAX_PLATFORM_VERSION. PLATFORM_VERSION is used to +# generate the range of allowed SDK versions, so it must have an entry for every +# unreleased API level targetable by this branch, not just those that are valid +# lunch targets for this branch. + +# Release config flag to override the current version to REL. Note that the +# codename can also be locked to REL by setting it in versino_defaults.mk. +ifneq ($(RELEASE_PLATFORM_VERSION_CODENAME_REL),) + PLATFORM_VERSION_CODENAME.$(TARGET_PLATFORM_VERSION) := REL endif -PLATFORM_SECURITY_PATCH := $(RELEASE_PLATFORM_SECURITY_PATCH) -.KATI_READONLY := PLATFORM_SECURITY_PATCH -ifdef PLATFORM_SDK_VERSION - $(error Do not set PLATFORM_SDK_VERSION directly. Use RELEASE_PLATFORM_SDK_VERSION. value: $(PLATFORM_SDK_VERSION)) +PLATFORM_VERSION_CODENAME := $(PLATFORM_VERSION_CODENAME.$(TARGET_PLATFORM_VERSION)) +ifndef PLATFORM_VERSION_CODENAME + # PLATFORM_VERSION_CODENAME falls back to TARGET_PLATFORM_VERSION + PLATFORM_VERSION_CODENAME := $(TARGET_PLATFORM_VERSION) endif -PLATFORM_SDK_VERSION := $(RELEASE_PLATFORM_SDK_VERSION) -.KATI_READONLY := PLATFORM_SDK_VERSION -ifdef PLATFORM_SDK_EXTENSION_VERSION - $(error Do not set PLATFORM_SDK_EXTENSION_VERSION directly. Use RELEASE_PLATFORM_SDK_EXTENSION_VERSION. value: $(PLATFORM_SDK_EXTENSION_VERSION)) +# This is all of the *active* development codenames. +# This confusing name is needed because +# all_codenames has been baked into build.prop for ages. +# +# Should be either the same as PLATFORM_VERSION_CODENAME or a comma-separated +# list of additional codenames after PLATFORM_VERSION_CODENAME. +PLATFORM_VERSION_ALL_CODENAMES := + +# Build a list of all active code names. Avoid duplicates, and stop when we +# reach a codename that matches PLATFORM_VERSION_CODENAME (anything beyond +# that is not included in our build). +_versions_in_target := \ + $(call find_and_earlier,$(ALL_VERSIONS),$(TARGET_PLATFORM_VERSION)) +$(foreach version,$(_versions_in_target),\ + $(eval _codename := $(PLATFORM_VERSION_CODENAME.$(version)))\ + $(if $(filter $(_codename),$(PLATFORM_VERSION_ALL_CODENAMES)),,\ + $(eval PLATFORM_VERSION_ALL_CODENAMES += $(_codename)))) + +# And the list of actually all the codenames that are in preview. The +# ALL_CODENAMES variable is sort of a lie for historical reasons and only +# includes codenames up to and including the currently active codename, whereas +# this variable also includes future codenames. For example, while AOSP is still +# merging into U, but V development has started, ALL_CODENAMES will only be U, +# but ALL_PREVIEW_CODENAMES will be U and V. +# +# REL is filtered out of the list. The codename of the current release is +# replaced by "REL" when the build is configured as a release rather than a +# preview. For example, PLATFORM_VERSION_CODENAME.UpsideDownCake will be "REL" +# rather than UpsideDownCake in a -next target when the upcoming release is +# UpsideDownCake. "REL" is a codename (and android.os.Build relies on this: +# https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/android/os/Build.java;l=484-487;drc=316e3d16c9f34212f3beace7695289651d15a071), +# so it should be in PLATFORM_VERSION_ALL_CODENAMES, but it definitely is not a +# preview codename. +PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := +$(foreach version,$(ALL_VERSIONS),\ + $(eval _codename := $(PLATFORM_VERSION_CODENAME.$(version)))\ + $(if $(filter REL,$(_codename)),,\ + $(if $(filter $(_codename),$(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)),,\ + $(eval PLATFORM_VERSION_ALL_PREVIEW_CODENAMES += $(_codename))))) + +# And convert from space separated to comma separated. +PLATFORM_VERSION_ALL_CODENAMES := \ + $(subst $(space),$(comma),$(strip $(PLATFORM_VERSION_ALL_CODENAMES))) +PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := \ + $(subst $(space),$(comma),$(strip $(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES))) + +.KATI_READONLY := \ + PLATFORM_VERSION_CODENAME \ + PLATFORM_VERSION_ALL_CODENAMES \ + PLATFORM_VERSION_ALL_PREVIEW_CODENAMES \ + +ifneq (REL,$(PLATFORM_VERSION_CODENAME)) + codenames := \ + $(subst $(comma),$(space),$(strip $(PLATFORM_VERSION_KNOWN_CODENAMES))) + ifeq ($(filter $(PLATFORM_VERSION_CODENAME),$(codenames)),) + $(error '$(PLATFORM_VERSION_CODENAME)' is not in '$(codenames)'. \ + Add PLATFORM_VERSION_CODENAME to PLATFORM_VERSION_KNOWN_CODENAMES) + endif endif -PLATFORM_SDK_EXTENSION_VERSION := $(RELEASE_PLATFORM_SDK_EXTENSION_VERSION) -.KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION - -# This is the sdk extension version that PLATFORM_SDK_VERSION ships with. -PLATFORM_BASE_SDK_EXTENSION_VERSION := $(PLATFORM_SDK_EXTENSION_VERSION) -.KATI_READONLY := PLATFORM_BASE_SDK_EXTENSION_VERSION - -ifdef PLATFORM_VERSION_CODENAME - $(error Do not set PLATFORM_VERSION_CODENAME directly. Use RELEASE_PLATFORM_VERSION. value: $(PLATFORM_VERSION_CODENAME)) -endif -PLATFORM_VERSION_CODENAME := $(RELEASE_PLATFORM_VERSION_CODENAME) -.KATI_READONLY := PLATFORM_VERSION_CODENAME - -ifdef PLATFORM_VERSION_ALL_CODENAMES - $(error Do not set PLATFORM_VERSION_ALL_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_CODENAMES. value: $(PLATFORM_VERSION_ALL_CODENAMES)) -endif -PLATFORM_VERSION_ALL_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_CODENAMES) -.KATI_READONLY := PLATFORM_VERSION_ALL_CODENAMES - -ifdef PLATFORM_VERSION_ALL_PREVIEW_CODENAMES - $(error Do not set PLATFORM_VERSION_ALL_PREVIEW_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES. value: $(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)) -endif -PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES) -.KATI_READONLY := PLATFORM_VERSION_ALL_PREVIEW_CODENAMES - -ifdef PLATFORM_VERSION_LAST_STABLE - $(error Do not set PLATFORM_VERSION_LAST_STABLE directly. Use RELEASE_PLATFORM_VERSION_LAST_STABLE. value: $(PLATFORM_VERSION_CODENAME)) -endif -PLATFORM_VERSION_LAST_STABLE := $(RELEASE_PLATFORM_VERSION_LAST_STABLE) -.KATI_READONLY := PLATFORM_VERSION_LAST_STABLE - - -# This are all known codenames. Should this move into the release config? -PLATFORM_VERSION_KNOWN_CODENAMES := \ -Base Base11 Cupcake Donut Eclair Eclair01 EclairMr1 Froyo Gingerbread GingerbreadMr1 \ -Honeycomb HoneycombMr1 HoneycombMr2 IceCreamSandwich IceCreamSandwichMr1 \ -JellyBean JellyBeanMr1 JellyBeanMr2 Kitkat KitkatWatch Lollipop LollipopMr1 M N NMr1 O OMr1 P \ -Q R S Sv2 Tiramisu UpsideDownCake VanillaIceCream - -# Convert from space separated list to comma separated -PLATFORM_VERSION_KNOWN_CODENAMES := \ - $(call normalize-comma-list,$(PLATFORM_VERSION_KNOWN_CODENAMES)) -.KATI_READONLY := PLATFORM_VERSION_KNOWN_CODENAMES ifndef PLATFORM_VERSION ifeq (REL,$(PLATFORM_VERSION_CODENAME)) From 186888303dfce8a51bdadca8b3bafc890340384a Mon Sep 17 00:00:00 2001 From: Baligh Uddin Date: Tue, 24 Oct 2023 14:18:47 +0000 Subject: [PATCH 60/85] Revert^2 "Move most version variable out to relase configs." 69b38b52b672a952eb1a72c937f7a7d9929fec63 Change-Id: I67c9ac7869fcad54f3b0b93a04e9dda5f97861d6 Bug: 306702353 Test: TH and local --- core/all_versions.bzl | 23 ----- core/envsetup.mk | 43 ++------- core/tasks/cts.mk | 2 +- core/version_defaults.mk | 111 ------------------------ core/version_util.mk | 182 +++++++++++++++++---------------------- 5 files changed, 89 insertions(+), 272 deletions(-) delete mode 100644 core/all_versions.bzl delete mode 100644 core/version_defaults.mk diff --git a/core/all_versions.bzl b/core/all_versions.bzl deleted file mode 100644 index 33da673431..0000000000 --- a/core/all_versions.bzl +++ /dev/null @@ -1,23 +0,0 @@ -# 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -_all_versions = ["OPR1", "OPD1", "OPD2", "OPM1", "OPM2", "PPR1", "PPD1", "PPD2", "PPM1", "PPM2", "QPR1"] + [ - version + subversion - for version in ["Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] - for subversion in ["P1A", "P1B", "P2A", "P2B", "D1A", "D1B", "D2A", "D2B", "Q1A", "Q1B", "Q2A", "Q2B", "Q3A", "Q3B"] -] - -variables_to_export_to_make = { - "ALL_VERSIONS": _all_versions, -} diff --git a/core/envsetup.mk b/core/envsetup.mk index 091c2e3050..7ddbf32766 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -51,44 +51,15 @@ endef include $(BUILD_SYSTEM)/release_config.mk # --------------------------------------------------------------- -# defines ALL_VERSIONS -$(call run-starlark,build/make/core/all_versions.bzl) +# Set up version information +include $(BUILD_SYSTEM)/version_util.mk -# Filters ALL_VERSIONS down to the range [$1, $2], and errors if $1 > $2 or $3 is -# not in [$1, $2] -# $(1): min platform version -# $(2): max platform version -# $(3): default platform version -define allowed-platform-versions -$(strip \ - $(if $(filter $(ALL_VERSIONS),$(1)),, - $(error Invalid MIN_PLATFORM_VERSION '$(1)')) - $(if $(filter $(ALL_VERSIONS),$(2)),, - $(error Invalid MAX_PLATFORM_VERSION '$(2)')) - $(if $(filter $(ALL_VERSIONS),$(3)),, - $(error Invalid RELEASE_PLATFORM_VERSION '$(3)')) +# This used to be calculated, but is now fixed and not expected +# to change over time anymore. New code attempting to use a +# variable like IS_AT_LAST_* should instead use a +# build system flag. - $(eval allowed_versions_ := $(call find_and_earlier,$(ALL_VERSIONS),$(2))) - - $(if $(filter $(allowed_versions_),$(1)),, - $(error MIN_PLATFORM_VERSION '$(1)' must be before MAX_PLATFORM_VERSION '$(2)')) - - $(eval allowed_versions_ := $(1) \ - $(filter-out $(call find_and_earlier,$(allowed_versions_),$(1)),$(allowed_versions_))) - - $(if $(filter $(allowed_versions_),$(3)),, - $(error RELEASE_PLATFORM_VERSION '$(3)' must be between MIN_PLATFORM_VERSION '$(1)' and MAX_PLATFORM_VERSION '$(2)')) - - $(allowed_versions_)) -endef - -#$(warning $(call allowed-platform-versions,OPR1,PPR1,OPR1)) -#$(warning $(call allowed-platform-versions,OPM1,PPR1,OPR1)) - -# Set up version information. -include $(BUILD_SYSTEM)/version_defaults.mk - -ENABLED_VERSIONS := $(call find_and_earlier,$(ALL_VERSIONS),$(TARGET_PLATFORM_VERSION)) +ENABLED_VERSIONS := "OPR1 OPD1 OPD2 OPM1 OPM2 PPR1 PPD1 PPD2 PPM1 PPM2 QPR1 QP1A QP1B QP2A QP2B QD1A QD1B QD2A QD2B QQ1A QQ1B QQ2A QQ2B QQ3A QQ3B RP1A RP1B RP2A RP2B RD1A RD1B RD2A RD2B RQ1A RQ1B RQ2A RQ2B RQ3A RQ3B SP1A SP1B SP2A SP2B SD1A SD1B SD2A SD2B SQ1A SQ1B SQ2A SQ2B SQ3A SQ3B TP1A TP1B TP2A TP2B TD1A TD1B TD2A TD2B TQ1A TQ1B TQ2A TQ2B TQ3A TQ3B UP1A UP1B UP2A UP2B UD1A UD1B UD2A UD2B UQ1A UQ1B UQ2A UQ2B UQ3A UQ3B" $(foreach v,$(ENABLED_VERSIONS), \ $(eval IS_AT_LEAST_$(v) := true)) diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk index d05640ced1..b9f0988740 100644 --- a/core/tasks/cts.mk +++ b/core/tasks/cts.mk @@ -37,7 +37,7 @@ ifneq (,$(wildcard cts/)) cts_platform_release_path := cts/tests/tests/os/assets/platform_releases.txt cts_platform_release_string := $(shell cat $(cts_platform_release_path)) - ifeq ($(RELEASE_PLATFORM_VERSION_CODENAME_REL),) + ifneq (REL,$(PLATFORM_VERSION_CODENAME)) ifeq (,$(findstring $(PLATFORM_VERSION),$(cts_platform_version_string))) define error_msg ============================================================ diff --git a/core/version_defaults.mk b/core/version_defaults.mk deleted file mode 100644 index 8c0b7d98b2..0000000000 --- a/core/version_defaults.mk +++ /dev/null @@ -1,111 +0,0 @@ -# -# Copyright (C) 2008 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# -# Handle various build version information. -# -# Guarantees that the following are defined: -# PLATFORM_VERSION -# PLATFORM_DISPLAY_VERSION -# PLATFORM_SDK_VERSION -# PLATFORM_VERSION_CODENAME -# DEFAULT_APP_TARGET_SDK -# BUILD_ID -# BUILD_NUMBER -# PLATFORM_SECURITY_PATCH -# PLATFORM_VNDK_VERSION -# PLATFORM_SYSTEMSDK_VERSIONS -# - -# Look for an optional file containing overrides of the defaults, -# but don't cry if we don't find it. We could just use -include, but -# the build.prop target also wants INTERNAL_BUILD_ID_MAKEFILE to be set -# if the file exists. -# -INTERNAL_BUILD_ID_MAKEFILE := $(wildcard $(BUILD_SYSTEM)/build_id.mk) -ifdef INTERNAL_BUILD_ID_MAKEFILE - include $(INTERNAL_BUILD_ID_MAKEFILE) -endif - -# Set release configuration. The default resides in build/release/build_flags.mk. -MIN_PLATFORM_VERSION := UP1A -MAX_PLATFORM_VERSION := VP1A - -# The last stable version name of the platform that was released. During -# development, this stays at that previous version, while the codename indicates -# further work based on the previous version. -PLATFORM_VERSION_LAST_STABLE := 14 -.KATI_READONLY := PLATFORM_VERSION_LAST_STABLE - -# These are the current development codenames, if the build is not a final -# release build. If this is a final release build, it is simply "REL". -# Note that this may be overridden by RELEASE_VERSION_CODENAME_REL in -# version_util.mk. -PLATFORM_VERSION_CODENAME.UP1A := UpsideDownCake -PLATFORM_VERSION_CODENAME.VP1A := VanillaIceCream - -# This is the user-visible version. In a final release build it should -# be empty to use PLATFORM_VERSION as the user-visible version. For -# a preview release it can be set to a user-friendly value like `12 Preview 1` -PLATFORM_DISPLAY_VERSION := - -ifndef PLATFORM_SDK_VERSION - # This is the canonical definition of the SDK version, which defines - # the set of APIs and functionality available in the platform. It - # is a single integer that increases monotonically as updates to - # the SDK are released. It should only be incremented when the APIs for - # the new release are frozen (so that developers don't write apps against - # intermediate builds). During development, this number remains at the - # SDK version the branch is based on and PLATFORM_VERSION_CODENAME holds - # the code-name of the new development work. - - # When you increment the PLATFORM_SDK_VERSION please ensure you also - # clear out the following text file of all older PLATFORM_VERSION's: - # cts/tests/tests/os/assets/platform_versions.txt - PLATFORM_SDK_VERSION := 34 -endif -.KATI_READONLY := PLATFORM_SDK_VERSION - -# This is the sdk extension version of this tree. -PLATFORM_SDK_EXTENSION_VERSION := 10 -.KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION - -# This is the sdk extension version that PLATFORM_SDK_VERSION ships with. -PLATFORM_BASE_SDK_EXTENSION_VERSION := $(PLATFORM_SDK_EXTENSION_VERSION) -.KATI_READONLY := PLATFORM_BASE_SDK_EXTENSION_VERSION - -# This are all known codenames. -PLATFORM_VERSION_KNOWN_CODENAMES := \ -Base Base11 Cupcake Donut Eclair Eclair01 EclairMr1 Froyo Gingerbread GingerbreadMr1 \ -Honeycomb HoneycombMr1 HoneycombMr2 IceCreamSandwich IceCreamSandwichMr1 \ -JellyBean JellyBeanMr1 JellyBeanMr2 Kitkat KitkatWatch Lollipop LollipopMr1 M N NMr1 O OMr1 P \ -Q R S Sv2 Tiramisu UpsideDownCake VanillaIceCream - -# Convert from space separated list to comma separated -PLATFORM_VERSION_KNOWN_CODENAMES := \ - $(call normalize-comma-list,$(PLATFORM_VERSION_KNOWN_CODENAMES)) -.KATI_READONLY := PLATFORM_VERSION_KNOWN_CODENAMES - -ifndef PLATFORM_SECURITY_PATCH - # Used to indicate the security patch that has been applied to the device. - # It must signify that the build includes all security patches issued up through the designated Android Public Security Bulletin. - # It must be of the form "YYYY-MM-DD" on production devices. - # It must match one of the Android Security Patch Level strings of the Public Security Bulletins. - # If there is no $PLATFORM_SECURITY_PATCH set, keep it empty. - PLATFORM_SECURITY_PATCH := 2023-12-05 -endif - -include $(BUILD_SYSTEM)/version_util.mk diff --git a/core/version_util.mk b/core/version_util.mk index 0cc3442238..dfa0277993 100644 --- a/core/version_util.mk +++ b/core/version_util.mk @@ -14,119 +14,99 @@ # limitations under the License. # -ALLOWED_VERSIONS := $(call allowed-platform-versions,\ - $(MIN_PLATFORM_VERSION),\ - $(MAX_PLATFORM_VERSION),\ - $(RELEASE_PLATFORM_VERSION)) + +# +# Handle various build version information. +# +# Guarantees that the following are defined: +# PLATFORM_VERSION +# PLATFORM_DISPLAY_VERSION +# PLATFORM_SDK_VERSION +# PLATFORM_SDK_EXTENSION_VERSION +# PLATFORM_VERSION_CODENAME +# DEFAULT_APP_TARGET_SDK +# BUILD_ID +# BUILD_NUMBER +# PLATFORM_SECURITY_PATCH +# PLATFORM_VNDK_VERSION +# PLATFORM_SYSTEMSDK_VERSIONS +# PLATFORM_VERSION_LAST_STABLE +# + +# Look for an optional file containing overrides of the defaults, +# but don't cry if we don't find it. We could just use -include, but +# the build.prop target also wants INTERNAL_BUILD_ID_MAKEFILE to be set +# if the file exists. +# +INTERNAL_BUILD_ID_MAKEFILE := $(wildcard $(BUILD_SYSTEM)/build_id.mk) +ifdef INTERNAL_BUILD_ID_MAKEFILE + include $(INTERNAL_BUILD_ID_MAKEFILE) +endif ifdef TARGET_PLATFORM_VERSION $(error Do not set TARGET_PLATFORM_VERSION directly. Use RELEASE_PLATFORM_VERSION. value: $(TARGET_PLATFORM_VERSION)) endif - TARGET_PLATFORM_VERSION := $(RELEASE_PLATFORM_VERSION) - -ifeq (,$(filter $(ALLOWED_VERSIONS), $(TARGET_PLATFORM_VERSION))) - $(warning Invalid TARGET_PLATFORM_VERSION '$(TARGET_PLATFORM_VERSION)', must be one of) - $(error $(ALLOWED_VERSIONS)) -endif -ALLOWED_VERSIONS := -MIN_PLATFORM_VERSION := -MAX_PLATFORM_VERSION := - .KATI_READONLY := TARGET_PLATFORM_VERSION -# Default versions for each TARGET_PLATFORM_VERSION -# TODO: PLATFORM_VERSION, PLATFORM_SDK_VERSION, etc. should be conditional -# on this - -# This is the canonical definition of the platform version, -# which is the version that we reveal to the end user. -# Update this value when the platform version changes (rather -# than overriding it somewhere else). Can be an arbitrary string. - -# When you change PLATFORM_VERSION for a given PLATFORM_SDK_VERSION -# please add that PLATFORM_VERSION as well as clean up obsolete PLATFORM_VERSION's -# in the following text file: -# cts/tests/tests/os/assets/platform_versions.txt - -# Note that there should be one PLATFORM_VERSION and PLATFORM_VERSION_CODENAME -# entry for each unreleased API level, regardless of -# MIN_PLATFORM_VERSION/MAX_PLATFORM_VERSION. PLATFORM_VERSION is used to -# generate the range of allowed SDK versions, so it must have an entry for every -# unreleased API level targetable by this branch, not just those that are valid -# lunch targets for this branch. - -# Release config flag to override the current version to REL. Note that the -# codename can also be locked to REL by setting it in versino_defaults.mk. -ifneq ($(RELEASE_PLATFORM_VERSION_CODENAME_REL),) - PLATFORM_VERSION_CODENAME.$(TARGET_PLATFORM_VERSION) := REL +ifdef PLATFORM_SECURITY_PATCH + $(error Do not set PLATFORM_SECURITY_PATCH directly. Use RELEASE_PLATFORM_SECURITY_PATCH. value: $(PLATFORM_SECURITY_PATCH)) endif +PLATFORM_SECURITY_PATCH := $(RELEASE_PLATFORM_SECURITY_PATCH) +.KATI_READONLY := PLATFORM_SECURITY_PATCH -PLATFORM_VERSION_CODENAME := $(PLATFORM_VERSION_CODENAME.$(TARGET_PLATFORM_VERSION)) -ifndef PLATFORM_VERSION_CODENAME - # PLATFORM_VERSION_CODENAME falls back to TARGET_PLATFORM_VERSION - PLATFORM_VERSION_CODENAME := $(TARGET_PLATFORM_VERSION) +ifdef PLATFORM_SDK_VERSION + $(error Do not set PLATFORM_SDK_VERSION directly. Use RELEASE_PLATFORM_SDK_VERSION. value: $(PLATFORM_SDK_VERSION)) endif +PLATFORM_SDK_VERSION := $(RELEASE_PLATFORM_SDK_VERSION) +.KATI_READONLY := PLATFORM_SDK_VERSION -# This is all of the *active* development codenames. -# This confusing name is needed because -# all_codenames has been baked into build.prop for ages. -# -# Should be either the same as PLATFORM_VERSION_CODENAME or a comma-separated -# list of additional codenames after PLATFORM_VERSION_CODENAME. -PLATFORM_VERSION_ALL_CODENAMES := - -# Build a list of all active code names. Avoid duplicates, and stop when we -# reach a codename that matches PLATFORM_VERSION_CODENAME (anything beyond -# that is not included in our build). -_versions_in_target := \ - $(call find_and_earlier,$(ALL_VERSIONS),$(TARGET_PLATFORM_VERSION)) -$(foreach version,$(_versions_in_target),\ - $(eval _codename := $(PLATFORM_VERSION_CODENAME.$(version)))\ - $(if $(filter $(_codename),$(PLATFORM_VERSION_ALL_CODENAMES)),,\ - $(eval PLATFORM_VERSION_ALL_CODENAMES += $(_codename)))) - -# And the list of actually all the codenames that are in preview. The -# ALL_CODENAMES variable is sort of a lie for historical reasons and only -# includes codenames up to and including the currently active codename, whereas -# this variable also includes future codenames. For example, while AOSP is still -# merging into U, but V development has started, ALL_CODENAMES will only be U, -# but ALL_PREVIEW_CODENAMES will be U and V. -# -# REL is filtered out of the list. The codename of the current release is -# replaced by "REL" when the build is configured as a release rather than a -# preview. For example, PLATFORM_VERSION_CODENAME.UpsideDownCake will be "REL" -# rather than UpsideDownCake in a -next target when the upcoming release is -# UpsideDownCake. "REL" is a codename (and android.os.Build relies on this: -# https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/android/os/Build.java;l=484-487;drc=316e3d16c9f34212f3beace7695289651d15a071), -# so it should be in PLATFORM_VERSION_ALL_CODENAMES, but it definitely is not a -# preview codename. -PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := -$(foreach version,$(ALL_VERSIONS),\ - $(eval _codename := $(PLATFORM_VERSION_CODENAME.$(version)))\ - $(if $(filter REL,$(_codename)),,\ - $(if $(filter $(_codename),$(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)),,\ - $(eval PLATFORM_VERSION_ALL_PREVIEW_CODENAMES += $(_codename))))) - -# And convert from space separated to comma separated. -PLATFORM_VERSION_ALL_CODENAMES := \ - $(subst $(space),$(comma),$(strip $(PLATFORM_VERSION_ALL_CODENAMES))) -PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := \ - $(subst $(space),$(comma),$(strip $(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES))) - -.KATI_READONLY := \ - PLATFORM_VERSION_CODENAME \ - PLATFORM_VERSION_ALL_CODENAMES \ - PLATFORM_VERSION_ALL_PREVIEW_CODENAMES \ - -ifneq (REL,$(PLATFORM_VERSION_CODENAME)) - codenames := \ - $(subst $(comma),$(space),$(strip $(PLATFORM_VERSION_KNOWN_CODENAMES))) - ifeq ($(filter $(PLATFORM_VERSION_CODENAME),$(codenames)),) - $(error '$(PLATFORM_VERSION_CODENAME)' is not in '$(codenames)'. \ - Add PLATFORM_VERSION_CODENAME to PLATFORM_VERSION_KNOWN_CODENAMES) - endif +ifdef PLATFORM_SDK_EXTENSION_VERSION + $(error Do not set PLATFORM_SDK_EXTENSION_VERSION directly. Use RELEASE_PLATFORM_SDK_EXTENSION_VERSION. value: $(PLATFORM_SDK_EXTENSION_VERSION)) endif +PLATFORM_SDK_EXTENSION_VERSION := $(RELEASE_PLATFORM_SDK_EXTENSION_VERSION) +.KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION + +# This is the sdk extension version that PLATFORM_SDK_VERSION ships with. +PLATFORM_BASE_SDK_EXTENSION_VERSION := $(PLATFORM_SDK_EXTENSION_VERSION) +.KATI_READONLY := PLATFORM_BASE_SDK_EXTENSION_VERSION + +ifdef PLATFORM_VERSION_CODENAME + $(error Do not set PLATFORM_VERSION_CODENAME directly. Use RELEASE_PLATFORM_VERSION. value: $(PLATFORM_VERSION_CODENAME)) +endif +PLATFORM_VERSION_CODENAME := $(RELEASE_PLATFORM_VERSION_CODENAME) +.KATI_READONLY := PLATFORM_VERSION_CODENAME + +ifdef PLATFORM_VERSION_ALL_CODENAMES + $(error Do not set PLATFORM_VERSION_ALL_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_CODENAMES. value: $(PLATFORM_VERSION_ALL_CODENAMES)) +endif +PLATFORM_VERSION_ALL_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_CODENAMES) +.KATI_READONLY := PLATFORM_VERSION_ALL_CODENAMES + +ifdef PLATFORM_VERSION_ALL_PREVIEW_CODENAMES + $(error Do not set PLATFORM_VERSION_ALL_PREVIEW_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES. value: $(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)) +endif +PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES) +.KATI_READONLY := PLATFORM_VERSION_ALL_PREVIEW_CODENAMES + +ifdef PLATFORM_VERSION_LAST_STABLE + $(error Do not set PLATFORM_VERSION_LAST_STABLE directly. Use RELEASE_PLATFORM_VERSION_LAST_STABLE. value: $(PLATFORM_VERSION_CODENAME)) +endif +PLATFORM_VERSION_LAST_STABLE := $(RELEASE_PLATFORM_VERSION_LAST_STABLE) +.KATI_READONLY := PLATFORM_VERSION_LAST_STABLE + + +# This are all known codenames. Should this move into the release config? +PLATFORM_VERSION_KNOWN_CODENAMES := \ +Base Base11 Cupcake Donut Eclair Eclair01 EclairMr1 Froyo Gingerbread GingerbreadMr1 \ +Honeycomb HoneycombMr1 HoneycombMr2 IceCreamSandwich IceCreamSandwichMr1 \ +JellyBean JellyBeanMr1 JellyBeanMr2 Kitkat KitkatWatch Lollipop LollipopMr1 M N NMr1 O OMr1 P \ +Q R S Sv2 Tiramisu UpsideDownCake VanillaIceCream + +# Convert from space separated list to comma separated +PLATFORM_VERSION_KNOWN_CODENAMES := \ + $(call normalize-comma-list,$(PLATFORM_VERSION_KNOWN_CODENAMES)) +.KATI_READONLY := PLATFORM_VERSION_KNOWN_CODENAMES ifndef PLATFORM_VERSION ifeq (REL,$(PLATFORM_VERSION_CODENAME)) From 7e2a56d9eba537bc036dfb948eaedbae033758a4 Mon Sep 17 00:00:00 2001 From: Jeff Hamilton Date: Thu, 19 Oct 2023 04:54:15 +0000 Subject: [PATCH 61/85] Move most version variable out to relase configs. This allows finer control of the version variables per release config, and removes a lot of computed logic in favor of just directly setting the values. Bug: 306702353 Test: lunch -next-userdebug && m -j98 Change-Id: I9edc7171d124f0cfa540fea6f0e06ba877910444 Ignore-AOSP-First: Changes in internal projects first. Merged-In: I9edc7171d124f0cfa540fea6f0e06ba877910444 --- core/all_versions.bzl | 23 ----- core/envsetup.mk | 43 ++------- core/tasks/cts.mk | 2 +- core/version_defaults.mk | 111 ------------------------ core/version_util.mk | 182 +++++++++++++++++---------------------- 5 files changed, 89 insertions(+), 272 deletions(-) delete mode 100644 core/all_versions.bzl delete mode 100644 core/version_defaults.mk diff --git a/core/all_versions.bzl b/core/all_versions.bzl deleted file mode 100644 index 33da673431..0000000000 --- a/core/all_versions.bzl +++ /dev/null @@ -1,23 +0,0 @@ -# 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -_all_versions = ["OPR1", "OPD1", "OPD2", "OPM1", "OPM2", "PPR1", "PPD1", "PPD2", "PPM1", "PPM2", "QPR1"] + [ - version + subversion - for version in ["Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] - for subversion in ["P1A", "P1B", "P2A", "P2B", "D1A", "D1B", "D2A", "D2B", "Q1A", "Q1B", "Q2A", "Q2B", "Q3A", "Q3B"] -] - -variables_to_export_to_make = { - "ALL_VERSIONS": _all_versions, -} diff --git a/core/envsetup.mk b/core/envsetup.mk index 091c2e3050..7ddbf32766 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -51,44 +51,15 @@ endef include $(BUILD_SYSTEM)/release_config.mk # --------------------------------------------------------------- -# defines ALL_VERSIONS -$(call run-starlark,build/make/core/all_versions.bzl) +# Set up version information +include $(BUILD_SYSTEM)/version_util.mk -# Filters ALL_VERSIONS down to the range [$1, $2], and errors if $1 > $2 or $3 is -# not in [$1, $2] -# $(1): min platform version -# $(2): max platform version -# $(3): default platform version -define allowed-platform-versions -$(strip \ - $(if $(filter $(ALL_VERSIONS),$(1)),, - $(error Invalid MIN_PLATFORM_VERSION '$(1)')) - $(if $(filter $(ALL_VERSIONS),$(2)),, - $(error Invalid MAX_PLATFORM_VERSION '$(2)')) - $(if $(filter $(ALL_VERSIONS),$(3)),, - $(error Invalid RELEASE_PLATFORM_VERSION '$(3)')) +# This used to be calculated, but is now fixed and not expected +# to change over time anymore. New code attempting to use a +# variable like IS_AT_LAST_* should instead use a +# build system flag. - $(eval allowed_versions_ := $(call find_and_earlier,$(ALL_VERSIONS),$(2))) - - $(if $(filter $(allowed_versions_),$(1)),, - $(error MIN_PLATFORM_VERSION '$(1)' must be before MAX_PLATFORM_VERSION '$(2)')) - - $(eval allowed_versions_ := $(1) \ - $(filter-out $(call find_and_earlier,$(allowed_versions_),$(1)),$(allowed_versions_))) - - $(if $(filter $(allowed_versions_),$(3)),, - $(error RELEASE_PLATFORM_VERSION '$(3)' must be between MIN_PLATFORM_VERSION '$(1)' and MAX_PLATFORM_VERSION '$(2)')) - - $(allowed_versions_)) -endef - -#$(warning $(call allowed-platform-versions,OPR1,PPR1,OPR1)) -#$(warning $(call allowed-platform-versions,OPM1,PPR1,OPR1)) - -# Set up version information. -include $(BUILD_SYSTEM)/version_defaults.mk - -ENABLED_VERSIONS := $(call find_and_earlier,$(ALL_VERSIONS),$(TARGET_PLATFORM_VERSION)) +ENABLED_VERSIONS := "OPR1 OPD1 OPD2 OPM1 OPM2 PPR1 PPD1 PPD2 PPM1 PPM2 QPR1 QP1A QP1B QP2A QP2B QD1A QD1B QD2A QD2B QQ1A QQ1B QQ2A QQ2B QQ3A QQ3B RP1A RP1B RP2A RP2B RD1A RD1B RD2A RD2B RQ1A RQ1B RQ2A RQ2B RQ3A RQ3B SP1A SP1B SP2A SP2B SD1A SD1B SD2A SD2B SQ1A SQ1B SQ2A SQ2B SQ3A SQ3B TP1A TP1B TP2A TP2B TD1A TD1B TD2A TD2B TQ1A TQ1B TQ2A TQ2B TQ3A TQ3B UP1A UP1B UP2A UP2B UD1A UD1B UD2A UD2B UQ1A UQ1B UQ2A UQ2B UQ3A UQ3B" $(foreach v,$(ENABLED_VERSIONS), \ $(eval IS_AT_LEAST_$(v) := true)) diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk index 593b7b6aaf..91cb2c94b0 100644 --- a/core/tasks/cts.mk +++ b/core/tasks/cts.mk @@ -37,7 +37,7 @@ ifneq (,$(wildcard cts/)) cts_platform_release_path := cts/tests/tests/os/assets/platform_releases.txt cts_platform_release_string := $(shell cat $(cts_platform_release_path)) - ifeq ($(RELEASE_PLATFORM_VERSION_CODENAME_REL),) + ifneq (REL,$(PLATFORM_VERSION_CODENAME)) ifeq (,$(findstring $(PLATFORM_VERSION),$(cts_platform_version_string))) define error_msg ============================================================ diff --git a/core/version_defaults.mk b/core/version_defaults.mk deleted file mode 100644 index a43506cad7..0000000000 --- a/core/version_defaults.mk +++ /dev/null @@ -1,111 +0,0 @@ -# -# Copyright (C) 2008 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# -# Handle various build version information. -# -# Guarantees that the following are defined: -# PLATFORM_VERSION -# PLATFORM_DISPLAY_VERSION -# PLATFORM_SDK_VERSION -# PLATFORM_VERSION_CODENAME -# DEFAULT_APP_TARGET_SDK -# BUILD_ID -# BUILD_NUMBER -# PLATFORM_SECURITY_PATCH -# PLATFORM_VNDK_VERSION -# PLATFORM_SYSTEMSDK_VERSIONS -# - -# Look for an optional file containing overrides of the defaults, -# but don't cry if we don't find it. We could just use -include, but -# the build.prop target also wants INTERNAL_BUILD_ID_MAKEFILE to be set -# if the file exists. -# -INTERNAL_BUILD_ID_MAKEFILE := $(wildcard $(BUILD_SYSTEM)/build_id.mk) -ifdef INTERNAL_BUILD_ID_MAKEFILE - include $(INTERNAL_BUILD_ID_MAKEFILE) -endif - -# Set release configuration. The default resides in build/release/build_flags.mk. -MIN_PLATFORM_VERSION := UP1A -MAX_PLATFORM_VERSION := VP1A - -# The last stable version name of the platform that was released. During -# development, this stays at that previous version, while the codename indicates -# further work based on the previous version. -PLATFORM_VERSION_LAST_STABLE := 14 -.KATI_READONLY := PLATFORM_VERSION_LAST_STABLE - -# These are the current development codenames, if the build is not a final -# release build. If this is a final release build, it is simply "REL". -# Note that this may be overridden by RELEASE_VERSION_CODENAME_REL in -# version_util.mk. -PLATFORM_VERSION_CODENAME.UP1A := UpsideDownCake -PLATFORM_VERSION_CODENAME.VP1A := VanillaIceCream - -# This is the user-visible version. In a final release build it should -# be empty to use PLATFORM_VERSION as the user-visible version. For -# a preview release it can be set to a user-friendly value like `12 Preview 1` -PLATFORM_DISPLAY_VERSION := - -ifndef PLATFORM_SDK_VERSION - # This is the canonical definition of the SDK version, which defines - # the set of APIs and functionality available in the platform. It - # is a single integer that increases monotonically as updates to - # the SDK are released. It should only be incremented when the APIs for - # the new release are frozen (so that developers don't write apps against - # intermediate builds). During development, this number remains at the - # SDK version the branch is based on and PLATFORM_VERSION_CODENAME holds - # the code-name of the new development work. - - # When you increment the PLATFORM_SDK_VERSION please ensure you also - # clear out the following text file of all older PLATFORM_VERSION's: - # cts/tests/tests/os/assets/platform_versions.txt - PLATFORM_SDK_VERSION := 34 -endif -.KATI_READONLY := PLATFORM_SDK_VERSION - -# This is the sdk extension version of this tree. -PLATFORM_SDK_EXTENSION_VERSION := 7 -.KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION - -# This is the sdk extension version that PLATFORM_SDK_VERSION ships with. -PLATFORM_BASE_SDK_EXTENSION_VERSION := $(PLATFORM_SDK_EXTENSION_VERSION) -.KATI_READONLY := PLATFORM_BASE_SDK_EXTENSION_VERSION - -# This are all known codenames. -PLATFORM_VERSION_KNOWN_CODENAMES := \ -Base Base11 Cupcake Donut Eclair Eclair01 EclairMr1 Froyo Gingerbread GingerbreadMr1 \ -Honeycomb HoneycombMr1 HoneycombMr2 IceCreamSandwich IceCreamSandwichMr1 \ -JellyBean JellyBeanMr1 JellyBeanMr2 Kitkat KitkatWatch Lollipop LollipopMr1 M N NMr1 O OMr1 P \ -Q R S Sv2 Tiramisu UpsideDownCake VanillaIceCream - -# Convert from space separated list to comma separated -PLATFORM_VERSION_KNOWN_CODENAMES := \ - $(call normalize-comma-list,$(PLATFORM_VERSION_KNOWN_CODENAMES)) -.KATI_READONLY := PLATFORM_VERSION_KNOWN_CODENAMES - -ifndef PLATFORM_SECURITY_PATCH - # Used to indicate the security patch that has been applied to the device. - # It must signify that the build includes all security patches issued up through the designated Android Public Security Bulletin. - # It must be of the form "YYYY-MM-DD" on production devices. - # It must match one of the Android Security Patch Level strings of the Public Security Bulletins. - # If there is no $PLATFORM_SECURITY_PATCH set, keep it empty. - PLATFORM_SECURITY_PATCH := 2023-12-01 -endif - -include $(BUILD_SYSTEM)/version_util.mk diff --git a/core/version_util.mk b/core/version_util.mk index 0cc3442238..dfa0277993 100644 --- a/core/version_util.mk +++ b/core/version_util.mk @@ -14,119 +14,99 @@ # limitations under the License. # -ALLOWED_VERSIONS := $(call allowed-platform-versions,\ - $(MIN_PLATFORM_VERSION),\ - $(MAX_PLATFORM_VERSION),\ - $(RELEASE_PLATFORM_VERSION)) + +# +# Handle various build version information. +# +# Guarantees that the following are defined: +# PLATFORM_VERSION +# PLATFORM_DISPLAY_VERSION +# PLATFORM_SDK_VERSION +# PLATFORM_SDK_EXTENSION_VERSION +# PLATFORM_VERSION_CODENAME +# DEFAULT_APP_TARGET_SDK +# BUILD_ID +# BUILD_NUMBER +# PLATFORM_SECURITY_PATCH +# PLATFORM_VNDK_VERSION +# PLATFORM_SYSTEMSDK_VERSIONS +# PLATFORM_VERSION_LAST_STABLE +# + +# Look for an optional file containing overrides of the defaults, +# but don't cry if we don't find it. We could just use -include, but +# the build.prop target also wants INTERNAL_BUILD_ID_MAKEFILE to be set +# if the file exists. +# +INTERNAL_BUILD_ID_MAKEFILE := $(wildcard $(BUILD_SYSTEM)/build_id.mk) +ifdef INTERNAL_BUILD_ID_MAKEFILE + include $(INTERNAL_BUILD_ID_MAKEFILE) +endif ifdef TARGET_PLATFORM_VERSION $(error Do not set TARGET_PLATFORM_VERSION directly. Use RELEASE_PLATFORM_VERSION. value: $(TARGET_PLATFORM_VERSION)) endif - TARGET_PLATFORM_VERSION := $(RELEASE_PLATFORM_VERSION) - -ifeq (,$(filter $(ALLOWED_VERSIONS), $(TARGET_PLATFORM_VERSION))) - $(warning Invalid TARGET_PLATFORM_VERSION '$(TARGET_PLATFORM_VERSION)', must be one of) - $(error $(ALLOWED_VERSIONS)) -endif -ALLOWED_VERSIONS := -MIN_PLATFORM_VERSION := -MAX_PLATFORM_VERSION := - .KATI_READONLY := TARGET_PLATFORM_VERSION -# Default versions for each TARGET_PLATFORM_VERSION -# TODO: PLATFORM_VERSION, PLATFORM_SDK_VERSION, etc. should be conditional -# on this - -# This is the canonical definition of the platform version, -# which is the version that we reveal to the end user. -# Update this value when the platform version changes (rather -# than overriding it somewhere else). Can be an arbitrary string. - -# When you change PLATFORM_VERSION for a given PLATFORM_SDK_VERSION -# please add that PLATFORM_VERSION as well as clean up obsolete PLATFORM_VERSION's -# in the following text file: -# cts/tests/tests/os/assets/platform_versions.txt - -# Note that there should be one PLATFORM_VERSION and PLATFORM_VERSION_CODENAME -# entry for each unreleased API level, regardless of -# MIN_PLATFORM_VERSION/MAX_PLATFORM_VERSION. PLATFORM_VERSION is used to -# generate the range of allowed SDK versions, so it must have an entry for every -# unreleased API level targetable by this branch, not just those that are valid -# lunch targets for this branch. - -# Release config flag to override the current version to REL. Note that the -# codename can also be locked to REL by setting it in versino_defaults.mk. -ifneq ($(RELEASE_PLATFORM_VERSION_CODENAME_REL),) - PLATFORM_VERSION_CODENAME.$(TARGET_PLATFORM_VERSION) := REL +ifdef PLATFORM_SECURITY_PATCH + $(error Do not set PLATFORM_SECURITY_PATCH directly. Use RELEASE_PLATFORM_SECURITY_PATCH. value: $(PLATFORM_SECURITY_PATCH)) endif +PLATFORM_SECURITY_PATCH := $(RELEASE_PLATFORM_SECURITY_PATCH) +.KATI_READONLY := PLATFORM_SECURITY_PATCH -PLATFORM_VERSION_CODENAME := $(PLATFORM_VERSION_CODENAME.$(TARGET_PLATFORM_VERSION)) -ifndef PLATFORM_VERSION_CODENAME - # PLATFORM_VERSION_CODENAME falls back to TARGET_PLATFORM_VERSION - PLATFORM_VERSION_CODENAME := $(TARGET_PLATFORM_VERSION) +ifdef PLATFORM_SDK_VERSION + $(error Do not set PLATFORM_SDK_VERSION directly. Use RELEASE_PLATFORM_SDK_VERSION. value: $(PLATFORM_SDK_VERSION)) endif +PLATFORM_SDK_VERSION := $(RELEASE_PLATFORM_SDK_VERSION) +.KATI_READONLY := PLATFORM_SDK_VERSION -# This is all of the *active* development codenames. -# This confusing name is needed because -# all_codenames has been baked into build.prop for ages. -# -# Should be either the same as PLATFORM_VERSION_CODENAME or a comma-separated -# list of additional codenames after PLATFORM_VERSION_CODENAME. -PLATFORM_VERSION_ALL_CODENAMES := - -# Build a list of all active code names. Avoid duplicates, and stop when we -# reach a codename that matches PLATFORM_VERSION_CODENAME (anything beyond -# that is not included in our build). -_versions_in_target := \ - $(call find_and_earlier,$(ALL_VERSIONS),$(TARGET_PLATFORM_VERSION)) -$(foreach version,$(_versions_in_target),\ - $(eval _codename := $(PLATFORM_VERSION_CODENAME.$(version)))\ - $(if $(filter $(_codename),$(PLATFORM_VERSION_ALL_CODENAMES)),,\ - $(eval PLATFORM_VERSION_ALL_CODENAMES += $(_codename)))) - -# And the list of actually all the codenames that are in preview. The -# ALL_CODENAMES variable is sort of a lie for historical reasons and only -# includes codenames up to and including the currently active codename, whereas -# this variable also includes future codenames. For example, while AOSP is still -# merging into U, but V development has started, ALL_CODENAMES will only be U, -# but ALL_PREVIEW_CODENAMES will be U and V. -# -# REL is filtered out of the list. The codename of the current release is -# replaced by "REL" when the build is configured as a release rather than a -# preview. For example, PLATFORM_VERSION_CODENAME.UpsideDownCake will be "REL" -# rather than UpsideDownCake in a -next target when the upcoming release is -# UpsideDownCake. "REL" is a codename (and android.os.Build relies on this: -# https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/core/java/android/os/Build.java;l=484-487;drc=316e3d16c9f34212f3beace7695289651d15a071), -# so it should be in PLATFORM_VERSION_ALL_CODENAMES, but it definitely is not a -# preview codename. -PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := -$(foreach version,$(ALL_VERSIONS),\ - $(eval _codename := $(PLATFORM_VERSION_CODENAME.$(version)))\ - $(if $(filter REL,$(_codename)),,\ - $(if $(filter $(_codename),$(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)),,\ - $(eval PLATFORM_VERSION_ALL_PREVIEW_CODENAMES += $(_codename))))) - -# And convert from space separated to comma separated. -PLATFORM_VERSION_ALL_CODENAMES := \ - $(subst $(space),$(comma),$(strip $(PLATFORM_VERSION_ALL_CODENAMES))) -PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := \ - $(subst $(space),$(comma),$(strip $(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES))) - -.KATI_READONLY := \ - PLATFORM_VERSION_CODENAME \ - PLATFORM_VERSION_ALL_CODENAMES \ - PLATFORM_VERSION_ALL_PREVIEW_CODENAMES \ - -ifneq (REL,$(PLATFORM_VERSION_CODENAME)) - codenames := \ - $(subst $(comma),$(space),$(strip $(PLATFORM_VERSION_KNOWN_CODENAMES))) - ifeq ($(filter $(PLATFORM_VERSION_CODENAME),$(codenames)),) - $(error '$(PLATFORM_VERSION_CODENAME)' is not in '$(codenames)'. \ - Add PLATFORM_VERSION_CODENAME to PLATFORM_VERSION_KNOWN_CODENAMES) - endif +ifdef PLATFORM_SDK_EXTENSION_VERSION + $(error Do not set PLATFORM_SDK_EXTENSION_VERSION directly. Use RELEASE_PLATFORM_SDK_EXTENSION_VERSION. value: $(PLATFORM_SDK_EXTENSION_VERSION)) endif +PLATFORM_SDK_EXTENSION_VERSION := $(RELEASE_PLATFORM_SDK_EXTENSION_VERSION) +.KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION + +# This is the sdk extension version that PLATFORM_SDK_VERSION ships with. +PLATFORM_BASE_SDK_EXTENSION_VERSION := $(PLATFORM_SDK_EXTENSION_VERSION) +.KATI_READONLY := PLATFORM_BASE_SDK_EXTENSION_VERSION + +ifdef PLATFORM_VERSION_CODENAME + $(error Do not set PLATFORM_VERSION_CODENAME directly. Use RELEASE_PLATFORM_VERSION. value: $(PLATFORM_VERSION_CODENAME)) +endif +PLATFORM_VERSION_CODENAME := $(RELEASE_PLATFORM_VERSION_CODENAME) +.KATI_READONLY := PLATFORM_VERSION_CODENAME + +ifdef PLATFORM_VERSION_ALL_CODENAMES + $(error Do not set PLATFORM_VERSION_ALL_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_CODENAMES. value: $(PLATFORM_VERSION_ALL_CODENAMES)) +endif +PLATFORM_VERSION_ALL_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_CODENAMES) +.KATI_READONLY := PLATFORM_VERSION_ALL_CODENAMES + +ifdef PLATFORM_VERSION_ALL_PREVIEW_CODENAMES + $(error Do not set PLATFORM_VERSION_ALL_PREVIEW_CODENAMES directly. Use RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES. value: $(PLATFORM_VERSION_ALL_PREVIEW_CODENAMES)) +endif +PLATFORM_VERSION_ALL_PREVIEW_CODENAMES := $(RELEASE_PLATFORM_VERSION_ALL_PREVIEW_CODENAMES) +.KATI_READONLY := PLATFORM_VERSION_ALL_PREVIEW_CODENAMES + +ifdef PLATFORM_VERSION_LAST_STABLE + $(error Do not set PLATFORM_VERSION_LAST_STABLE directly. Use RELEASE_PLATFORM_VERSION_LAST_STABLE. value: $(PLATFORM_VERSION_CODENAME)) +endif +PLATFORM_VERSION_LAST_STABLE := $(RELEASE_PLATFORM_VERSION_LAST_STABLE) +.KATI_READONLY := PLATFORM_VERSION_LAST_STABLE + + +# This are all known codenames. Should this move into the release config? +PLATFORM_VERSION_KNOWN_CODENAMES := \ +Base Base11 Cupcake Donut Eclair Eclair01 EclairMr1 Froyo Gingerbread GingerbreadMr1 \ +Honeycomb HoneycombMr1 HoneycombMr2 IceCreamSandwich IceCreamSandwichMr1 \ +JellyBean JellyBeanMr1 JellyBeanMr2 Kitkat KitkatWatch Lollipop LollipopMr1 M N NMr1 O OMr1 P \ +Q R S Sv2 Tiramisu UpsideDownCake VanillaIceCream + +# Convert from space separated list to comma separated +PLATFORM_VERSION_KNOWN_CODENAMES := \ + $(call normalize-comma-list,$(PLATFORM_VERSION_KNOWN_CODENAMES)) +.KATI_READONLY := PLATFORM_VERSION_KNOWN_CODENAMES ifndef PLATFORM_VERSION ifeq (REL,$(PLATFORM_VERSION_CODENAME)) From c8b7191c74c67619955abec992568732a13675a5 Mon Sep 17 00:00:00 2001 From: Dave Mankoff Date: Wed, 25 Oct 2023 15:06:32 +0000 Subject: [PATCH 62/85] Let aconfig protos be read by FlagFlipper Bug: 307526764 Test: manually built Change-Id: I689a15cc8c97a814df6f8e45bcf7f732d1693835 --- tools/aconfig/Android.bp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/aconfig/Android.bp b/tools/aconfig/Android.bp index f7a46f0f8e..425d8a9f3d 100644 --- a/tools/aconfig/Android.bp +++ b/tools/aconfig/Android.bp @@ -15,7 +15,8 @@ java_library { sdk_version: "current", min_sdk_version: "UpsideDownCake", apex_available: [ - "com.android.configinfrastructure" + "com.android.configinfrastructure", + "//apex_available:platform", ] } From e2ac8b19c46c52724f9d05f25127cfeea0cba6dd Mon Sep 17 00:00:00 2001 From: Alfred Piccioni Date: Wed, 25 Oct 2023 13:56:04 +0200 Subject: [PATCH 63/85] Remove emulator_x86_arm board from common boards The board will now live in the Android TV vendor partition, since the emulator team is no longer supporting 32-bit boards. Bug: 305610937 Test: Null Change-Id: Ia1afb35ad15eb991bb2451c160db4f853f016587 Ignore-AOSP-First: this will be cp'ed to AOSP soon after --- target/board/emulator_x86_arm/BoardConfig.mk | 52 ------------------- target/board/emulator_x86_arm/device.mk | 18 ------- target/board/emulator_x86_arm/system_ext.prop | 5 -- 3 files changed, 75 deletions(-) delete mode 100644 target/board/emulator_x86_arm/BoardConfig.mk delete mode 100644 target/board/emulator_x86_arm/device.mk delete mode 100644 target/board/emulator_x86_arm/system_ext.prop diff --git a/target/board/emulator_x86_arm/BoardConfig.mk b/target/board/emulator_x86_arm/BoardConfig.mk deleted file mode 100644 index 21fdbc8e99..0000000000 --- a/target/board/emulator_x86_arm/BoardConfig.mk +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# x86 emulator specific definitions -TARGET_CPU_ABI := x86 -TARGET_ARCH := x86 -TARGET_ARCH_VARIANT := x86 - -TARGET_NATIVE_BRIDGE_ARCH := arm -TARGET_NATIVE_BRIDGE_ARCH_VARIANT := armv7-a-neon -TARGET_NATIVE_BRIDGE_CPU_VARIANT := generic -TARGET_NATIVE_BRIDGE_ABI := armeabi-v7a armeabi - -BUILD_BROKEN_DUP_RULES := true - -# -# The inclusion order below is important. -# The settings in latter makefiles overwrite those in the former. -# -include build/make/target/board/BoardConfigMainlineCommon.mk -include build/make/target/board/BoardConfigEmuCommon.mk - -# the settings differ from BoardConfigMainlineCommon.mk -BOARD_USES_SYSTEM_OTHER_ODEX := - -# Resize to 4G to accommodate ASAN and CTS -BOARD_USERDATAIMAGE_PARTITION_SIZE := 4294967296 - -BOARD_SEPOLICY_DIRS += device/generic/goldfish/sepolicy/x86 - -# Wifi. -BOARD_WLAN_DEVICE := emulator -BOARD_HOSTAPD_DRIVER := NL80211 -BOARD_WPA_SUPPLICANT_DRIVER := NL80211 -BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_simulated -BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_simulated -WPA_SUPPLICANT_VERSION := VER_0_8_X -WIFI_DRIVER_FW_PATH_PARAM := "/dev/null" -WIFI_DRIVER_FW_PATH_STA := "/dev/null" -WIFI_DRIVER_FW_PATH_AP := "/dev/null" diff --git a/target/board/emulator_x86_arm/device.mk b/target/board/emulator_x86_arm/device.mk deleted file mode 100644 index af023eb25c..0000000000 --- a/target/board/emulator_x86_arm/device.mk +++ /dev/null @@ -1,18 +0,0 @@ -# -# Copyright (C) 2020 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -PRODUCT_SOONG_NAMESPACES += device/generic/goldfish # for libwifi-hal-emu -PRODUCT_SOONG_NAMESPACES += device/generic/goldfish-opengl # for goldfish deps. diff --git a/target/board/emulator_x86_arm/system_ext.prop b/target/board/emulator_x86_arm/system_ext.prop deleted file mode 100644 index 64829f3ce4..0000000000 --- a/target/board/emulator_x86_arm/system_ext.prop +++ /dev/null @@ -1,5 +0,0 @@ -# -# system.prop for generic sdk -# - -rild.libpath=/vendor/lib/libreference-ril.so From 8b481264f8c01b662d93b2eb68a97350b6d4e363 Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Fri, 27 Oct 2023 13:27:07 -0700 Subject: [PATCH 64/85] Move more non-AB code to separate files non-AB has different lifetime and development cycles from AB. To avoid accidentally breaking each other when making changes, put non-AB code in its own files. Ignore-AOSP-First: Need to resolve a merge conflict first in main Test: local non-AB OTA generation Bug: 296485685 Change-Id: I0736ecef343834c746464666a454a8bfcd4a20ea --- tools/releasetools/Android.bp | 5 + .../releasetools/check_target_files_vintf.py | 1 - tools/releasetools/common.py | 924 +----------------- tools/releasetools/edify_generator.py | 48 +- tools/releasetools/make_recovery_patch.py | 3 +- tools/releasetools/non_ab_ota.py | 920 ++++++++++++++++- tools/releasetools/test_common.py | 287 ------ tools/releasetools/test_non_ab_ota.py | 309 +++++- 8 files changed, 1260 insertions(+), 1237 deletions(-) diff --git a/tools/releasetools/Android.bp b/tools/releasetools/Android.bp index ee266b7d91..ad014af31f 100644 --- a/tools/releasetools/Android.bp +++ b/tools/releasetools/Android.bp @@ -483,8 +483,13 @@ python_binary_host { defaults: ["releasetools_binary_defaults"], srcs: [ "make_recovery_patch.py", + "non_ab_ota.py", + "edify_generator.py", + "check_target_files_vintf.py", ], libs: [ + "ota_utils_lib", + "ota_metadata_proto", "releasetools_common", ], } diff --git a/tools/releasetools/check_target_files_vintf.py b/tools/releasetools/check_target_files_vintf.py index 33624f5085..e7d3a183a4 100755 --- a/tools/releasetools/check_target_files_vintf.py +++ b/tools/releasetools/check_target_files_vintf.py @@ -31,7 +31,6 @@ import sys import zipfile import common -from apex_manifest import ParseApexManifest logger = logging.getLogger(__name__) diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index f5f8394cd8..d97611cbdd 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -15,7 +15,6 @@ from __future__ import print_function import base64 -import collections import copy import datetime import errno @@ -23,7 +22,6 @@ import fnmatch import getopt import getpass import gzip -import imp import json import logging import logging.config @@ -36,17 +34,13 @@ import subprocess import stat import sys import tempfile -import threading -import time import zipfile from dataclasses import dataclass -from genericpath import isdir from hashlib import sha1, sha256 import images -import rangelib import sparse_img -from blockimgdiff import BlockImageDiff + logger = logging.getLogger(__name__) @@ -155,35 +149,6 @@ class AvbChainedPartitionArg: self.partition, self.rollback_index_location, self.pubkey_path) -class ErrorCode(object): - """Define error_codes for failures that happen during the actual - update package installation. - - Error codes 0-999 are reserved for failures before the package - installation (i.e. low battery, package verification failure). - Detailed code in 'bootable/recovery/error_code.h' """ - - SYSTEM_VERIFICATION_FAILURE = 1000 - SYSTEM_UPDATE_FAILURE = 1001 - SYSTEM_UNEXPECTED_CONTENTS = 1002 - SYSTEM_NONZERO_CONTENTS = 1003 - SYSTEM_RECOVER_FAILURE = 1004 - VENDOR_VERIFICATION_FAILURE = 2000 - VENDOR_UPDATE_FAILURE = 2001 - VENDOR_UNEXPECTED_CONTENTS = 2002 - VENDOR_NONZERO_CONTENTS = 2003 - VENDOR_RECOVER_FAILURE = 2004 - OEM_PROP_MISMATCH = 3000 - FINGERPRINT_MISMATCH = 3001 - THUMBPRINT_MISMATCH = 3002 - OLDER_BUILD = 3003 - DEVICE_MISMATCH = 3004 - BAD_PATCH_FILE = 3005 - INSUFFICIENT_CACHE_SPACE = 3006 - TUNE_PARTITION_FAILURE = 3007 - APPLY_PATCH_FAILURE = 3008 - - class ExternalError(RuntimeError): pass @@ -3134,107 +3099,6 @@ def ZipClose(zip_file): zipfile.ZIP64_LIMIT = saved_zip64_limit -class DeviceSpecificParams(object): - module = None - - def __init__(self, **kwargs): - """Keyword arguments to the constructor become attributes of this - object, which is passed to all functions in the device-specific - module.""" - for k, v in kwargs.items(): - setattr(self, k, v) - self.extras = OPTIONS.extras - - if self.module is None: - path = OPTIONS.device_specific - if not path: - return - try: - if os.path.isdir(path): - info = imp.find_module("releasetools", [path]) - else: - d, f = os.path.split(path) - b, x = os.path.splitext(f) - if x == ".py": - f = b - info = imp.find_module(f, [d]) - logger.info("loaded device-specific extensions from %s", path) - self.module = imp.load_module("device_specific", *info) - except ImportError: - logger.info("unable to load device-specific module; assuming none") - - def _DoCall(self, function_name, *args, **kwargs): - """Call the named function in the device-specific module, passing - the given args and kwargs. The first argument to the call will be - the DeviceSpecific object itself. If there is no module, or the - module does not define the function, return the value of the - 'default' kwarg (which itself defaults to None).""" - if self.module is None or not hasattr(self.module, function_name): - return kwargs.get("default") - return getattr(self.module, function_name)(*((self,) + args), **kwargs) - - def FullOTA_Assertions(self): - """Called after emitting the block of assertions at the top of a - full OTA package. Implementations can add whatever additional - assertions they like.""" - return self._DoCall("FullOTA_Assertions") - - def FullOTA_InstallBegin(self): - """Called at the start of full OTA installation.""" - return self._DoCall("FullOTA_InstallBegin") - - def FullOTA_GetBlockDifferences(self): - """Called during full OTA installation and verification. - Implementation should return a list of BlockDifference objects describing - the update on each additional partitions. - """ - return self._DoCall("FullOTA_GetBlockDifferences") - - def FullOTA_InstallEnd(self): - """Called at the end of full OTA installation; typically this is - used to install the image for the device's baseband processor.""" - return self._DoCall("FullOTA_InstallEnd") - - def IncrementalOTA_Assertions(self): - """Called after emitting the block of assertions at the top of an - incremental OTA package. Implementations can add whatever - additional assertions they like.""" - return self._DoCall("IncrementalOTA_Assertions") - - def IncrementalOTA_VerifyBegin(self): - """Called at the start of the verification phase of incremental - OTA installation; additional checks can be placed here to abort - the script before any changes are made.""" - return self._DoCall("IncrementalOTA_VerifyBegin") - - def IncrementalOTA_VerifyEnd(self): - """Called at the end of the verification phase of incremental OTA - installation; additional checks can be placed here to abort the - script before any changes are made.""" - return self._DoCall("IncrementalOTA_VerifyEnd") - - def IncrementalOTA_InstallBegin(self): - """Called at the start of incremental OTA installation (after - verification is complete).""" - return self._DoCall("IncrementalOTA_InstallBegin") - - def IncrementalOTA_GetBlockDifferences(self): - """Called during incremental OTA installation and verification. - Implementation should return a list of BlockDifference objects describing - the update on each additional partitions. - """ - return self._DoCall("IncrementalOTA_GetBlockDifferences") - - def IncrementalOTA_InstallEnd(self): - """Called at the end of incremental OTA installation; typically - this is used to install the image for the device's baseband - processor.""" - return self._DoCall("IncrementalOTA_InstallEnd") - - def VerifyOTA_Assertions(self): - return self._DoCall("VerifyOTA_Assertions") - - class File(object): def __init__(self, name, data, compress_size=None): self.name = name @@ -3264,454 +3128,11 @@ class File(object): ZipWriteStr(z, self.name, self.data, compress_type=compression) -DIFF_PROGRAM_BY_EXT = { - ".gz": "imgdiff", - ".zip": ["imgdiff", "-z"], - ".jar": ["imgdiff", "-z"], - ".apk": ["imgdiff", "-z"], - ".img": "imgdiff", -} - - -class Difference(object): - def __init__(self, tf, sf, diff_program=None): - self.tf = tf - self.sf = sf - self.patch = None - self.diff_program = diff_program - - def ComputePatch(self): - """Compute the patch (as a string of data) needed to turn sf into - tf. Returns the same tuple as GetPatch().""" - - tf = self.tf - sf = self.sf - - if self.diff_program: - diff_program = self.diff_program - else: - ext = os.path.splitext(tf.name)[1] - diff_program = DIFF_PROGRAM_BY_EXT.get(ext, "bsdiff") - - ttemp = tf.WriteToTemp() - stemp = sf.WriteToTemp() - - ext = os.path.splitext(tf.name)[1] - - try: - ptemp = tempfile.NamedTemporaryFile() - if isinstance(diff_program, list): - cmd = copy.copy(diff_program) - else: - cmd = [diff_program] - cmd.append(stemp.name) - cmd.append(ttemp.name) - cmd.append(ptemp.name) - p = Run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - err = [] - - def run(): - _, e = p.communicate() - if e: - err.append(e) - th = threading.Thread(target=run) - th.start() - th.join(timeout=300) # 5 mins - if th.is_alive(): - logger.warning("diff command timed out") - p.terminate() - th.join(5) - if th.is_alive(): - p.kill() - th.join() - - if p.returncode != 0: - logger.warning("Failure running %s:\n%s\n", cmd, "".join(err)) - self.patch = None - return None, None, None - diff = ptemp.read() - finally: - ptemp.close() - stemp.close() - ttemp.close() - - self.patch = diff - return self.tf, self.sf, self.patch - - def GetPatch(self): - """Returns a tuple of (target_file, source_file, patch_data). - - patch_data may be None if ComputePatch hasn't been called, or if - computing the patch failed. - """ - return self.tf, self.sf, self.patch - - -def ComputeDifferences(diffs): - """Call ComputePatch on all the Difference objects in 'diffs'.""" - logger.info("%d diffs to compute", len(diffs)) - - # Do the largest files first, to try and reduce the long-pole effect. - by_size = [(i.tf.size, i) for i in diffs] - by_size.sort(reverse=True) - by_size = [i[1] for i in by_size] - - lock = threading.Lock() - diff_iter = iter(by_size) # accessed under lock - - def worker(): - try: - lock.acquire() - for d in diff_iter: - lock.release() - start = time.time() - d.ComputePatch() - dur = time.time() - start - lock.acquire() - - tf, sf, patch = d.GetPatch() - if sf.name == tf.name: - name = tf.name - else: - name = "%s (%s)" % (tf.name, sf.name) - if patch is None: - logger.error("patching failed! %40s", name) - else: - logger.info( - "%8.2f sec %8d / %8d bytes (%6.2f%%) %s", dur, len(patch), - tf.size, 100.0 * len(patch) / tf.size, name) - lock.release() - except Exception: - logger.exception("Failed to compute diff from worker") - raise - - # start worker threads; wait for them all to finish. - threads = [threading.Thread(target=worker) - for i in range(OPTIONS.worker_threads)] - for th in threads: - th.start() - while threads: - threads.pop().join() - - -class BlockDifference(object): - def __init__(self, partition, tgt, src=None, check_first_block=False, - version=None, disable_imgdiff=False): - self.tgt = tgt - self.src = src - self.partition = partition - self.check_first_block = check_first_block - self.disable_imgdiff = disable_imgdiff - - if version is None: - version = max( - int(i) for i in - OPTIONS.info_dict.get("blockimgdiff_versions", "1").split(",")) - assert version >= 3 - self.version = version - - b = BlockImageDiff(tgt, src, threads=OPTIONS.worker_threads, - version=self.version, - disable_imgdiff=self.disable_imgdiff) - self.path = os.path.join(MakeTempDir(), partition) - b.Compute(self.path) - self._required_cache = b.max_stashed_size - self.touched_src_ranges = b.touched_src_ranges - self.touched_src_sha1 = b.touched_src_sha1 - - # On devices with dynamic partitions, for new partitions, - # src is None but OPTIONS.source_info_dict is not. - if OPTIONS.source_info_dict is None: - is_dynamic_build = OPTIONS.info_dict.get( - "use_dynamic_partitions") == "true" - is_dynamic_source = False - else: - is_dynamic_build = OPTIONS.source_info_dict.get( - "use_dynamic_partitions") == "true" - is_dynamic_source = partition in shlex.split( - OPTIONS.source_info_dict.get("dynamic_partition_list", "").strip()) - - is_dynamic_target = partition in shlex.split( - OPTIONS.info_dict.get("dynamic_partition_list", "").strip()) - - # For dynamic partitions builds, check partition list in both source - # and target build because new partitions may be added, and existing - # partitions may be removed. - is_dynamic = is_dynamic_build and (is_dynamic_source or is_dynamic_target) - - if is_dynamic: - self.device = 'map_partition("%s")' % partition - else: - if OPTIONS.source_info_dict is None: - _, device_expr = GetTypeAndDeviceExpr("/" + partition, - OPTIONS.info_dict) - else: - _, device_expr = GetTypeAndDeviceExpr("/" + partition, - OPTIONS.source_info_dict) - self.device = device_expr - - @property - def required_cache(self): - return self._required_cache - - def WriteScript(self, script, output_zip, progress=None, - write_verify_script=False): - if not self.src: - # write the output unconditionally - script.Print("Patching %s image unconditionally..." % (self.partition,)) - else: - script.Print("Patching %s image after verification." % (self.partition,)) - - if progress: - script.ShowProgress(progress, 0) - self._WriteUpdate(script, output_zip) - - if write_verify_script: - self.WritePostInstallVerifyScript(script) - - def WriteStrictVerifyScript(self, script): - """Verify all the blocks in the care_map, including clobbered blocks. - - This differs from the WriteVerifyScript() function: a) it prints different - error messages; b) it doesn't allow half-way updated images to pass the - verification.""" - - partition = self.partition - script.Print("Verifying %s..." % (partition,)) - ranges = self.tgt.care_map - ranges_str = ranges.to_string_raw() - script.AppendExtra( - 'range_sha1(%s, "%s") == "%s" && ui_print(" Verified.") || ' - 'ui_print("%s has unexpected contents.");' % ( - self.device, ranges_str, - self.tgt.TotalSha1(include_clobbered_blocks=True), - self.partition)) - script.AppendExtra("") - - def WriteVerifyScript(self, script, touched_blocks_only=False): - partition = self.partition - - # full OTA - if not self.src: - script.Print("Image %s will be patched unconditionally." % (partition,)) - - # incremental OTA - else: - if touched_blocks_only: - ranges = self.touched_src_ranges - expected_sha1 = self.touched_src_sha1 - else: - ranges = self.src.care_map.subtract(self.src.clobbered_blocks) - expected_sha1 = self.src.TotalSha1() - - # No blocks to be checked, skipping. - if not ranges: - return - - ranges_str = ranges.to_string_raw() - script.AppendExtra( - 'if (range_sha1(%s, "%s") == "%s" || block_image_verify(%s, ' - 'package_extract_file("%s.transfer.list"), "%s.new.dat", ' - '"%s.patch.dat")) then' % ( - self.device, ranges_str, expected_sha1, - self.device, partition, partition, partition)) - script.Print('Verified %s image...' % (partition,)) - script.AppendExtra('else') - - if self.version >= 4: - - # Bug: 21124327 - # When generating incrementals for the system and vendor partitions in - # version 4 or newer, explicitly check the first block (which contains - # the superblock) of the partition to see if it's what we expect. If - # this check fails, give an explicit log message about the partition - # having been remounted R/W (the most likely explanation). - if self.check_first_block: - script.AppendExtra('check_first_block(%s);' % (self.device,)) - - # If version >= 4, try block recovery before abort update - if partition == "system": - code = ErrorCode.SYSTEM_RECOVER_FAILURE - else: - code = ErrorCode.VENDOR_RECOVER_FAILURE - script.AppendExtra(( - 'ifelse (block_image_recover({device}, "{ranges}") && ' - 'block_image_verify({device}, ' - 'package_extract_file("{partition}.transfer.list"), ' - '"{partition}.new.dat", "{partition}.patch.dat"), ' - 'ui_print("{partition} recovered successfully."), ' - 'abort("E{code}: {partition} partition fails to recover"));\n' - 'endif;').format(device=self.device, ranges=ranges_str, - partition=partition, code=code)) - - # Abort the OTA update. Note that the incremental OTA cannot be applied - # even if it may match the checksum of the target partition. - # a) If version < 3, operations like move and erase will make changes - # unconditionally and damage the partition. - # b) If version >= 3, it won't even reach here. - else: - if partition == "system": - code = ErrorCode.SYSTEM_VERIFICATION_FAILURE - else: - code = ErrorCode.VENDOR_VERIFICATION_FAILURE - script.AppendExtra(( - 'abort("E%d: %s partition has unexpected contents");\n' - 'endif;') % (code, partition)) - - def WritePostInstallVerifyScript(self, script): - partition = self.partition - script.Print('Verifying the updated %s image...' % (partition,)) - # Unlike pre-install verification, clobbered_blocks should not be ignored. - ranges = self.tgt.care_map - ranges_str = ranges.to_string_raw() - script.AppendExtra( - 'if range_sha1(%s, "%s") == "%s" then' % ( - self.device, ranges_str, - self.tgt.TotalSha1(include_clobbered_blocks=True))) - - # Bug: 20881595 - # Verify that extended blocks are really zeroed out. - if self.tgt.extended: - ranges_str = self.tgt.extended.to_string_raw() - script.AppendExtra( - 'if range_sha1(%s, "%s") == "%s" then' % ( - self.device, ranges_str, - self._HashZeroBlocks(self.tgt.extended.size()))) - script.Print('Verified the updated %s image.' % (partition,)) - if partition == "system": - code = ErrorCode.SYSTEM_NONZERO_CONTENTS - else: - code = ErrorCode.VENDOR_NONZERO_CONTENTS - script.AppendExtra( - 'else\n' - ' abort("E%d: %s partition has unexpected non-zero contents after ' - 'OTA update");\n' - 'endif;' % (code, partition)) - else: - script.Print('Verified the updated %s image.' % (partition,)) - - if partition == "system": - code = ErrorCode.SYSTEM_UNEXPECTED_CONTENTS - else: - code = ErrorCode.VENDOR_UNEXPECTED_CONTENTS - - script.AppendExtra( - 'else\n' - ' abort("E%d: %s partition has unexpected contents after OTA ' - 'update");\n' - 'endif;' % (code, partition)) - - def _WriteUpdate(self, script, output_zip): - ZipWrite(output_zip, - '{}.transfer.list'.format(self.path), - '{}.transfer.list'.format(self.partition)) - - # For full OTA, compress the new.dat with brotli with quality 6 to reduce - # its size. Quailty 9 almost triples the compression time but doesn't - # further reduce the size too much. For a typical 1.8G system.new.dat - # zip | brotli(quality 6) | brotli(quality 9) - # compressed_size: 942M | 869M (~8% reduced) | 854M - # compression_time: 75s | 265s | 719s - # decompression_time: 15s | 25s | 25s - - if not self.src and not OPTIONS.info_dict.get("board_non_ab_ota_disable_compression"): - brotli_cmd = ['brotli', '--quality=6', - '--output={}.new.dat.br'.format(self.path), - '{}.new.dat'.format(self.path)] - print("Compressing {}.new.dat with brotli".format(self.partition)) - RunAndCheckOutput(brotli_cmd) - - new_data_name = '{}.new.dat.br'.format(self.partition) - ZipWrite(output_zip, - '{}.new.dat.br'.format(self.path), - new_data_name, - compress_type=zipfile.ZIP_STORED) - else: - new_data_name = '{}.new.dat'.format(self.partition) - ZipWrite(output_zip, '{}.new.dat'.format(self.path), new_data_name) - - ZipWrite(output_zip, - '{}.patch.dat'.format(self.path), - '{}.patch.dat'.format(self.partition), - compress_type=zipfile.ZIP_STORED) - - if self.partition == "system": - code = ErrorCode.SYSTEM_UPDATE_FAILURE - else: - code = ErrorCode.VENDOR_UPDATE_FAILURE - - call = ('block_image_update({device}, ' - 'package_extract_file("{partition}.transfer.list"), ' - '"{new_data_name}", "{partition}.patch.dat") ||\n' - ' abort("E{code}: Failed to update {partition} image.");'.format( - device=self.device, partition=self.partition, - new_data_name=new_data_name, code=code)) - script.AppendExtra(script.WordWrap(call)) - - def _HashBlocks(self, source, ranges): # pylint: disable=no-self-use - data = source.ReadRangeSet(ranges) - ctx = sha1() - - for p in data: - ctx.update(p) - - return ctx.hexdigest() - - def _HashZeroBlocks(self, num_blocks): # pylint: disable=no-self-use - """Return the hash value for all zero blocks.""" - zero_block = '\x00' * 4096 - ctx = sha1() - for _ in range(num_blocks): - ctx.update(zero_block) - - return ctx.hexdigest() - - # Expose these two classes to support vendor-specific scripts DataImage = images.DataImage EmptyImage = images.EmptyImage -# map recovery.fstab's fs_types to mount/format "partition types" -PARTITION_TYPES = { - "ext4": "EMMC", - "emmc": "EMMC", - "f2fs": "EMMC", - "squashfs": "EMMC", - "erofs": "EMMC" -} - - -def GetTypeAndDevice(mount_point, info, check_no_slot=True): - """ - Use GetTypeAndDeviceExpr whenever possible. This function is kept for - backwards compatibility. It aborts if the fstab entry has slotselect option - (unless check_no_slot is explicitly set to False). - """ - fstab = info["fstab"] - if fstab: - if check_no_slot: - assert not fstab[mount_point].slotselect, \ - "Use GetTypeAndDeviceExpr instead" - return (PARTITION_TYPES[fstab[mount_point].fs_type], - fstab[mount_point].device) - raise KeyError - - -def GetTypeAndDeviceExpr(mount_point, info): - """ - Return the filesystem of the partition, and an edify expression that evaluates - to the device at runtime. - """ - fstab = info["fstab"] - if fstab: - p = fstab[mount_point] - device_expr = '"%s"' % fstab[mount_point].device - if p.slotselect: - device_expr = 'add_slot_suffix(%s)' % device_expr - return (PARTITION_TYPES[fstab[mount_point].fs_type], device_expr) - raise KeyError - def GetEntryForDevice(fstab, device): """ @@ -3787,349 +3208,6 @@ def ExtractAvbPublicKey(avbtool, key): return output -def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img, - info_dict=None): - """Generates the recovery-from-boot patch and writes the script to output. - - Most of the space in the boot and recovery images is just the kernel, which is - identical for the two, so the resulting patch should be efficient. Add it to - the output zip, along with a shell script that is run from init.rc on first - boot to actually do the patching and install the new recovery image. - - Args: - input_dir: The top-level input directory of the target-files.zip. - output_sink: The callback function that writes the result. - recovery_img: File object for the recovery image. - boot_img: File objects for the boot image. - info_dict: A dict returned by common.LoadInfoDict() on the input - target_files. Will use OPTIONS.info_dict if None has been given. - """ - if info_dict is None: - info_dict = OPTIONS.info_dict - - full_recovery_image = info_dict.get("full_recovery_image") == "true" - board_uses_vendorimage = info_dict.get("board_uses_vendorimage") == "true" - - if board_uses_vendorimage: - # In this case, the output sink is rooted at VENDOR - recovery_img_path = "etc/recovery.img" - recovery_resource_dat_path = "VENDOR/etc/recovery-resource.dat" - sh_dir = "bin" - else: - # In this case the output sink is rooted at SYSTEM - recovery_img_path = "vendor/etc/recovery.img" - recovery_resource_dat_path = "SYSTEM/vendor/etc/recovery-resource.dat" - sh_dir = "vendor/bin" - - if full_recovery_image: - output_sink(recovery_img_path, recovery_img.data) - - else: - system_root_image = info_dict.get("system_root_image") == "true" - include_recovery_dtbo = info_dict.get("include_recovery_dtbo") == "true" - include_recovery_acpio = info_dict.get("include_recovery_acpio") == "true" - path = os.path.join(input_dir, recovery_resource_dat_path) - # With system-root-image, boot and recovery images will have mismatching - # entries (only recovery has the ramdisk entry) (Bug: 72731506). Use bsdiff - # to handle such a case. - if system_root_image or include_recovery_dtbo or include_recovery_acpio: - diff_program = ["bsdiff"] - bonus_args = "" - assert not os.path.exists(path) - else: - diff_program = ["imgdiff"] - if os.path.exists(path): - diff_program.append("-b") - diff_program.append(path) - bonus_args = "--bonus /vendor/etc/recovery-resource.dat" - else: - bonus_args = "" - - d = Difference(recovery_img, boot_img, diff_program=diff_program) - _, _, patch = d.ComputePatch() - output_sink("recovery-from-boot.p", patch) - - try: - # The following GetTypeAndDevice()s need to use the path in the target - # info_dict instead of source_info_dict. - boot_type, boot_device = GetTypeAndDevice("/boot", info_dict, - check_no_slot=False) - recovery_type, recovery_device = GetTypeAndDevice("/recovery", info_dict, - check_no_slot=False) - except KeyError: - return - - if full_recovery_image: - - # Note that we use /vendor to refer to the recovery resources. This will - # work for a separate vendor partition mounted at /vendor or a - # /system/vendor subdirectory on the system partition, for which init will - # create a symlink from /vendor to /system/vendor. - - sh = """#!/vendor/bin/sh -if ! applypatch --check %(type)s:%(device)s:%(size)d:%(sha1)s; then - applypatch \\ - --flash /vendor/etc/recovery.img \\ - --target %(type)s:%(device)s:%(size)d:%(sha1)s && \\ - log -t recovery "Installing new recovery image: succeeded" || \\ - log -t recovery "Installing new recovery image: failed" -else - log -t recovery "Recovery image already installed" -fi -""" % {'type': recovery_type, - 'device': recovery_device, - 'sha1': recovery_img.sha1, - 'size': recovery_img.size} - else: - sh = """#!/vendor/bin/sh -if ! applypatch --check %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s; then - applypatch %(bonus_args)s \\ - --patch /vendor/recovery-from-boot.p \\ - --source %(boot_type)s:%(boot_device)s:%(boot_size)d:%(boot_sha1)s \\ - --target %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s && \\ - log -t recovery "Installing new recovery image: succeeded" || \\ - log -t recovery "Installing new recovery image: failed" -else - log -t recovery "Recovery image already installed" -fi -""" % {'boot_size': boot_img.size, - 'boot_sha1': boot_img.sha1, - 'recovery_size': recovery_img.size, - 'recovery_sha1': recovery_img.sha1, - 'boot_type': boot_type, - 'boot_device': boot_device + '$(getprop ro.boot.slot_suffix)', - 'recovery_type': recovery_type, - 'recovery_device': recovery_device + '$(getprop ro.boot.slot_suffix)', - 'bonus_args': bonus_args} - - # The install script location moved from /system/etc to /system/bin in the L - # release. In the R release it is in VENDOR/bin or SYSTEM/vendor/bin. - sh_location = os.path.join(sh_dir, "install-recovery.sh") - - logger.info("putting script in %s", sh_location) - - output_sink(sh_location, sh.encode()) - - -class DynamicPartitionUpdate(object): - def __init__(self, src_group=None, tgt_group=None, progress=None, - block_difference=None): - self.src_group = src_group - self.tgt_group = tgt_group - self.progress = progress - self.block_difference = block_difference - - @property - def src_size(self): - if not self.block_difference: - return 0 - return DynamicPartitionUpdate._GetSparseImageSize(self.block_difference.src) - - @property - def tgt_size(self): - if not self.block_difference: - return 0 - return DynamicPartitionUpdate._GetSparseImageSize(self.block_difference.tgt) - - @staticmethod - def _GetSparseImageSize(img): - if not img: - return 0 - return img.blocksize * img.total_blocks - - -class DynamicGroupUpdate(object): - def __init__(self, src_size=None, tgt_size=None): - # None: group does not exist. 0: no size limits. - self.src_size = src_size - self.tgt_size = tgt_size - - -class DynamicPartitionsDifference(object): - def __init__(self, info_dict, block_diffs, progress_dict=None, - source_info_dict=None): - if progress_dict is None: - progress_dict = {} - - self._remove_all_before_apply = False - if source_info_dict is None: - self._remove_all_before_apply = True - source_info_dict = {} - - block_diff_dict = collections.OrderedDict( - [(e.partition, e) for e in block_diffs]) - - assert len(block_diff_dict) == len(block_diffs), \ - "Duplicated BlockDifference object for {}".format( - [partition for partition, count in - collections.Counter(e.partition for e in block_diffs).items() - if count > 1]) - - self._partition_updates = collections.OrderedDict() - - for p, block_diff in block_diff_dict.items(): - self._partition_updates[p] = DynamicPartitionUpdate() - self._partition_updates[p].block_difference = block_diff - - for p, progress in progress_dict.items(): - if p in self._partition_updates: - self._partition_updates[p].progress = progress - - tgt_groups = shlex.split(info_dict.get( - "super_partition_groups", "").strip()) - src_groups = shlex.split(source_info_dict.get( - "super_partition_groups", "").strip()) - - for g in tgt_groups: - for p in shlex.split(info_dict.get( - "super_%s_partition_list" % g, "").strip()): - assert p in self._partition_updates, \ - "{} is in target super_{}_partition_list but no BlockDifference " \ - "object is provided.".format(p, g) - self._partition_updates[p].tgt_group = g - - for g in src_groups: - for p in shlex.split(source_info_dict.get( - "super_%s_partition_list" % g, "").strip()): - assert p in self._partition_updates, \ - "{} is in source super_{}_partition_list but no BlockDifference " \ - "object is provided.".format(p, g) - self._partition_updates[p].src_group = g - - target_dynamic_partitions = set(shlex.split(info_dict.get( - "dynamic_partition_list", "").strip())) - block_diffs_with_target = set(p for p, u in self._partition_updates.items() - if u.tgt_size) - assert block_diffs_with_target == target_dynamic_partitions, \ - "Target Dynamic partitions: {}, BlockDifference with target: {}".format( - list(target_dynamic_partitions), list(block_diffs_with_target)) - - source_dynamic_partitions = set(shlex.split(source_info_dict.get( - "dynamic_partition_list", "").strip())) - block_diffs_with_source = set(p for p, u in self._partition_updates.items() - if u.src_size) - assert block_diffs_with_source == source_dynamic_partitions, \ - "Source Dynamic partitions: {}, BlockDifference with source: {}".format( - list(source_dynamic_partitions), list(block_diffs_with_source)) - - if self._partition_updates: - logger.info("Updating dynamic partitions %s", - self._partition_updates.keys()) - - self._group_updates = collections.OrderedDict() - - for g in tgt_groups: - self._group_updates[g] = DynamicGroupUpdate() - self._group_updates[g].tgt_size = int(info_dict.get( - "super_%s_group_size" % g, "0").strip()) - - for g in src_groups: - if g not in self._group_updates: - self._group_updates[g] = DynamicGroupUpdate() - self._group_updates[g].src_size = int(source_info_dict.get( - "super_%s_group_size" % g, "0").strip()) - - self._Compute() - - def WriteScript(self, script, output_zip, write_verify_script=False): - script.Comment('--- Start patching dynamic partitions ---') - for p, u in self._partition_updates.items(): - if u.src_size and u.tgt_size and u.src_size > u.tgt_size: - script.Comment('Patch partition %s' % p) - u.block_difference.WriteScript(script, output_zip, progress=u.progress, - write_verify_script=False) - - op_list_path = MakeTempFile() - with open(op_list_path, 'w') as f: - for line in self._op_list: - f.write('{}\n'.format(line)) - - ZipWrite(output_zip, op_list_path, "dynamic_partitions_op_list") - - script.Comment('Update dynamic partition metadata') - script.AppendExtra('assert(update_dynamic_partitions(' - 'package_extract_file("dynamic_partitions_op_list")));') - - if write_verify_script: - for p, u in self._partition_updates.items(): - if u.src_size and u.tgt_size and u.src_size > u.tgt_size: - u.block_difference.WritePostInstallVerifyScript(script) - script.AppendExtra('unmap_partition("%s");' % p) # ignore errors - - for p, u in self._partition_updates.items(): - if u.tgt_size and u.src_size <= u.tgt_size: - script.Comment('Patch partition %s' % p) - u.block_difference.WriteScript(script, output_zip, progress=u.progress, - write_verify_script=write_verify_script) - if write_verify_script: - script.AppendExtra('unmap_partition("%s");' % p) # ignore errors - - script.Comment('--- End patching dynamic partitions ---') - - def _Compute(self): - self._op_list = list() - - def append(line): - self._op_list.append(line) - - def comment(line): - self._op_list.append("# %s" % line) - - if self._remove_all_before_apply: - comment('Remove all existing dynamic partitions and groups before ' - 'applying full OTA') - append('remove_all_groups') - - for p, u in self._partition_updates.items(): - if u.src_group and not u.tgt_group: - append('remove %s' % p) - - for p, u in self._partition_updates.items(): - if u.src_group and u.tgt_group and u.src_group != u.tgt_group: - comment('Move partition %s from %s to default' % (p, u.src_group)) - append('move %s default' % p) - - for p, u in self._partition_updates.items(): - if u.src_size and u.tgt_size and u.src_size > u.tgt_size: - comment('Shrink partition %s from %d to %d' % - (p, u.src_size, u.tgt_size)) - append('resize %s %s' % (p, u.tgt_size)) - - for g, u in self._group_updates.items(): - if u.src_size is not None and u.tgt_size is None: - append('remove_group %s' % g) - if (u.src_size is not None and u.tgt_size is not None and - u.src_size > u.tgt_size): - comment('Shrink group %s from %d to %d' % (g, u.src_size, u.tgt_size)) - append('resize_group %s %d' % (g, u.tgt_size)) - - for g, u in self._group_updates.items(): - if u.src_size is None and u.tgt_size is not None: - comment('Add group %s with maximum size %d' % (g, u.tgt_size)) - append('add_group %s %d' % (g, u.tgt_size)) - if (u.src_size is not None and u.tgt_size is not None and - u.src_size < u.tgt_size): - comment('Grow group %s from %d to %d' % (g, u.src_size, u.tgt_size)) - append('resize_group %s %d' % (g, u.tgt_size)) - - for p, u in self._partition_updates.items(): - if u.tgt_group and not u.src_group: - comment('Add partition %s to group %s' % (p, u.tgt_group)) - append('add %s %s' % (p, u.tgt_group)) - - for p, u in self._partition_updates.items(): - if u.tgt_size and u.src_size < u.tgt_size: - comment('Grow partition %s from %d to %d' % - (p, u.src_size, u.tgt_size)) - append('resize %s %d' % (p, u.tgt_size)) - - for p, u in self._partition_updates.items(): - if u.src_group and u.tgt_group and u.src_group != u.tgt_group: - comment('Move partition %s from default to %s' % - (p, u.tgt_group)) - append('move %s %s' % (p, u.tgt_group)) - - def GetBootImageBuildProp(boot_img, ramdisk_format=RamdiskFormat.LZ4): """ Get build.prop from ramdisk within the boot image diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py index 033c02e60c..664d5cd9e3 100644 --- a/tools/releasetools/edify_generator.py +++ b/tools/releasetools/edify_generator.py @@ -16,6 +16,36 @@ import re import common + +class ErrorCode(object): + """Define error_codes for failures that happen during the actual + update package installation. + + Error codes 0-999 are reserved for failures before the package + installation (i.e. low battery, package verification failure). + Detailed code in 'bootable/recovery/error_code.h' """ + + SYSTEM_VERIFICATION_FAILURE = 1000 + SYSTEM_UPDATE_FAILURE = 1001 + SYSTEM_UNEXPECTED_CONTENTS = 1002 + SYSTEM_NONZERO_CONTENTS = 1003 + SYSTEM_RECOVER_FAILURE = 1004 + VENDOR_VERIFICATION_FAILURE = 2000 + VENDOR_UPDATE_FAILURE = 2001 + VENDOR_UNEXPECTED_CONTENTS = 2002 + VENDOR_NONZERO_CONTENTS = 2003 + VENDOR_RECOVER_FAILURE = 2004 + OEM_PROP_MISMATCH = 3000 + FINGERPRINT_MISMATCH = 3001 + THUMBPRINT_MISMATCH = 3002 + OLDER_BUILD = 3003 + DEVICE_MISMATCH = 3004 + BAD_PATCH_FILE = 3005 + INSUFFICIENT_CACHE_SPACE = 3006 + TUNE_PARTITION_FAILURE = 3007 + APPLY_PATCH_FAILURE = 3008 + + class EdifyGenerator(object): """Class to generate scripts in the 'edify' recovery script language used from donut onwards.""" @@ -88,7 +118,7 @@ class EdifyGenerator(object): 'abort("E{code}: This package expects the value \\"{values}\\" for ' '\\"{name}\\"; this has value \\"" + ' '{get_prop_command} + "\\".");').format( - code=common.ErrorCode.OEM_PROP_MISMATCH, + code=ErrorCode.OEM_PROP_MISMATCH, get_prop_command=get_prop_command, name=name, values='\\" or \\"'.join(values)) self.script.append(cmd) @@ -101,7 +131,7 @@ class EdifyGenerator(object): for i in fp]) + ' ||\n abort("E%d: Package expects build fingerprint of %s; ' 'this device has " + getprop("ro.build.fingerprint") + ".");') % ( - common.ErrorCode.FINGERPRINT_MISMATCH, " or ".join(fp)) + ErrorCode.FINGERPRINT_MISMATCH, " or ".join(fp)) self.script.append(cmd) def AssertSomeThumbprint(self, *fp): @@ -112,7 +142,7 @@ class EdifyGenerator(object): for i in fp]) + ' ||\n abort("E%d: Package expects build thumbprint of %s; this ' 'device has " + getprop("ro.build.thumbprint") + ".");') % ( - common.ErrorCode.THUMBPRINT_MISMATCH, " or ".join(fp)) + ErrorCode.THUMBPRINT_MISMATCH, " or ".join(fp)) self.script.append(cmd) def AssertFingerprintOrThumbprint(self, fp, tp): @@ -133,14 +163,14 @@ class EdifyGenerator(object): ('(!less_than_int(%s, getprop("ro.build.date.utc"))) || ' 'abort("E%d: Can\'t install this package (%s) over newer ' 'build (" + getprop("ro.build.date") + ").");') % ( - timestamp, common.ErrorCode.OLDER_BUILD, timestamp_text)) + timestamp, ErrorCode.OLDER_BUILD, timestamp_text)) def AssertDevice(self, device): """Assert that the device identifier is the given string.""" cmd = ('getprop("ro.product.device") == "%s" || ' 'abort("E%d: This package is for \\"%s\\" devices; ' 'this is a \\"" + getprop("ro.product.device") + "\\".");') % ( - device, common.ErrorCode.DEVICE_MISMATCH, device) + device, ErrorCode.DEVICE_MISMATCH, device) self.script.append(cmd) def AssertSomeBootloader(self, *bootloaders): @@ -207,7 +237,7 @@ class EdifyGenerator(object): 'unexpected contents."));').format( target=target_expr, source=source_expr, - code=common.ErrorCode.BAD_PATCH_FILE))) + code=ErrorCode.BAD_PATCH_FILE))) def CacheFreeSpaceCheck(self, amount): """Check that there's at least 'amount' space that can be made @@ -216,7 +246,7 @@ class EdifyGenerator(object): self.script.append(('apply_patch_space(%d) || abort("E%d: Not enough free ' 'space on /cache to apply patches.");') % ( amount, - common.ErrorCode.INSUFFICIENT_CACHE_SPACE)) + ErrorCode.INSUFFICIENT_CACHE_SPACE)) def Mount(self, mount_point, mount_options_by_format=""): """Mount the partition with the given mount_point. @@ -264,7 +294,7 @@ class EdifyGenerator(object): 'tune2fs(' + "".join(['"%s", ' % (i,) for i in options]) + '%s) || abort("E%d: Failed to tune partition %s");' % ( self._GetSlotSuffixDeviceForEntry(p), - common.ErrorCode.TUNE_PARTITION_FAILURE, partition)) + ErrorCode.TUNE_PARTITION_FAILURE, partition)) def FormatPartition(self, partition): """Format the given partition, specified by its mount point (eg, @@ -354,7 +384,7 @@ class EdifyGenerator(object): target=target_expr, source=source_expr, patch=patch_expr, - code=common.ErrorCode.APPLY_PATCH_FAILURE))) + code=ErrorCode.APPLY_PATCH_FAILURE))) def _GetSlotSuffixDeviceForEntry(self, entry=None): """ diff --git a/tools/releasetools/make_recovery_patch.py b/tools/releasetools/make_recovery_patch.py index 1497d69ed7..397bf23932 100644 --- a/tools/releasetools/make_recovery_patch.py +++ b/tools/releasetools/make_recovery_patch.py @@ -21,6 +21,7 @@ import os import sys import common +from non_ab_ota import MakeRecoveryPatch if sys.hexversion < 0x02070000: print("Python 2.7 or newer is required.", file=sys.stderr) @@ -60,7 +61,7 @@ def main(argv): *fn.split("/")), "wb") as f: f.write(data) - common.MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img) + MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img) if __name__ == '__main__': diff --git a/tools/releasetools/non_ab_ota.py b/tools/releasetools/non_ab_ota.py index 667891c65e..5839d17730 100644 --- a/tools/releasetools/non_ab_ota.py +++ b/tools/releasetools/non_ab_ota.py @@ -13,17 +13,25 @@ # limitations under the License. import collections +import copy +import imp import logging import os +import time +import threading +import tempfile import zipfile +import subprocess +import shlex import common import edify_generator -import verity_utils +from edify_generator import ErrorCode from check_target_files_vintf import CheckVintfIfTrebleEnabled, HasPartition -from common import OPTIONS +from common import OPTIONS, Run, MakeTempDir, RunAndCheckOutput, ZipWrite, MakeTempFile from ota_utils import UNZIP_PATTERN, FinalizeMetadata, GetPackageMetadata, PropertyFiles -import subprocess +from blockimgdiff import BlockImageDiff +from hashlib import sha1 logger = logging.getLogger(__name__) @@ -51,7 +59,7 @@ def GetBlockDifferences(target_zip, source_zip, target_info, source_info, check_first_block = partition_source_info.fs_type == "ext4" # Disable imgdiff because it relies on zlib to produce stable output # across different versions, which is often not the case. - return common.BlockDifference(name, partition_tgt, partition_src, + return BlockDifference(name, partition_tgt, partition_src, check_first_block, version=blockimgdiff_version, disable_imgdiff=True) @@ -76,7 +84,7 @@ def GetBlockDifferences(target_zip, source_zip, target_info, source_info, tgt = common.GetUserImage(partition, OPTIONS.input_tmp, target_zip, info_dict=target_info, reset_file_map=True) - block_diff_dict[partition] = common.BlockDifference(partition, tgt, + block_diff_dict[partition] = BlockDifference(partition, tgt, src=None) # Incremental OTA update. else: @@ -95,7 +103,7 @@ def GetBlockDifferences(target_zip, source_zip, target_info, source_info, function_name = "FullOTA_GetBlockDifferences" if device_specific_diffs: - assert all(isinstance(diff, common.BlockDifference) + assert all(isinstance(diff, BlockDifference) for diff in device_specific_diffs), \ "{} is not returning a list of BlockDifference objects".format( function_name) @@ -131,7 +139,7 @@ def WriteFullOTAPackage(input_zip, output_file): output_zip = zipfile.ZipFile( staging_file, "w", compression=zipfile.ZIP_DEFLATED) - device_specific = common.DeviceSpecificParams( + device_specific = DeviceSpecificParams( input_zip=input_zip, input_version=target_api_version, output_zip=output_zip, @@ -217,7 +225,7 @@ else if get_stage("%(bcb_dev)s") == "3/3" then if target_info.get('use_dynamic_partitions') == "true": # Use empty source_info_dict to indicate that all partitions / groups must # be re-added. - dynamic_partitions_diff = common.DynamicPartitionsDifference( + dynamic_partitions_diff = DynamicPartitionsDifference( info_dict=OPTIONS.info_dict, block_diffs=block_diff_dict.values(), progress_dict=progress_dict) @@ -309,7 +317,7 @@ def WriteBlockIncrementalOTAPackage(target_zip, source_zip, output_file): output_zip = zipfile.ZipFile( staging_file, "w", compression=zipfile.ZIP_DEFLATED) - device_specific = common.DeviceSpecificParams( + device_specific = DeviceSpecificParams( source_zip=source_zip, source_version=source_api_version, source_tmp=OPTIONS.source_tmp, @@ -404,9 +412,9 @@ else if get_stage("%(bcb_dev)s") != "3/3" then required_cache_sizes = [diff.required_cache for diff in block_diff_dict.values()] if updating_boot: - boot_type, boot_device_expr = common.GetTypeAndDeviceExpr("/boot", + boot_type, boot_device_expr = GetTypeAndDeviceExpr("/boot", source_info) - d = common.Difference(target_boot, source_boot, "bsdiff") + d = Difference(target_boot, source_boot, "bsdiff") _, _, d = d.ComputePatch() if d is None: include_full_boot = True @@ -461,7 +469,7 @@ else if OPTIONS.target_info_dict.get("use_dynamic_partitions") != "true": raise RuntimeError( "can't generate incremental that disables dynamic partitions") - dynamic_partitions_diff = common.DynamicPartitionsDifference( + dynamic_partitions_diff = DynamicPartitionsDifference( info_dict=OPTIONS.target_info_dict, source_info_dict=OPTIONS.source_info_dict, block_diffs=block_diff_dict.values(), @@ -687,3 +695,891 @@ def HasRecoveryPatch(target_files_zip, info_dict): namelist = target_files_zip.namelist() return patch in namelist or img in namelist + + +class DeviceSpecificParams(object): + module = None + + def __init__(self, **kwargs): + """Keyword arguments to the constructor become attributes of this + object, which is passed to all functions in the device-specific + module.""" + for k, v in kwargs.items(): + setattr(self, k, v) + self.extras = OPTIONS.extras + + if self.module is None: + path = OPTIONS.device_specific + if not path: + return + try: + if os.path.isdir(path): + info = imp.find_module("releasetools", [path]) + else: + d, f = os.path.split(path) + b, x = os.path.splitext(f) + if x == ".py": + f = b + info = imp.find_module(f, [d]) + logger.info("loaded device-specific extensions from %s", path) + self.module = imp.load_module("device_specific", *info) + except ImportError: + logger.info("unable to load device-specific module; assuming none") + + def _DoCall(self, function_name, *args, **kwargs): + """Call the named function in the device-specific module, passing + the given args and kwargs. The first argument to the call will be + the DeviceSpecific object itself. If there is no module, or the + module does not define the function, return the value of the + 'default' kwarg (which itself defaults to None).""" + if self.module is None or not hasattr(self.module, function_name): + return kwargs.get("default") + return getattr(self.module, function_name)(*((self,) + args), **kwargs) + + def FullOTA_Assertions(self): + """Called after emitting the block of assertions at the top of a + full OTA package. Implementations can add whatever additional + assertions they like.""" + return self._DoCall("FullOTA_Assertions") + + def FullOTA_InstallBegin(self): + """Called at the start of full OTA installation.""" + return self._DoCall("FullOTA_InstallBegin") + + def FullOTA_GetBlockDifferences(self): + """Called during full OTA installation and verification. + Implementation should return a list of BlockDifference objects describing + the update on each additional partitions. + """ + return self._DoCall("FullOTA_GetBlockDifferences") + + def FullOTA_InstallEnd(self): + """Called at the end of full OTA installation; typically this is + used to install the image for the device's baseband processor.""" + return self._DoCall("FullOTA_InstallEnd") + + def IncrementalOTA_Assertions(self): + """Called after emitting the block of assertions at the top of an + incremental OTA package. Implementations can add whatever + additional assertions they like.""" + return self._DoCall("IncrementalOTA_Assertions") + + def IncrementalOTA_VerifyBegin(self): + """Called at the start of the verification phase of incremental + OTA installation; additional checks can be placed here to abort + the script before any changes are made.""" + return self._DoCall("IncrementalOTA_VerifyBegin") + + def IncrementalOTA_VerifyEnd(self): + """Called at the end of the verification phase of incremental OTA + installation; additional checks can be placed here to abort the + script before any changes are made.""" + return self._DoCall("IncrementalOTA_VerifyEnd") + + def IncrementalOTA_InstallBegin(self): + """Called at the start of incremental OTA installation (after + verification is complete).""" + return self._DoCall("IncrementalOTA_InstallBegin") + + def IncrementalOTA_GetBlockDifferences(self): + """Called during incremental OTA installation and verification. + Implementation should return a list of BlockDifference objects describing + the update on each additional partitions. + """ + return self._DoCall("IncrementalOTA_GetBlockDifferences") + + def IncrementalOTA_InstallEnd(self): + """Called at the end of incremental OTA installation; typically + this is used to install the image for the device's baseband + processor.""" + return self._DoCall("IncrementalOTA_InstallEnd") + + def VerifyOTA_Assertions(self): + return self._DoCall("VerifyOTA_Assertions") + + +DIFF_PROGRAM_BY_EXT = { + ".gz": "imgdiff", + ".zip": ["imgdiff", "-z"], + ".jar": ["imgdiff", "-z"], + ".apk": ["imgdiff", "-z"], + ".img": "imgdiff", +} + + +class Difference(object): + def __init__(self, tf, sf, diff_program=None): + self.tf = tf + self.sf = sf + self.patch = None + self.diff_program = diff_program + + def ComputePatch(self): + """Compute the patch (as a string of data) needed to turn sf into + tf. Returns the same tuple as GetPatch().""" + + tf = self.tf + sf = self.sf + + if self.diff_program: + diff_program = self.diff_program + else: + ext = os.path.splitext(tf.name)[1] + diff_program = DIFF_PROGRAM_BY_EXT.get(ext, "bsdiff") + + ttemp = tf.WriteToTemp() + stemp = sf.WriteToTemp() + + ext = os.path.splitext(tf.name)[1] + + try: + ptemp = tempfile.NamedTemporaryFile() + if isinstance(diff_program, list): + cmd = copy.copy(diff_program) + else: + cmd = [diff_program] + cmd.append(stemp.name) + cmd.append(ttemp.name) + cmd.append(ptemp.name) + p = Run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + err = [] + + def run(): + _, e = p.communicate() + if e: + err.append(e) + th = threading.Thread(target=run) + th.start() + th.join(timeout=300) # 5 mins + if th.is_alive(): + logger.warning("diff command timed out") + p.terminate() + th.join(5) + if th.is_alive(): + p.kill() + th.join() + + if p.returncode != 0: + logger.warning("Failure running %s:\n%s\n", cmd, "".join(err)) + self.patch = None + return None, None, None + diff = ptemp.read() + finally: + ptemp.close() + stemp.close() + ttemp.close() + + self.patch = diff + return self.tf, self.sf, self.patch + + def GetPatch(self): + """Returns a tuple of (target_file, source_file, patch_data). + + patch_data may be None if ComputePatch hasn't been called, or if + computing the patch failed. + """ + return self.tf, self.sf, self.patch + + +def ComputeDifferences(diffs): + """Call ComputePatch on all the Difference objects in 'diffs'.""" + logger.info("%d diffs to compute", len(diffs)) + + # Do the largest files first, to try and reduce the long-pole effect. + by_size = [(i.tf.size, i) for i in diffs] + by_size.sort(reverse=True) + by_size = [i[1] for i in by_size] + + lock = threading.Lock() + diff_iter = iter(by_size) # accessed under lock + + def worker(): + try: + lock.acquire() + for d in diff_iter: + lock.release() + start = time.time() + d.ComputePatch() + dur = time.time() - start + lock.acquire() + + tf, sf, patch = d.GetPatch() + if sf.name == tf.name: + name = tf.name + else: + name = "%s (%s)" % (tf.name, sf.name) + if patch is None: + logger.error("patching failed! %40s", name) + else: + logger.info( + "%8.2f sec %8d / %8d bytes (%6.2f%%) %s", dur, len(patch), + tf.size, 100.0 * len(patch) / tf.size, name) + lock.release() + except Exception: + logger.exception("Failed to compute diff from worker") + raise + + # start worker threads; wait for them all to finish. + threads = [threading.Thread(target=worker) + for i in range(OPTIONS.worker_threads)] + for th in threads: + th.start() + while threads: + threads.pop().join() + + +class BlockDifference(object): + def __init__(self, partition, tgt, src=None, check_first_block=False, + version=None, disable_imgdiff=False): + self.tgt = tgt + self.src = src + self.partition = partition + self.check_first_block = check_first_block + self.disable_imgdiff = disable_imgdiff + + if version is None: + version = max( + int(i) for i in + OPTIONS.info_dict.get("blockimgdiff_versions", "1").split(",")) + assert version >= 3 + self.version = version + + b = BlockImageDiff(tgt, src, threads=OPTIONS.worker_threads, + version=self.version, + disable_imgdiff=self.disable_imgdiff) + self.path = os.path.join(MakeTempDir(), partition) + b.Compute(self.path) + self._required_cache = b.max_stashed_size + self.touched_src_ranges = b.touched_src_ranges + self.touched_src_sha1 = b.touched_src_sha1 + + # On devices with dynamic partitions, for new partitions, + # src is None but OPTIONS.source_info_dict is not. + if OPTIONS.source_info_dict is None: + is_dynamic_build = OPTIONS.info_dict.get( + "use_dynamic_partitions") == "true" + is_dynamic_source = False + else: + is_dynamic_build = OPTIONS.source_info_dict.get( + "use_dynamic_partitions") == "true" + is_dynamic_source = partition in shlex.split( + OPTIONS.source_info_dict.get("dynamic_partition_list", "").strip()) + + is_dynamic_target = partition in shlex.split( + OPTIONS.info_dict.get("dynamic_partition_list", "").strip()) + + # For dynamic partitions builds, check partition list in both source + # and target build because new partitions may be added, and existing + # partitions may be removed. + is_dynamic = is_dynamic_build and (is_dynamic_source or is_dynamic_target) + + if is_dynamic: + self.device = 'map_partition("%s")' % partition + else: + if OPTIONS.source_info_dict is None: + _, device_expr = GetTypeAndDeviceExpr("/" + partition, + OPTIONS.info_dict) + else: + _, device_expr = GetTypeAndDeviceExpr("/" + partition, + OPTIONS.source_info_dict) + self.device = device_expr + + @property + def required_cache(self): + return self._required_cache + + def WriteScript(self, script, output_zip, progress=None, + write_verify_script=False): + if not self.src: + # write the output unconditionally + script.Print("Patching %s image unconditionally..." % (self.partition,)) + else: + script.Print("Patching %s image after verification." % (self.partition,)) + + if progress: + script.ShowProgress(progress, 0) + self._WriteUpdate(script, output_zip) + + if write_verify_script: + self.WritePostInstallVerifyScript(script) + + def WriteStrictVerifyScript(self, script): + """Verify all the blocks in the care_map, including clobbered blocks. + + This differs from the WriteVerifyScript() function: a) it prints different + error messages; b) it doesn't allow half-way updated images to pass the + verification.""" + + partition = self.partition + script.Print("Verifying %s..." % (partition,)) + ranges = self.tgt.care_map + ranges_str = ranges.to_string_raw() + script.AppendExtra( + 'range_sha1(%s, "%s") == "%s" && ui_print(" Verified.") || ' + 'ui_print("%s has unexpected contents.");' % ( + self.device, ranges_str, + self.tgt.TotalSha1(include_clobbered_blocks=True), + self.partition)) + script.AppendExtra("") + + def WriteVerifyScript(self, script, touched_blocks_only=False): + partition = self.partition + + # full OTA + if not self.src: + script.Print("Image %s will be patched unconditionally." % (partition,)) + + # incremental OTA + else: + if touched_blocks_only: + ranges = self.touched_src_ranges + expected_sha1 = self.touched_src_sha1 + else: + ranges = self.src.care_map.subtract(self.src.clobbered_blocks) + expected_sha1 = self.src.TotalSha1() + + # No blocks to be checked, skipping. + if not ranges: + return + + ranges_str = ranges.to_string_raw() + script.AppendExtra( + 'if (range_sha1(%s, "%s") == "%s" || block_image_verify(%s, ' + 'package_extract_file("%s.transfer.list"), "%s.new.dat", ' + '"%s.patch.dat")) then' % ( + self.device, ranges_str, expected_sha1, + self.device, partition, partition, partition)) + script.Print('Verified %s image...' % (partition,)) + script.AppendExtra('else') + + if self.version >= 4: + + # Bug: 21124327 + # When generating incrementals for the system and vendor partitions in + # version 4 or newer, explicitly check the first block (which contains + # the superblock) of the partition to see if it's what we expect. If + # this check fails, give an explicit log message about the partition + # having been remounted R/W (the most likely explanation). + if self.check_first_block: + script.AppendExtra('check_first_block(%s);' % (self.device,)) + + # If version >= 4, try block recovery before abort update + if partition == "system": + code = ErrorCode.SYSTEM_RECOVER_FAILURE + else: + code = ErrorCode.VENDOR_RECOVER_FAILURE + script.AppendExtra(( + 'ifelse (block_image_recover({device}, "{ranges}") && ' + 'block_image_verify({device}, ' + 'package_extract_file("{partition}.transfer.list"), ' + '"{partition}.new.dat", "{partition}.patch.dat"), ' + 'ui_print("{partition} recovered successfully."), ' + 'abort("E{code}: {partition} partition fails to recover"));\n' + 'endif;').format(device=self.device, ranges=ranges_str, + partition=partition, code=code)) + + # Abort the OTA update. Note that the incremental OTA cannot be applied + # even if it may match the checksum of the target partition. + # a) If version < 3, operations like move and erase will make changes + # unconditionally and damage the partition. + # b) If version >= 3, it won't even reach here. + else: + if partition == "system": + code = ErrorCode.SYSTEM_VERIFICATION_FAILURE + else: + code = ErrorCode.VENDOR_VERIFICATION_FAILURE + script.AppendExtra(( + 'abort("E%d: %s partition has unexpected contents");\n' + 'endif;') % (code, partition)) + + def WritePostInstallVerifyScript(self, script): + partition = self.partition + script.Print('Verifying the updated %s image...' % (partition,)) + # Unlike pre-install verification, clobbered_blocks should not be ignored. + ranges = self.tgt.care_map + ranges_str = ranges.to_string_raw() + script.AppendExtra( + 'if range_sha1(%s, "%s") == "%s" then' % ( + self.device, ranges_str, + self.tgt.TotalSha1(include_clobbered_blocks=True))) + + # Bug: 20881595 + # Verify that extended blocks are really zeroed out. + if self.tgt.extended: + ranges_str = self.tgt.extended.to_string_raw() + script.AppendExtra( + 'if range_sha1(%s, "%s") == "%s" then' % ( + self.device, ranges_str, + self._HashZeroBlocks(self.tgt.extended.size()))) + script.Print('Verified the updated %s image.' % (partition,)) + if partition == "system": + code = ErrorCode.SYSTEM_NONZERO_CONTENTS + else: + code = ErrorCode.VENDOR_NONZERO_CONTENTS + script.AppendExtra( + 'else\n' + ' abort("E%d: %s partition has unexpected non-zero contents after ' + 'OTA update");\n' + 'endif;' % (code, partition)) + else: + script.Print('Verified the updated %s image.' % (partition,)) + + if partition == "system": + code = ErrorCode.SYSTEM_UNEXPECTED_CONTENTS + else: + code = ErrorCode.VENDOR_UNEXPECTED_CONTENTS + + script.AppendExtra( + 'else\n' + ' abort("E%d: %s partition has unexpected contents after OTA ' + 'update");\n' + 'endif;' % (code, partition)) + + def _WriteUpdate(self, script, output_zip): + ZipWrite(output_zip, + '{}.transfer.list'.format(self.path), + '{}.transfer.list'.format(self.partition)) + + # For full OTA, compress the new.dat with brotli with quality 6 to reduce + # its size. Quailty 9 almost triples the compression time but doesn't + # further reduce the size too much. For a typical 1.8G system.new.dat + # zip | brotli(quality 6) | brotli(quality 9) + # compressed_size: 942M | 869M (~8% reduced) | 854M + # compression_time: 75s | 265s | 719s + # decompression_time: 15s | 25s | 25s + + if not self.src: + brotli_cmd = ['brotli', '--quality=6', + '--output={}.new.dat.br'.format(self.path), + '{}.new.dat'.format(self.path)] + print("Compressing {}.new.dat with brotli".format(self.partition)) + RunAndCheckOutput(brotli_cmd) + + new_data_name = '{}.new.dat.br'.format(self.partition) + ZipWrite(output_zip, + '{}.new.dat.br'.format(self.path), + new_data_name, + compress_type=zipfile.ZIP_STORED) + else: + new_data_name = '{}.new.dat'.format(self.partition) + ZipWrite(output_zip, '{}.new.dat'.format(self.path), new_data_name) + + ZipWrite(output_zip, + '{}.patch.dat'.format(self.path), + '{}.patch.dat'.format(self.partition), + compress_type=zipfile.ZIP_STORED) + + if self.partition == "system": + code = ErrorCode.SYSTEM_UPDATE_FAILURE + else: + code = ErrorCode.VENDOR_UPDATE_FAILURE + + call = ('block_image_update({device}, ' + 'package_extract_file("{partition}.transfer.list"), ' + '"{new_data_name}", "{partition}.patch.dat") ||\n' + ' abort("E{code}: Failed to update {partition} image.");'.format( + device=self.device, partition=self.partition, + new_data_name=new_data_name, code=code)) + script.AppendExtra(script.WordWrap(call)) + + def _HashBlocks(self, source, ranges): # pylint: disable=no-self-use + data = source.ReadRangeSet(ranges) + ctx = sha1() + + for p in data: + ctx.update(p) + + return ctx.hexdigest() + + def _HashZeroBlocks(self, num_blocks): # pylint: disable=no-self-use + """Return the hash value for all zero blocks.""" + zero_block = '\x00' * 4096 + ctx = sha1() + for _ in range(num_blocks): + ctx.update(zero_block) + + return ctx.hexdigest() + + +def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img, + info_dict=None): + """Generates the recovery-from-boot patch and writes the script to output. + + Most of the space in the boot and recovery images is just the kernel, which is + identical for the two, so the resulting patch should be efficient. Add it to + the output zip, along with a shell script that is run from init.rc on first + boot to actually do the patching and install the new recovery image. + + Args: + input_dir: The top-level input directory of the target-files.zip. + output_sink: The callback function that writes the result. + recovery_img: File object for the recovery image. + boot_img: File objects for the boot image. + info_dict: A dict returned by common.LoadInfoDict() on the input + target_files. Will use OPTIONS.info_dict if None has been given. + """ + if info_dict is None: + info_dict = OPTIONS.info_dict + + full_recovery_image = info_dict.get("full_recovery_image") == "true" + board_uses_vendorimage = info_dict.get("board_uses_vendorimage") == "true" + + if board_uses_vendorimage: + # In this case, the output sink is rooted at VENDOR + recovery_img_path = "etc/recovery.img" + recovery_resource_dat_path = "VENDOR/etc/recovery-resource.dat" + sh_dir = "bin" + else: + # In this case the output sink is rooted at SYSTEM + recovery_img_path = "vendor/etc/recovery.img" + recovery_resource_dat_path = "SYSTEM/vendor/etc/recovery-resource.dat" + sh_dir = "vendor/bin" + + if full_recovery_image: + output_sink(recovery_img_path, recovery_img.data) + + else: + system_root_image = info_dict.get("system_root_image") == "true" + include_recovery_dtbo = info_dict.get("include_recovery_dtbo") == "true" + include_recovery_acpio = info_dict.get("include_recovery_acpio") == "true" + path = os.path.join(input_dir, recovery_resource_dat_path) + # With system-root-image, boot and recovery images will have mismatching + # entries (only recovery has the ramdisk entry) (Bug: 72731506). Use bsdiff + # to handle such a case. + if system_root_image or include_recovery_dtbo or include_recovery_acpio: + diff_program = ["bsdiff"] + bonus_args = "" + assert not os.path.exists(path) + else: + diff_program = ["imgdiff"] + if os.path.exists(path): + diff_program.append("-b") + diff_program.append(path) + bonus_args = "--bonus /vendor/etc/recovery-resource.dat" + else: + bonus_args = "" + + d = Difference(recovery_img, boot_img, diff_program=diff_program) + _, _, patch = d.ComputePatch() + output_sink("recovery-from-boot.p", patch) + + try: + # The following GetTypeAndDevice()s need to use the path in the target + # info_dict instead of source_info_dict. + boot_type, boot_device = GetTypeAndDevice("/boot", info_dict, + check_no_slot=False) + recovery_type, recovery_device = GetTypeAndDevice("/recovery", info_dict, + check_no_slot=False) + except KeyError: + return + + if full_recovery_image: + + # Note that we use /vendor to refer to the recovery resources. This will + # work for a separate vendor partition mounted at /vendor or a + # /system/vendor subdirectory on the system partition, for which init will + # create a symlink from /vendor to /system/vendor. + + sh = """#!/vendor/bin/sh +if ! applypatch --check %(type)s:%(device)s:%(size)d:%(sha1)s; then + applypatch \\ + --flash /vendor/etc/recovery.img \\ + --target %(type)s:%(device)s:%(size)d:%(sha1)s && \\ + log -t recovery "Installing new recovery image: succeeded" || \\ + log -t recovery "Installing new recovery image: failed" +else + log -t recovery "Recovery image already installed" +fi +""" % {'type': recovery_type, + 'device': recovery_device, + 'sha1': recovery_img.sha1, + 'size': recovery_img.size} + else: + sh = """#!/vendor/bin/sh +if ! applypatch --check %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s; then + applypatch %(bonus_args)s \\ + --patch /vendor/recovery-from-boot.p \\ + --source %(boot_type)s:%(boot_device)s:%(boot_size)d:%(boot_sha1)s \\ + --target %(recovery_type)s:%(recovery_device)s:%(recovery_size)d:%(recovery_sha1)s && \\ + log -t recovery "Installing new recovery image: succeeded" || \\ + log -t recovery "Installing new recovery image: failed" +else + log -t recovery "Recovery image already installed" +fi +""" % {'boot_size': boot_img.size, + 'boot_sha1': boot_img.sha1, + 'recovery_size': recovery_img.size, + 'recovery_sha1': recovery_img.sha1, + 'boot_type': boot_type, + 'boot_device': boot_device + '$(getprop ro.boot.slot_suffix)', + 'recovery_type': recovery_type, + 'recovery_device': recovery_device + '$(getprop ro.boot.slot_suffix)', + 'bonus_args': bonus_args} + + # The install script location moved from /system/etc to /system/bin in the L + # release. In the R release it is in VENDOR/bin or SYSTEM/vendor/bin. + sh_location = os.path.join(sh_dir, "install-recovery.sh") + + logger.info("putting script in %s", sh_location) + + output_sink(sh_location, sh.encode()) + + +class DynamicPartitionUpdate(object): + def __init__(self, src_group=None, tgt_group=None, progress=None, + block_difference=None): + self.src_group = src_group + self.tgt_group = tgt_group + self.progress = progress + self.block_difference = block_difference + + @property + def src_size(self): + if not self.block_difference: + return 0 + return DynamicPartitionUpdate._GetSparseImageSize(self.block_difference.src) + + @property + def tgt_size(self): + if not self.block_difference: + return 0 + return DynamicPartitionUpdate._GetSparseImageSize(self.block_difference.tgt) + + @staticmethod + def _GetSparseImageSize(img): + if not img: + return 0 + return img.blocksize * img.total_blocks + + +class DynamicGroupUpdate(object): + def __init__(self, src_size=None, tgt_size=None): + # None: group does not exist. 0: no size limits. + self.src_size = src_size + self.tgt_size = tgt_size + + +class DynamicPartitionsDifference(object): + def __init__(self, info_dict, block_diffs, progress_dict=None, + source_info_dict=None): + if progress_dict is None: + progress_dict = {} + + self._remove_all_before_apply = False + if source_info_dict is None: + self._remove_all_before_apply = True + source_info_dict = {} + + block_diff_dict = collections.OrderedDict( + [(e.partition, e) for e in block_diffs]) + + assert len(block_diff_dict) == len(block_diffs), \ + "Duplicated BlockDifference object for {}".format( + [partition for partition, count in + collections.Counter(e.partition for e in block_diffs).items() + if count > 1]) + + self._partition_updates = collections.OrderedDict() + + for p, block_diff in block_diff_dict.items(): + self._partition_updates[p] = DynamicPartitionUpdate() + self._partition_updates[p].block_difference = block_diff + + for p, progress in progress_dict.items(): + if p in self._partition_updates: + self._partition_updates[p].progress = progress + + tgt_groups = shlex.split(info_dict.get( + "super_partition_groups", "").strip()) + src_groups = shlex.split(source_info_dict.get( + "super_partition_groups", "").strip()) + + for g in tgt_groups: + for p in shlex.split(info_dict.get( + "super_%s_partition_list" % g, "").strip()): + assert p in self._partition_updates, \ + "{} is in target super_{}_partition_list but no BlockDifference " \ + "object is provided.".format(p, g) + self._partition_updates[p].tgt_group = g + + for g in src_groups: + for p in shlex.split(source_info_dict.get( + "super_%s_partition_list" % g, "").strip()): + assert p in self._partition_updates, \ + "{} is in source super_{}_partition_list but no BlockDifference " \ + "object is provided.".format(p, g) + self._partition_updates[p].src_group = g + + target_dynamic_partitions = set(shlex.split(info_dict.get( + "dynamic_partition_list", "").strip())) + block_diffs_with_target = set(p for p, u in self._partition_updates.items() + if u.tgt_size) + assert block_diffs_with_target == target_dynamic_partitions, \ + "Target Dynamic partitions: {}, BlockDifference with target: {}".format( + list(target_dynamic_partitions), list(block_diffs_with_target)) + + source_dynamic_partitions = set(shlex.split(source_info_dict.get( + "dynamic_partition_list", "").strip())) + block_diffs_with_source = set(p for p, u in self._partition_updates.items() + if u.src_size) + assert block_diffs_with_source == source_dynamic_partitions, \ + "Source Dynamic partitions: {}, BlockDifference with source: {}".format( + list(source_dynamic_partitions), list(block_diffs_with_source)) + + if self._partition_updates: + logger.info("Updating dynamic partitions %s", + self._partition_updates.keys()) + + self._group_updates = collections.OrderedDict() + + for g in tgt_groups: + self._group_updates[g] = DynamicGroupUpdate() + self._group_updates[g].tgt_size = int(info_dict.get( + "super_%s_group_size" % g, "0").strip()) + + for g in src_groups: + if g not in self._group_updates: + self._group_updates[g] = DynamicGroupUpdate() + self._group_updates[g].src_size = int(source_info_dict.get( + "super_%s_group_size" % g, "0").strip()) + + self._Compute() + + def WriteScript(self, script, output_zip, write_verify_script=False): + script.Comment('--- Start patching dynamic partitions ---') + for p, u in self._partition_updates.items(): + if u.src_size and u.tgt_size and u.src_size > u.tgt_size: + script.Comment('Patch partition %s' % p) + u.block_difference.WriteScript(script, output_zip, progress=u.progress, + write_verify_script=False) + + op_list_path = MakeTempFile() + with open(op_list_path, 'w') as f: + for line in self._op_list: + f.write('{}\n'.format(line)) + + ZipWrite(output_zip, op_list_path, "dynamic_partitions_op_list") + + script.Comment('Update dynamic partition metadata') + script.AppendExtra('assert(update_dynamic_partitions(' + 'package_extract_file("dynamic_partitions_op_list")));') + + if write_verify_script: + for p, u in self._partition_updates.items(): + if u.src_size and u.tgt_size and u.src_size > u.tgt_size: + u.block_difference.WritePostInstallVerifyScript(script) + script.AppendExtra('unmap_partition("%s");' % p) # ignore errors + + for p, u in self._partition_updates.items(): + if u.tgt_size and u.src_size <= u.tgt_size: + script.Comment('Patch partition %s' % p) + u.block_difference.WriteScript(script, output_zip, progress=u.progress, + write_verify_script=write_verify_script) + if write_verify_script: + script.AppendExtra('unmap_partition("%s");' % p) # ignore errors + + script.Comment('--- End patching dynamic partitions ---') + + def _Compute(self): + self._op_list = list() + + def append(line): + self._op_list.append(line) + + def comment(line): + self._op_list.append("# %s" % line) + + if self._remove_all_before_apply: + comment('Remove all existing dynamic partitions and groups before ' + 'applying full OTA') + append('remove_all_groups') + + for p, u in self._partition_updates.items(): + if u.src_group and not u.tgt_group: + append('remove %s' % p) + + for p, u in self._partition_updates.items(): + if u.src_group and u.tgt_group and u.src_group != u.tgt_group: + comment('Move partition %s from %s to default' % (p, u.src_group)) + append('move %s default' % p) + + for p, u in self._partition_updates.items(): + if u.src_size and u.tgt_size and u.src_size > u.tgt_size: + comment('Shrink partition %s from %d to %d' % + (p, u.src_size, u.tgt_size)) + append('resize %s %s' % (p, u.tgt_size)) + + for g, u in self._group_updates.items(): + if u.src_size is not None and u.tgt_size is None: + append('remove_group %s' % g) + if (u.src_size is not None and u.tgt_size is not None and + u.src_size > u.tgt_size): + comment('Shrink group %s from %d to %d' % (g, u.src_size, u.tgt_size)) + append('resize_group %s %d' % (g, u.tgt_size)) + + for g, u in self._group_updates.items(): + if u.src_size is None and u.tgt_size is not None: + comment('Add group %s with maximum size %d' % (g, u.tgt_size)) + append('add_group %s %d' % (g, u.tgt_size)) + if (u.src_size is not None and u.tgt_size is not None and + u.src_size < u.tgt_size): + comment('Grow group %s from %d to %d' % (g, u.src_size, u.tgt_size)) + append('resize_group %s %d' % (g, u.tgt_size)) + + for p, u in self._partition_updates.items(): + if u.tgt_group and not u.src_group: + comment('Add partition %s to group %s' % (p, u.tgt_group)) + append('add %s %s' % (p, u.tgt_group)) + + for p, u in self._partition_updates.items(): + if u.tgt_size and u.src_size < u.tgt_size: + comment('Grow partition %s from %d to %d' % + (p, u.src_size, u.tgt_size)) + append('resize %s %d' % (p, u.tgt_size)) + + for p, u in self._partition_updates.items(): + if u.src_group and u.tgt_group and u.src_group != u.tgt_group: + comment('Move partition %s from default to %s' % + (p, u.tgt_group)) + append('move %s %s' % (p, u.tgt_group)) + + +# map recovery.fstab's fs_types to mount/format "partition types" +PARTITION_TYPES = { + "ext4": "EMMC", + "emmc": "EMMC", + "f2fs": "EMMC", + "squashfs": "EMMC", + "erofs": "EMMC" +} + + +def GetTypeAndDevice(mount_point, info, check_no_slot=True): + """ + Use GetTypeAndDeviceExpr whenever possible. This function is kept for + backwards compatibility. It aborts if the fstab entry has slotselect option + (unless check_no_slot is explicitly set to False). + """ + fstab = info["fstab"] + if fstab: + if check_no_slot: + assert not fstab[mount_point].slotselect, \ + "Use GetTypeAndDeviceExpr instead" + return (PARTITION_TYPES[fstab[mount_point].fs_type], + fstab[mount_point].device) + raise KeyError + + +def GetTypeAndDeviceExpr(mount_point, info): + """ + Return the filesystem of the partition, and an edify expression that evaluates + to the device at runtime. + """ + fstab = info["fstab"] + if fstab: + p = fstab[mount_point] + device_expr = '"%s"' % fstab[mount_point].device + if p.slotselect: + device_expr = 'add_slot_suffix(%s)' % device_expr + return (PARTITION_TYPES[fstab[mount_point].fs_type], device_expr) + raise KeyError diff --git a/tools/releasetools/test_common.py b/tools/releasetools/test_common.py index 14f0e88f91..8052821567 100644 --- a/tools/releasetools/test_common.py +++ b/tools/releasetools/test_common.py @@ -26,7 +26,6 @@ from typing import BinaryIO import common import test_utils import validate_target_files -from images import EmptyImage, DataImage from rangelib import RangeSet @@ -1671,292 +1670,6 @@ class CommonUtilsTest(test_utils.ReleaseToolsTestCase): test_file.name, 'generic_kernel') -class InstallRecoveryScriptFormatTest(test_utils.ReleaseToolsTestCase): - """Checks the format of install-recovery.sh. - - Its format should match between common.py and validate_target_files.py. - """ - - def setUp(self): - self._tempdir = common.MakeTempDir() - # Create a fake dict that contains the fstab info for boot&recovery. - self._info = {"fstab": {}} - fake_fstab = [ - "/dev/soc.0/by-name/boot /boot emmc defaults defaults", - "/dev/soc.0/by-name/recovery /recovery emmc defaults defaults"] - self._info["fstab"] = common.LoadRecoveryFSTab("\n".join, 2, fake_fstab) - # Construct the gzipped recovery.img and boot.img - self.recovery_data = bytearray([ - 0x1f, 0x8b, 0x08, 0x00, 0x81, 0x11, 0x02, 0x5a, 0x00, 0x03, 0x2b, 0x4a, - 0x4d, 0xce, 0x2f, 0x4b, 0x2d, 0xaa, 0x04, 0x00, 0xc9, 0x93, 0x43, 0xf3, - 0x08, 0x00, 0x00, 0x00 - ]) - # echo -n "boot" | gzip -f | hd - self.boot_data = bytearray([ - 0x1f, 0x8b, 0x08, 0x00, 0x8c, 0x12, 0x02, 0x5a, 0x00, 0x03, 0x4b, 0xca, - 0xcf, 0x2f, 0x01, 0x00, 0xc4, 0xae, 0xed, 0x46, 0x04, 0x00, 0x00, 0x00 - ]) - - def _out_tmp_sink(self, name, data, prefix="SYSTEM"): - loc = os.path.join(self._tempdir, prefix, name) - if not os.path.exists(os.path.dirname(loc)): - os.makedirs(os.path.dirname(loc)) - with open(loc, "wb") as f: - f.write(data) - - def test_full_recovery(self): - recovery_image = common.File("recovery.img", self.recovery_data) - boot_image = common.File("boot.img", self.boot_data) - self._info["full_recovery_image"] = "true" - - common.MakeRecoveryPatch(self._tempdir, self._out_tmp_sink, - recovery_image, boot_image, self._info) - validate_target_files.ValidateInstallRecoveryScript(self._tempdir, - self._info) - - @test_utils.SkipIfExternalToolsUnavailable() - def test_recovery_from_boot(self): - recovery_image = common.File("recovery.img", self.recovery_data) - self._out_tmp_sink("recovery.img", recovery_image.data, "IMAGES") - boot_image = common.File("boot.img", self.boot_data) - self._out_tmp_sink("boot.img", boot_image.data, "IMAGES") - - common.MakeRecoveryPatch(self._tempdir, self._out_tmp_sink, - recovery_image, boot_image, self._info) - validate_target_files.ValidateInstallRecoveryScript(self._tempdir, - self._info) - # Validate 'recovery-from-boot' with bonus argument. - self._out_tmp_sink("etc/recovery-resource.dat", b"bonus", "SYSTEM") - common.MakeRecoveryPatch(self._tempdir, self._out_tmp_sink, - recovery_image, boot_image, self._info) - validate_target_files.ValidateInstallRecoveryScript(self._tempdir, - self._info) - - -class MockBlockDifference(object): - - def __init__(self, partition, tgt, src=None): - self.partition = partition - self.tgt = tgt - self.src = src - - def WriteScript(self, script, _, progress=None, - write_verify_script=False): - if progress: - script.AppendExtra("progress({})".format(progress)) - script.AppendExtra("patch({});".format(self.partition)) - if write_verify_script: - self.WritePostInstallVerifyScript(script) - - def WritePostInstallVerifyScript(self, script): - script.AppendExtra("verify({});".format(self.partition)) - - -class FakeSparseImage(object): - - def __init__(self, size): - self.blocksize = 4096 - self.total_blocks = size // 4096 - assert size % 4096 == 0, "{} is not a multiple of 4096".format(size) - - -class DynamicPartitionsDifferenceTest(test_utils.ReleaseToolsTestCase): - - @staticmethod - def get_op_list(output_path): - with zipfile.ZipFile(output_path, allowZip64=True) as output_zip: - with output_zip.open('dynamic_partitions_op_list') as op_list: - return [line.decode().strip() for line in op_list.readlines() - if not line.startswith(b'#')] - - def setUp(self): - self.script = test_utils.MockScriptWriter() - self.output_path = common.MakeTempFile(suffix='.zip') - - def test_full(self): - target_info = common.LoadDictionaryFromLines(""" -dynamic_partition_list=system vendor -super_partition_groups=group_foo -super_group_foo_group_size={group_size} -super_group_foo_partition_list=system vendor -""".format(group_size=4 * GiB).split("\n")) - block_diffs = [MockBlockDifference("system", FakeSparseImage(3 * GiB)), - MockBlockDifference("vendor", FakeSparseImage(1 * GiB))] - - dp_diff = common.DynamicPartitionsDifference(target_info, block_diffs) - with zipfile.ZipFile(self.output_path, 'w', allowZip64=True) as output_zip: - dp_diff.WriteScript(self.script, output_zip, write_verify_script=True) - - self.assertEqual(str(self.script).strip(), """ -assert(update_dynamic_partitions(package_extract_file("dynamic_partitions_op_list"))); -patch(system); -verify(system); -unmap_partition("system"); -patch(vendor); -verify(vendor); -unmap_partition("vendor"); -""".strip()) - - lines = self.get_op_list(self.output_path) - - remove_all_groups = lines.index("remove_all_groups") - add_group = lines.index("add_group group_foo 4294967296") - add_vendor = lines.index("add vendor group_foo") - add_system = lines.index("add system group_foo") - resize_vendor = lines.index("resize vendor 1073741824") - resize_system = lines.index("resize system 3221225472") - - self.assertLess(remove_all_groups, add_group, - "Should add groups after removing all groups") - self.assertLess(add_group, min(add_vendor, add_system), - "Should add partitions after adding group") - self.assertLess(add_system, resize_system, - "Should resize system after adding it") - self.assertLess(add_vendor, resize_vendor, - "Should resize vendor after adding it") - - def test_inc_groups(self): - source_info = common.LoadDictionaryFromLines(""" -super_partition_groups=group_foo group_bar group_baz -super_group_foo_group_size={group_foo_size} -super_group_bar_group_size={group_bar_size} -""".format(group_foo_size=4 * GiB, group_bar_size=3 * GiB).split("\n")) - target_info = common.LoadDictionaryFromLines(""" -super_partition_groups=group_foo group_baz group_qux -super_group_foo_group_size={group_foo_size} -super_group_baz_group_size={group_baz_size} -super_group_qux_group_size={group_qux_size} -""".format(group_foo_size=3 * GiB, group_baz_size=4 * GiB, - group_qux_size=1 * GiB).split("\n")) - - dp_diff = common.DynamicPartitionsDifference(target_info, - block_diffs=[], - source_info_dict=source_info) - with zipfile.ZipFile(self.output_path, 'w', allowZip64=True) as output_zip: - dp_diff.WriteScript(self.script, output_zip, write_verify_script=True) - - lines = self.get_op_list(self.output_path) - - removed = lines.index("remove_group group_bar") - shrunk = lines.index("resize_group group_foo 3221225472") - grown = lines.index("resize_group group_baz 4294967296") - added = lines.index("add_group group_qux 1073741824") - - self.assertLess(max(removed, shrunk), - min(grown, added), - "ops that remove / shrink partitions must precede ops that " - "grow / add partitions") - - def test_incremental(self): - source_info = common.LoadDictionaryFromLines(""" -dynamic_partition_list=system vendor product system_ext -super_partition_groups=group_foo -super_group_foo_group_size={group_foo_size} -super_group_foo_partition_list=system vendor product system_ext -""".format(group_foo_size=4 * GiB).split("\n")) - target_info = common.LoadDictionaryFromLines(""" -dynamic_partition_list=system vendor product odm -super_partition_groups=group_foo group_bar -super_group_foo_group_size={group_foo_size} -super_group_foo_partition_list=system vendor odm -super_group_bar_group_size={group_bar_size} -super_group_bar_partition_list=product -""".format(group_foo_size=3 * GiB, group_bar_size=1 * GiB).split("\n")) - - block_diffs = [MockBlockDifference("system", FakeSparseImage(1536 * MiB), - src=FakeSparseImage(1024 * MiB)), - MockBlockDifference("vendor", FakeSparseImage(512 * MiB), - src=FakeSparseImage(1024 * MiB)), - MockBlockDifference("product", FakeSparseImage(1024 * MiB), - src=FakeSparseImage(1024 * MiB)), - MockBlockDifference("system_ext", None, - src=FakeSparseImage(1024 * MiB)), - MockBlockDifference("odm", FakeSparseImage(1024 * MiB), - src=None)] - - dp_diff = common.DynamicPartitionsDifference(target_info, block_diffs, - source_info_dict=source_info) - with zipfile.ZipFile(self.output_path, 'w', allowZip64=True) as output_zip: - dp_diff.WriteScript(self.script, output_zip, write_verify_script=True) - - metadata_idx = self.script.lines.index( - 'assert(update_dynamic_partitions(package_extract_file(' - '"dynamic_partitions_op_list")));') - self.assertLess(self.script.lines.index('patch(vendor);'), metadata_idx) - self.assertLess(metadata_idx, self.script.lines.index('verify(vendor);')) - for p in ("product", "system", "odm"): - patch_idx = self.script.lines.index("patch({});".format(p)) - verify_idx = self.script.lines.index("verify({});".format(p)) - self.assertLess(metadata_idx, patch_idx, - "Should patch {} after updating metadata".format(p)) - self.assertLess(patch_idx, verify_idx, - "Should verify {} after patching".format(p)) - - self.assertNotIn("patch(system_ext);", self.script.lines) - - lines = self.get_op_list(self.output_path) - - remove = lines.index("remove system_ext") - move_product_out = lines.index("move product default") - shrink = lines.index("resize vendor 536870912") - shrink_group = lines.index("resize_group group_foo 3221225472") - add_group_bar = lines.index("add_group group_bar 1073741824") - add_odm = lines.index("add odm group_foo") - grow_existing = lines.index("resize system 1610612736") - grow_added = lines.index("resize odm 1073741824") - move_product_in = lines.index("move product group_bar") - - max_idx_move_partition_out_foo = max(remove, move_product_out, shrink) - min_idx_move_partition_in_foo = min(add_odm, grow_existing, grow_added) - - self.assertLess(max_idx_move_partition_out_foo, shrink_group, - "Must shrink group after partitions inside group are shrunk" - " / removed") - - self.assertLess(add_group_bar, move_product_in, - "Must add partitions to group after group is added") - - self.assertLess(max_idx_move_partition_out_foo, - min_idx_move_partition_in_foo, - "Must shrink partitions / remove partitions from group" - "before adding / moving partitions into group") - - def test_remove_partition(self): - source_info = common.LoadDictionaryFromLines(""" -blockimgdiff_versions=3,4 -use_dynamic_partitions=true -dynamic_partition_list=foo -super_partition_groups=group_foo -super_group_foo_group_size={group_foo_size} -super_group_foo_partition_list=foo -""".format(group_foo_size=4 * GiB).split("\n")) - target_info = common.LoadDictionaryFromLines(""" -blockimgdiff_versions=3,4 -use_dynamic_partitions=true -super_partition_groups=group_foo -super_group_foo_group_size={group_foo_size} -""".format(group_foo_size=4 * GiB).split("\n")) - - common.OPTIONS.info_dict = target_info - common.OPTIONS.target_info_dict = target_info - common.OPTIONS.source_info_dict = source_info - common.OPTIONS.cache_size = 4 * 4096 - - block_diffs = [common.BlockDifference("foo", EmptyImage(), - src=DataImage("source", pad=True))] - - dp_diff = common.DynamicPartitionsDifference(target_info, block_diffs, - source_info_dict=source_info) - with zipfile.ZipFile(self.output_path, 'w', allowZip64=True) as output_zip: - dp_diff.WriteScript(self.script, output_zip, write_verify_script=True) - - self.assertNotIn("block_image_update", str(self.script), - "Removed partition should not be patched.") - - lines = self.get_op_list(self.output_path) - self.assertEqual(lines, ["remove foo"]) - - class PartitionBuildPropsTest(test_utils.ReleaseToolsTestCase): def setUp(self): self.odm_build_prop = [ diff --git a/tools/releasetools/test_non_ab_ota.py b/tools/releasetools/test_non_ab_ota.py index 5207e2fc72..7a5ccd3091 100644 --- a/tools/releasetools/test_non_ab_ota.py +++ b/tools/releasetools/test_non_ab_ota.py @@ -15,19 +15,24 @@ # import copy +import os import zipfile import common import test_utils +import validate_target_files -from non_ab_ota import NonAbOtaPropertyFiles, WriteFingerprintAssertion +from images import EmptyImage, DataImage +from non_ab_ota import NonAbOtaPropertyFiles, WriteFingerprintAssertion, BlockDifference, DynamicPartitionsDifference, MakeRecoveryPatch from test_utils import PropertyFilesTestCase class NonAbOtaPropertyFilesTest(PropertyFilesTestCase): """Additional validity checks specialized for NonAbOtaPropertyFiles.""" + def setUp(self): - common.OPTIONS.no_signing = False + common.OPTIONS.no_signing = False + def test_init(self): property_files = NonAbOtaPropertyFiles() self.assertEqual('ota-property-files', property_files.name) @@ -55,7 +60,8 @@ class NonAbOtaPropertyFilesTest(PropertyFilesTestCase): with zipfile.ZipFile(zip_file) as zip_fp: raw_metadata = property_files.GetPropertyFilesString( zip_fp, reserve_space=False) - property_files_string = property_files.Finalize(zip_fp, len(raw_metadata)) + property_files_string = property_files.Finalize( + zip_fp, len(raw_metadata)) tokens = self._parse_property_files_string(property_files_string) self.assertEqual(2, len(tokens)) @@ -77,6 +83,7 @@ class NonAbOtaPropertyFilesTest(PropertyFilesTestCase): property_files.Verify(zip_fp, raw_metadata) + class NonAbOTATest(test_utils.ReleaseToolsTestCase): TEST_TARGET_INFO_DICT = { 'build.prop': common.PartitionBuildProps.FromDictionary( @@ -98,7 +105,7 @@ class NonAbOTATest(test_utils.ReleaseToolsTestCase): ), 'vendor.build.prop': common.PartitionBuildProps.FromDictionary( 'vendor', { - 'ro.vendor.build.fingerprint': 'vendor-build-fingerprint'} + 'ro.vendor.build.fingerprint': 'vendor-build-fingerprint'} ), 'property1': 'value1', 'property2': 4096, @@ -118,6 +125,7 @@ class NonAbOTATest(test_utils.ReleaseToolsTestCase): 'ro.product.device': 'device3', }, ] + def test_WriteFingerprintAssertion_without_oem_props(self): target_info = common.BuildInfo(self.TEST_TARGET_INFO_DICT, None) source_info_dict = copy.deepcopy(self.TEST_TARGET_INFO_DICT) @@ -170,3 +178,296 @@ class NonAbOTATest(test_utils.ReleaseToolsTestCase): [('AssertSomeThumbprint', 'build-thumbprint', 'source-build-thumbprint')], script_writer.lines) + + +KiB = 1024 +MiB = 1024 * KiB +GiB = 1024 * MiB + + +class MockBlockDifference(object): + + def __init__(self, partition, tgt, src=None): + self.partition = partition + self.tgt = tgt + self.src = src + + def WriteScript(self, script, _, progress=None, + write_verify_script=False): + if progress: + script.AppendExtra("progress({})".format(progress)) + script.AppendExtra("patch({});".format(self.partition)) + if write_verify_script: + self.WritePostInstallVerifyScript(script) + + def WritePostInstallVerifyScript(self, script): + script.AppendExtra("verify({});".format(self.partition)) + + +class FakeSparseImage(object): + + def __init__(self, size): + self.blocksize = 4096 + self.total_blocks = size // 4096 + assert size % 4096 == 0, "{} is not a multiple of 4096".format(size) + + +class DynamicPartitionsDifferenceTest(test_utils.ReleaseToolsTestCase): + + @staticmethod + def get_op_list(output_path): + with zipfile.ZipFile(output_path, allowZip64=True) as output_zip: + with output_zip.open('dynamic_partitions_op_list') as op_list: + return [line.decode().strip() for line in op_list.readlines() + if not line.startswith(b'#')] + + def setUp(self): + self.script = test_utils.MockScriptWriter() + self.output_path = common.MakeTempFile(suffix='.zip') + + def test_full(self): + target_info = common.LoadDictionaryFromLines(""" +dynamic_partition_list=system vendor +super_partition_groups=group_foo +super_group_foo_group_size={group_size} +super_group_foo_partition_list=system vendor +""".format(group_size=4 * GiB).split("\n")) + block_diffs = [MockBlockDifference("system", FakeSparseImage(3 * GiB)), + MockBlockDifference("vendor", FakeSparseImage(1 * GiB))] + + dp_diff = DynamicPartitionsDifference(target_info, block_diffs) + with zipfile.ZipFile(self.output_path, 'w', allowZip64=True) as output_zip: + dp_diff.WriteScript(self.script, output_zip, write_verify_script=True) + + self.assertEqual(str(self.script).strip(), """ +assert(update_dynamic_partitions(package_extract_file("dynamic_partitions_op_list"))); +patch(system); +verify(system); +unmap_partition("system"); +patch(vendor); +verify(vendor); +unmap_partition("vendor"); +""".strip()) + + lines = self.get_op_list(self.output_path) + + remove_all_groups = lines.index("remove_all_groups") + add_group = lines.index("add_group group_foo 4294967296") + add_vendor = lines.index("add vendor group_foo") + add_system = lines.index("add system group_foo") + resize_vendor = lines.index("resize vendor 1073741824") + resize_system = lines.index("resize system 3221225472") + + self.assertLess(remove_all_groups, add_group, + "Should add groups after removing all groups") + self.assertLess(add_group, min(add_vendor, add_system), + "Should add partitions after adding group") + self.assertLess(add_system, resize_system, + "Should resize system after adding it") + self.assertLess(add_vendor, resize_vendor, + "Should resize vendor after adding it") + + def test_inc_groups(self): + source_info = common.LoadDictionaryFromLines(""" +super_partition_groups=group_foo group_bar group_baz +super_group_foo_group_size={group_foo_size} +super_group_bar_group_size={group_bar_size} +""".format(group_foo_size=4 * GiB, group_bar_size=3 * GiB).split("\n")) + target_info = common.LoadDictionaryFromLines(""" +super_partition_groups=group_foo group_baz group_qux +super_group_foo_group_size={group_foo_size} +super_group_baz_group_size={group_baz_size} +super_group_qux_group_size={group_qux_size} +""".format(group_foo_size=3 * GiB, group_baz_size=4 * GiB, + group_qux_size=1 * GiB).split("\n")) + + dp_diff = DynamicPartitionsDifference(target_info, + block_diffs=[], + source_info_dict=source_info) + with zipfile.ZipFile(self.output_path, 'w', allowZip64=True) as output_zip: + dp_diff.WriteScript(self.script, output_zip, write_verify_script=True) + + lines = self.get_op_list(self.output_path) + + removed = lines.index("remove_group group_bar") + shrunk = lines.index("resize_group group_foo 3221225472") + grown = lines.index("resize_group group_baz 4294967296") + added = lines.index("add_group group_qux 1073741824") + + self.assertLess(max(removed, shrunk), + min(grown, added), + "ops that remove / shrink partitions must precede ops that " + "grow / add partitions") + + def test_incremental(self): + source_info = common.LoadDictionaryFromLines(""" +dynamic_partition_list=system vendor product system_ext +super_partition_groups=group_foo +super_group_foo_group_size={group_foo_size} +super_group_foo_partition_list=system vendor product system_ext +""".format(group_foo_size=4 * GiB).split("\n")) + target_info = common.LoadDictionaryFromLines(""" +dynamic_partition_list=system vendor product odm +super_partition_groups=group_foo group_bar +super_group_foo_group_size={group_foo_size} +super_group_foo_partition_list=system vendor odm +super_group_bar_group_size={group_bar_size} +super_group_bar_partition_list=product +""".format(group_foo_size=3 * GiB, group_bar_size=1 * GiB).split("\n")) + + block_diffs = [MockBlockDifference("system", FakeSparseImage(1536 * MiB), + src=FakeSparseImage(1024 * MiB)), + MockBlockDifference("vendor", FakeSparseImage(512 * MiB), + src=FakeSparseImage(1024 * MiB)), + MockBlockDifference("product", FakeSparseImage(1024 * MiB), + src=FakeSparseImage(1024 * MiB)), + MockBlockDifference("system_ext", None, + src=FakeSparseImage(1024 * MiB)), + MockBlockDifference("odm", FakeSparseImage(1024 * MiB), + src=None)] + + dp_diff = DynamicPartitionsDifference(target_info, block_diffs, + source_info_dict=source_info) + with zipfile.ZipFile(self.output_path, 'w', allowZip64=True) as output_zip: + dp_diff.WriteScript(self.script, output_zip, write_verify_script=True) + + metadata_idx = self.script.lines.index( + 'assert(update_dynamic_partitions(package_extract_file(' + '"dynamic_partitions_op_list")));') + self.assertLess(self.script.lines.index('patch(vendor);'), metadata_idx) + self.assertLess(metadata_idx, self.script.lines.index('verify(vendor);')) + for p in ("product", "system", "odm"): + patch_idx = self.script.lines.index("patch({});".format(p)) + verify_idx = self.script.lines.index("verify({});".format(p)) + self.assertLess(metadata_idx, patch_idx, + "Should patch {} after updating metadata".format(p)) + self.assertLess(patch_idx, verify_idx, + "Should verify {} after patching".format(p)) + + self.assertNotIn("patch(system_ext);", self.script.lines) + + lines = self.get_op_list(self.output_path) + + remove = lines.index("remove system_ext") + move_product_out = lines.index("move product default") + shrink = lines.index("resize vendor 536870912") + shrink_group = lines.index("resize_group group_foo 3221225472") + add_group_bar = lines.index("add_group group_bar 1073741824") + add_odm = lines.index("add odm group_foo") + grow_existing = lines.index("resize system 1610612736") + grow_added = lines.index("resize odm 1073741824") + move_product_in = lines.index("move product group_bar") + + max_idx_move_partition_out_foo = max(remove, move_product_out, shrink) + min_idx_move_partition_in_foo = min(add_odm, grow_existing, grow_added) + + self.assertLess(max_idx_move_partition_out_foo, shrink_group, + "Must shrink group after partitions inside group are shrunk" + " / removed") + + self.assertLess(add_group_bar, move_product_in, + "Must add partitions to group after group is added") + + self.assertLess(max_idx_move_partition_out_foo, + min_idx_move_partition_in_foo, + "Must shrink partitions / remove partitions from group" + "before adding / moving partitions into group") + + def test_remove_partition(self): + source_info = common.LoadDictionaryFromLines(""" +blockimgdiff_versions=3,4 +use_dynamic_partitions=true +dynamic_partition_list=foo +super_partition_groups=group_foo +super_group_foo_group_size={group_foo_size} +super_group_foo_partition_list=foo +""".format(group_foo_size=4 * GiB).split("\n")) + target_info = common.LoadDictionaryFromLines(""" +blockimgdiff_versions=3,4 +use_dynamic_partitions=true +super_partition_groups=group_foo +super_group_foo_group_size={group_foo_size} +""".format(group_foo_size=4 * GiB).split("\n")) + + common.OPTIONS.info_dict = target_info + common.OPTIONS.target_info_dict = target_info + common.OPTIONS.source_info_dict = source_info + common.OPTIONS.cache_size = 4 * 4096 + + block_diffs = [BlockDifference("foo", EmptyImage(), + src=DataImage("source", pad=True))] + + dp_diff = DynamicPartitionsDifference(target_info, block_diffs, + source_info_dict=source_info) + with zipfile.ZipFile(self.output_path, 'w', allowZip64=True) as output_zip: + dp_diff.WriteScript(self.script, output_zip, write_verify_script=True) + + self.assertNotIn("block_image_update", str(self.script), + "Removed partition should not be patched.") + + lines = self.get_op_list(self.output_path) + self.assertEqual(lines, ["remove foo"]) + + + +class InstallRecoveryScriptFormatTest(test_utils.ReleaseToolsTestCase): + """Checks the format of install-recovery.sh. + + Its format should match between common.py and validate_target_files.py. + """ + + def setUp(self): + self._tempdir = common.MakeTempDir() + # Create a fake dict that contains the fstab info for boot&recovery. + self._info = {"fstab": {}} + fake_fstab = [ + "/dev/soc.0/by-name/boot /boot emmc defaults defaults", + "/dev/soc.0/by-name/recovery /recovery emmc defaults defaults"] + self._info["fstab"] = common.LoadRecoveryFSTab("\n".join, 2, fake_fstab) + # Construct the gzipped recovery.img and boot.img + self.recovery_data = bytearray([ + 0x1f, 0x8b, 0x08, 0x00, 0x81, 0x11, 0x02, 0x5a, 0x00, 0x03, 0x2b, 0x4a, + 0x4d, 0xce, 0x2f, 0x4b, 0x2d, 0xaa, 0x04, 0x00, 0xc9, 0x93, 0x43, 0xf3, + 0x08, 0x00, 0x00, 0x00 + ]) + # echo -n "boot" | gzip -f | hd + self.boot_data = bytearray([ + 0x1f, 0x8b, 0x08, 0x00, 0x8c, 0x12, 0x02, 0x5a, 0x00, 0x03, 0x4b, 0xca, + 0xcf, 0x2f, 0x01, 0x00, 0xc4, 0xae, 0xed, 0x46, 0x04, 0x00, 0x00, 0x00 + ]) + + def _out_tmp_sink(self, name, data, prefix="SYSTEM"): + loc = os.path.join(self._tempdir, prefix, name) + if not os.path.exists(os.path.dirname(loc)): + os.makedirs(os.path.dirname(loc)) + with open(loc, "wb") as f: + f.write(data) + + def test_full_recovery(self): + recovery_image = common.File("recovery.img", self.recovery_data) + boot_image = common.File("boot.img", self.boot_data) + self._info["full_recovery_image"] = "true" + + MakeRecoveryPatch(self._tempdir, self._out_tmp_sink, + recovery_image, boot_image, self._info) + validate_target_files.ValidateInstallRecoveryScript(self._tempdir, + self._info) + + @test_utils.SkipIfExternalToolsUnavailable() + def test_recovery_from_boot(self): + recovery_image = common.File("recovery.img", self.recovery_data) + self._out_tmp_sink("recovery.img", recovery_image.data, "IMAGES") + boot_image = common.File("boot.img", self.boot_data) + self._out_tmp_sink("boot.img", boot_image.data, "IMAGES") + + MakeRecoveryPatch(self._tempdir, self._out_tmp_sink, + recovery_image, boot_image, self._info) + validate_target_files.ValidateInstallRecoveryScript(self._tempdir, + self._info) + # Validate 'recovery-from-boot' with bonus argument. + self._out_tmp_sink("etc/recovery-resource.dat", b"bonus", "SYSTEM") + MakeRecoveryPatch(self._tempdir, self._out_tmp_sink, + recovery_image, boot_image, self._info) + validate_target_files.ValidateInstallRecoveryScript(self._tempdir, + self._info) + From d9199eb8edd464ca056dc0a14e60dd79cd5a8103 Mon Sep 17 00:00:00 2001 From: Harshit Mahajan Date: Mon, 23 Oct 2023 20:23:14 +0000 Subject: [PATCH 65/85] Revert "[CrashRecovery] Add module to BCP and SSCP" Revert submission 24444827-crashrecovery Reason for revert: Since the module is not behind any flags, it is getting included in 24Q1 Beta release. Reverted changes: /q/submissionid:24444827-crashrecovery Bug: b/305826937 Change-Id: I39dfab62897d907023720b594d6929397403d314 --- target/product/base_system.mk | 1 - target/product/default_art_config.mk | 2 -- 2 files changed, 3 deletions(-) diff --git a/target/product/base_system.mk b/target/product/base_system.mk index a9d3f7656c..63f9f84554 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -53,7 +53,6 @@ PRODUCT_PACKAGES += \ com.android.btservices \ com.android.configinfrastructure \ com.android.conscrypt \ - com.android.crashrecovery \ com.android.devicelock \ com.android.extservices \ com.android.healthfitness \ diff --git a/target/product/default_art_config.mk b/target/product/default_art_config.mk index 78c45c1b47..3f2376dd4b 100644 --- a/target/product/default_art_config.mk +++ b/target/product/default_art_config.mk @@ -66,7 +66,6 @@ PRODUCT_APEX_BOOT_JARS := \ com.android.btservices:framework-bluetooth \ com.android.configinfrastructure:framework-configinfrastructure \ com.android.conscrypt:conscrypt \ - com.android.crashrecovery:framework-crashrecovery \ com.android.devicelock:framework-devicelock \ com.android.healthfitness:framework-healthfitness \ com.android.i18n:core-icu4j \ @@ -95,7 +94,6 @@ PRODUCT_APEX_SYSTEM_SERVER_JARS := \ com.android.appsearch:service-appsearch \ com.android.art:service-art \ com.android.configinfrastructure:service-configinfrastructure \ - com.android.crashrecovery:service-crashrecovery \ com.android.healthfitness:service-healthfitness \ com.android.media:service-media-s \ com.android.ondevicepersonalization:service-ondevicepersonalization \ From 0fee92dc93aaf84d3dcea22d2ed903231da2751d Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Fri, 20 Oct 2023 10:39:06 -0700 Subject: [PATCH 66/85] Add ravenwood test config template Modeled after robolectric_test_config_template.xml Bug: 292141694 Test: m nothing --no-skip-soong-tests Test: m hoststubgen ravenwood-runtime tradefed atest && atest-dev HostStubGenTest-framework-test Change-Id: I9ef906074df65c93d9e1a4b4998e6137196075ed --- core/ravenwood_test_config_template.xml | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 core/ravenwood_test_config_template.xml diff --git a/core/ravenwood_test_config_template.xml b/core/ravenwood_test_config_template.xml new file mode 100644 index 0000000000..b9002687b1 --- /dev/null +++ b/core/ravenwood_test_config_template.xml @@ -0,0 +1,40 @@ + + + + + From 51dc3e7a205652c99c6d022f6fabb8b31b11d29b Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Sat, 4 Nov 2023 14:58:26 +0000 Subject: [PATCH 67/85] Revert "handheld_system: Replace NFC app with NFC apex" Revert submission 24993894-cherrypicker-L80100000963393177:N49200001411943056 Reason for revert: Causing bootloop with signed builds Reverted changes: /q/submissionid:24993894-cherrypicker-L80100000963393177:N49200001411943056 Bug: 309117462 Change-Id: Ic35189ae47f3e2b4302d09cbb524f7c8e6ddc2d6 Test: Compiles, device boots up --- target/product/handheld_system.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/product/handheld_system.mk b/target/product/handheld_system.mk index b2064fa0e3..d5c2a87c07 100644 --- a/target/product/handheld_system.mk +++ b/target/product/handheld_system.mk @@ -40,7 +40,6 @@ PRODUCT_PACKAGES += \ BuiltInPrintService \ CalendarProvider \ cameraserver \ - com.android.nfcservices \ CameraExtensionsProxy \ CaptivePortalLogin \ CertInstaller \ @@ -58,6 +57,7 @@ PRODUCT_PACKAGES += \ MmsService \ MtpService \ MusicFX \ + NfcNci \ PacProcessor \ preinstalled-packages-platform-handheld-system.xml \ PrintRecommendationService \ From df633571e8a9b78fa7808e2dd922f0dc4adf38af Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Tue, 7 Nov 2023 01:14:47 +0000 Subject: [PATCH 68/85] Trunk Stable finalization. Ignore-AOSP-First: local first Bug: 304316873 Test: build/make/tools/finalization/build-step-1.sh Change-Id: I17319cbf9abeaadcbd3c26998c541e7aa400e4fb --- .../finalize-aidl-vndk-sdk-resources.sh | 52 +++++++++++++------ 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/tools/finalization/finalize-aidl-vndk-sdk-resources.sh b/tools/finalization/finalize-aidl-vndk-sdk-resources.sh index 6d13325ee1..dac3a0cbc8 100755 --- a/tools/finalization/finalize-aidl-vndk-sdk-resources.sh +++ b/tools/finalization/finalize-aidl-vndk-sdk-resources.sh @@ -69,6 +69,33 @@ inline bool IsAtLeast${FINAL_PLATFORM_CODENAME:0:1}() { return android_get_devic rm "$tmpfile" } +function bumpSdkExtensionsVersion() { + local SDKEXT="packages/modules/SdkExtensions/" + + # This used to call bump_sdk.sh utility. + # However due to TS, we have to build the gen_sdk with a correct set of settings. + + # "$top/packages/modules/SdkExtensions/gen_sdk/bump_sdk.sh" ${FINAL_MAINLINE_EXTENSION} + # Leave the last commit as a set of modified files. + # The code to create a finalization topic will pick it up later. + # git -C ${SDKEXT} reset HEAD~1 + + local sdk="${FINAL_MAINLINE_EXTENSION}" + local modules_arg= + + TARGET_PRODUCT=aosp_arm64 \ + TARGET_RELEASE=fina_1 \ + TARGET_BUILD_VARIANT=userdebug \ + DIST_DIR=out/dist \ + $top/build/soong/soong_ui.bash --make-mode --soong-only gen_sdk + + ANDROID_BUILD_TOP="$top" out/soong/host/linux-x86/bin/gen_sdk \ + --database ${SDKEXT}/gen_sdk/extensions_db.textpb \ + --action new_sdk \ + --sdk "$sdk" \ + $modules_arg +} + function finalize_aidl_vndk_sdk_resources() { local top="$(dirname "$0")"/../../../.. source $top/build/make/tools/finalization/environment.sh @@ -76,8 +103,8 @@ function finalize_aidl_vndk_sdk_resources() { local SDK_CODENAME="public static final int $FINAL_PLATFORM_CODENAME_JAVA = CUR_DEVELOPMENT;" local SDK_VERSION="public static final int $FINAL_PLATFORM_CODENAME_JAVA = $FINAL_PLATFORM_SDK_VERSION;" - # default target to modify tree and build SDK - local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug DIST_DIR=out/dist" + # target to modify tree and build VNDK + local vndk_m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug DIST_DIR=out/dist" # The full process can be found at (INTERNAL) go/android-sdk-finalization. @@ -91,14 +118,14 @@ function finalize_aidl_vndk_sdk_resources() { cp "$top/development/vndk/tools/definition-tool/datasets/vndk-lib-extra-list-current.txt" \ "$top/development/vndk/tools/definition-tool/datasets/vndk-lib-extra-list-$FINAL_PLATFORM_SDK_VERSION.txt" - AIDL_TRANSITIVE_FREEZE=true $m aidl-freeze-api create_reference_dumps + AIDL_TRANSITIVE_FREEZE=true $vndk_m aidl-freeze-api create_reference_dumps # Generate ABI dumps ANDROID_BUILD_TOP="$top" out/host/linux-x86/bin/create_reference_dumps echo "NOTE: THIS INTENTIONALLY MAY FAIL AND REPAIR ITSELF (until 'DONE')" # Update new versions of files. See update-vndk-list.sh (which requires envsetup.sh) - $m check-vndk-list || \ + $vndk_m check-vndk-list || \ { cp $top/out/soong/vndk/vndk.libraries.txt $top/build/make/target/product/gsi/current.txt; } echo "DONE: THIS INTENTIONALLY MAY FAIL AND REPAIR ITSELF" @@ -114,9 +141,6 @@ function finalize_aidl_vndk_sdk_resources() { sed -i -e 's/Pkg\.Revision.*/Pkg\.Revision=${PLATFORM_SDK_VERSION}.0.0/g' $build_tools_source # build/make - local version_defaults="$top/build/make/core/version_defaults.mk" - sed -i -e "s/PLATFORM_SDK_VERSION := .*/PLATFORM_SDK_VERSION := ${FINAL_PLATFORM_SDK_VERSION}/g" $version_defaults - sed -i -e "s/PLATFORM_VERSION_LAST_STABLE := .*/PLATFORM_VERSION_LAST_STABLE := ${FINAL_PLATFORM_VERSION}/g" $version_defaults sed -i -e "s/sepolicy_major_vers := .*/sepolicy_major_vers := ${FINAL_PLATFORM_SDK_VERSION}/g" "$top/build/make/core/config.mk" cp "$top/build/make/target/product/gsi/current.txt" "$top/build/make/target/product/gsi/$FINAL_PLATFORM_SDK_VERSION.txt" @@ -149,18 +173,14 @@ function finalize_aidl_vndk_sdk_resources() { sed -i -e "/=.*$((${FINAL_PLATFORM_SDK_VERSION}-1)),/a \\ SDK_${FINAL_PLATFORM_CODENAME_JAVA} = ${FINAL_PLATFORM_SDK_VERSION}," "$top/frameworks/base/tools/aapt2/SdkConstants.h" # Bump Mainline SDK extension version. - local SDKEXT="packages/modules/SdkExtensions/" - "$top/packages/modules/SdkExtensions/gen_sdk/bump_sdk.sh" ${FINAL_MAINLINE_EXTENSION} - # Leave the last commit as a set of modified files. - # The code to create a finalization topic will pick it up later. - git -C ${SDKEXT} reset HEAD~1 + bumpSdkExtensionsVersion - local version_defaults="$top/build/make/core/version_defaults.mk" - sed -i -e "s/PLATFORM_SDK_EXTENSION_VERSION := .*/PLATFORM_SDK_EXTENSION_VERSION := ${FINAL_MAINLINE_EXTENSION}/g" $version_defaults + # target to build SDK + local sdk_m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_RELEASE=fina_1 TARGET_BUILD_VARIANT=userdebug DIST_DIR=out/dist" # Force update current.txt - $m clobber - $m update-api + $sdk_m clobber + $sdk_m update-api } finalize_aidl_vndk_sdk_resources From 44dffc0914fa4c0e692f67bc824ecf1571597f54 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Tue, 7 Nov 2023 20:51:58 -0800 Subject: [PATCH 69/85] Rename bzl files to scl These files don't have anything to do with bazel, they just use starlark as a configuration language. Bazel recently introduced the scl file extension to use for this format, which doesn't have any bazel-specific symbols. Use that extension for our pure starlark files as well. Bug: 309686282 Test: Presubmits Change-Id: I04719332ca781f98a459b0038df37029efcbd8b1 --- core/release_config.bzl | 225 +--------------------------------------- core/release_config.mk | 10 -- core/release_config.scl | 224 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 225 insertions(+), 234 deletions(-) mode change 100644 => 120000 core/release_config.bzl create mode 100644 core/release_config.scl diff --git a/core/release_config.bzl b/core/release_config.bzl deleted file mode 100644 index a29f3f2869..0000000000 --- a/core/release_config.bzl +++ /dev/null @@ -1,224 +0,0 @@ -# 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -""" -Export build flags (with values) to make. -""" - -load("//build/bazel/utils:schema_validation.bzl", "validate") - -# Partitions that get build system flag summaries -_flag_partitions = [ - "product", - "system", - "system_ext", - "vendor", -] - -ALL = ["all"] -PRODUCT = ["product"] -SYSTEM = ["system"] -SYSTEM_EXT = ["system_ext"] -VENDOR = ["vendor"] - -_valid_types = ["NoneType", "bool", "list", "string", "int"] - -_all_flags_schema = { - "type": "list", - "of": { - "type": "dict", - "required_keys": { - "name": {"type": "string"}, - "partitions": { - "type": "list", - "of": { - "type": "string", - "choices": _flag_partitions + ["all"], - }, - "unique": True, - }, - "default": { - "or": [ - {"type": t} - for t in _valid_types - ], - }, - "declared_in": {"type": "string"}, - }, - "optional_keys": { - "appends": { - "type": "bool", - }, - }, - }, -} - -_all_values_schema = { - "type": "list", - "of": { - "type": "dict", - "required_keys": { - "name": {"type": "string"}, - "value": { - "or": [ - {"type": t} - for t in _valid_types - ], - }, - "set_in": {"type": "string"}, - }, - }, -} - -def flag(name, partitions, default, _kwmarker = (), appends = False): - """Declare a flag. - - Args: - name: name of the flag - partitions: the partitions where this should be recorded. - default: the default value of the flag. - _kwmarker: Used to detect argument misuse. - appends: Whether new values should be append (not replace) the old. - - Returns: - A dictionary containing the flag declaration. - """ - - # If specified, appends must be a keyword value. - if _kwmarker != (): - fail("Too many positional parameters") - if not partitions: - fail("At least 1 partition is required") - if not name.startswith("RELEASE_"): - fail("Release flag names must start with RELEASE_") - if " " in name or "\t" in name or "\n" in name: - fail("Flag names must not contain whitespace: \"" + name + "\"") - for partition in partitions: - if partition == "all": - if len(partitions) > 1: - fail("\"all\" can't be combined with other partitions: " + str(partitions)) - elif partition not in _flag_partitions: - fail("Invalid partition: " + partition + ", allowed partitions: " + - str(_flag_partitions)) - if type(default) not in _valid_types: - fail("Invalid type of default for flag \"" + name + "\" (" + type(default) + ")") - return { - "name": name, - "partitions": partitions, - "default": default, - "appends": appends, - } - -def value(name, value): - """Define the flag value for a particular configuration. - - Args: - name: The name of the flag. - value: The value for the flag. - - Returns: - A dictionary containing the name and value to be used. - """ - return { - "name": name, - "value": value, - } - -def _format_value(val): - """Format the starlark type correctly for make. - - Args: - val: The value to format - - Returns: - The value, formatted correctly for make. - """ - if type(val) == "NoneType": - return "" - elif type(val) == "bool": - return "true" if val else "" - else: - return val - -def release_config(all_flags, all_values): - """Return the make variables that should be set for this release config. - - Args: - all_flags: A list of flag objects (from flag() calls). - all_values: A list of value objects (from value() calls). - - Returns: - A dictionary of {name: value} variables for make. - """ - validate(all_flags, _all_flags_schema) - validate(all_values, _all_values_schema) - - # Validate flags - flag_names = [] - flags_dict = {} - for flag in all_flags: - if flag["name"] in flag_names: - fail(flag["declared_in"] + ": Duplicate declaration of flag " + flag["name"]) - flag_names.append(flag["name"]) - flags_dict[flag["name"]] = flag - - # Record which flags go on which partition - partitions = {} - for flag in all_flags: - for partition in flag["partitions"]: - if partition == "all": - if len(flag["partitions"]) > 1: - fail("\"all\" can't be combined with other partitions: " + str(flag["partitions"])) - for partition in _flag_partitions: - partitions.setdefault(partition, []).append(flag["name"]) - else: - partitions.setdefault(partition, []).append(flag["name"]) - - # Generate final values. - # Only declared flags may have a value. - values = {} - for value in all_values: - name = value["name"] - if name not in flag_names: - fail(value["set_in"] + ": Value set for undeclared build flag: " + name) - if flags_dict[name]["appends"]: - if name in values: - values[name]["value"] += " " + value["value"] - values[name]["set_in"] += " " + value["set_in"] - else: - values[name] = value - else: - values[name] = value - - # Collect values - result = { - "_ALL_RELEASE_FLAGS": sorted(flag_names), - } - for partition, names in partitions.items(): - result["_ALL_RELEASE_FLAGS.PARTITIONS." + partition] = names - for flag in all_flags: - if flag["name"] in values: - val = values[flag["name"]]["value"] - set_in = values[flag["name"]]["set_in"] - else: - val = flag["default"] - set_in = flag["declared_in"] - val = _format_value(val) - result[flag["name"]] = val - result["_ALL_RELEASE_FLAGS." + flag["name"] + ".PARTITIONS"] = flag["partitions"] - result["_ALL_RELEASE_FLAGS." + flag["name"] + ".DEFAULT"] = _format_value(flag["default"]) - result["_ALL_RELEASE_FLAGS." + flag["name"] + ".VALUE"] = val - result["_ALL_RELEASE_FLAGS." + flag["name"] + ".DECLARED_IN"] = flag["declared_in"] - result["_ALL_RELEASE_FLAGS." + flag["name"] + ".SET_IN"] = set_in - - return result diff --git a/core/release_config.bzl b/core/release_config.bzl new file mode 120000 index 0000000000..ffb70a3a3d --- /dev/null +++ b/core/release_config.bzl @@ -0,0 +1 @@ +release_config.scl \ No newline at end of file diff --git a/core/release_config.mk b/core/release_config.mk index 5993e85b51..e1e0726057 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -82,16 +82,6 @@ $(foreach f, $(config_map_files), \ ) FLAG_DECLARATION_FILES := -# Make sure that the flag definitions are included for vendor/google builds. -# This decouples the change in vendor/google/release/release_config_map.mk -# from this logic change. -# TODO: Remove this once the vendor/google FLAG_DECLARATION_FILES change is there. -$(if $(wildcard vendor/google/release/release_config_map.mk),\ - $(if $(filter vendor/google/release/build_flags.bzl,$(_flag_declaration_files)),,\ - $(eval _flag_declaration_files := vendor/google/release/build_flags.bzl $(_flag_declaration_files)) \ - ) \ -) - # If TARGET_RELEASE is set, fail if there is no matching release config # If it isn't set, no release config files will be included and all flags # will get their default values. diff --git a/core/release_config.scl b/core/release_config.scl new file mode 100644 index 0000000000..101f119709 --- /dev/null +++ b/core/release_config.scl @@ -0,0 +1,224 @@ +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Export build flags (with values) to make. +""" + +load("//build/bazel/utils:schema_validation.scl", "validate") + +# Partitions that get build system flag summaries +_flag_partitions = [ + "product", + "system", + "system_ext", + "vendor", +] + +ALL = ["all"] +PRODUCT = ["product"] +SYSTEM = ["system"] +SYSTEM_EXT = ["system_ext"] +VENDOR = ["vendor"] + +_valid_types = ["NoneType", "bool", "list", "string", "int"] + +_all_flags_schema = { + "type": "list", + "of": { + "type": "dict", + "required_keys": { + "name": {"type": "string"}, + "partitions": { + "type": "list", + "of": { + "type": "string", + "choices": _flag_partitions + ["all"], + }, + "unique": True, + }, + "default": { + "or": [ + {"type": t} + for t in _valid_types + ], + }, + "declared_in": {"type": "string"}, + }, + "optional_keys": { + "appends": { + "type": "bool", + }, + }, + }, +} + +_all_values_schema = { + "type": "list", + "of": { + "type": "dict", + "required_keys": { + "name": {"type": "string"}, + "value": { + "or": [ + {"type": t} + for t in _valid_types + ], + }, + "set_in": {"type": "string"}, + }, + }, +} + +def flag(name, partitions, default, _kwmarker = (), appends = False): + """Declare a flag. + + Args: + name: name of the flag + partitions: the partitions where this should be recorded. + default: the default value of the flag. + _kwmarker: Used to detect argument misuse. + appends: Whether new values should be append (not replace) the old. + + Returns: + A dictionary containing the flag declaration. + """ + + # If specified, appends must be a keyword value. + if _kwmarker != (): + fail("Too many positional parameters") + if not partitions: + fail("At least 1 partition is required") + if not name.startswith("RELEASE_"): + fail("Release flag names must start with RELEASE_") + if " " in name or "\t" in name or "\n" in name: + fail("Flag names must not contain whitespace: \"" + name + "\"") + for partition in partitions: + if partition == "all": + if len(partitions) > 1: + fail("\"all\" can't be combined with other partitions: " + str(partitions)) + elif partition not in _flag_partitions: + fail("Invalid partition: " + partition + ", allowed partitions: " + + str(_flag_partitions)) + if type(default) not in _valid_types: + fail("Invalid type of default for flag \"" + name + "\" (" + type(default) + ")") + return { + "name": name, + "partitions": partitions, + "default": default, + "appends": appends, + } + +def value(name, value): + """Define the flag value for a particular configuration. + + Args: + name: The name of the flag. + value: The value for the flag. + + Returns: + A dictionary containing the name and value to be used. + """ + return { + "name": name, + "value": value, + } + +def _format_value(val): + """Format the starlark type correctly for make. + + Args: + val: The value to format + + Returns: + The value, formatted correctly for make. + """ + if type(val) == "NoneType": + return "" + elif type(val) == "bool": + return "true" if val else "" + else: + return val + +def release_config(all_flags, all_values): + """Return the make variables that should be set for this release config. + + Args: + all_flags: A list of flag objects (from flag() calls). + all_values: A list of value objects (from value() calls). + + Returns: + A dictionary of {name: value} variables for make. + """ + validate(all_flags, _all_flags_schema) + validate(all_values, _all_values_schema) + + # Validate flags + flag_names = [] + flags_dict = {} + for flag in all_flags: + if flag["name"] in flag_names: + fail(flag["declared_in"] + ": Duplicate declaration of flag " + flag["name"]) + flag_names.append(flag["name"]) + flags_dict[flag["name"]] = flag + + # Record which flags go on which partition + partitions = {} + for flag in all_flags: + for partition in flag["partitions"]: + if partition == "all": + if len(flag["partitions"]) > 1: + fail("\"all\" can't be combined with other partitions: " + str(flag["partitions"])) + for partition in _flag_partitions: + partitions.setdefault(partition, []).append(flag["name"]) + else: + partitions.setdefault(partition, []).append(flag["name"]) + + # Generate final values. + # Only declared flags may have a value. + values = {} + for value in all_values: + name = value["name"] + if name not in flag_names: + fail(value["set_in"] + ": Value set for undeclared build flag: " + name) + if flags_dict[name]["appends"]: + if name in values: + values[name]["value"] += " " + value["value"] + values[name]["set_in"] += " " + value["set_in"] + else: + values[name] = value + else: + values[name] = value + + # Collect values + result = { + "_ALL_RELEASE_FLAGS": sorted(flag_names), + } + for partition, names in partitions.items(): + result["_ALL_RELEASE_FLAGS.PARTITIONS." + partition] = names + for flag in all_flags: + if flag["name"] in values: + val = values[flag["name"]]["value"] + set_in = values[flag["name"]]["set_in"] + else: + val = flag["default"] + set_in = flag["declared_in"] + val = _format_value(val) + result[flag["name"]] = val + result["_ALL_RELEASE_FLAGS." + flag["name"] + ".PARTITIONS"] = flag["partitions"] + result["_ALL_RELEASE_FLAGS." + flag["name"] + ".DEFAULT"] = _format_value(flag["default"]) + result["_ALL_RELEASE_FLAGS." + flag["name"] + ".VALUE"] = val + result["_ALL_RELEASE_FLAGS." + flag["name"] + ".DECLARED_IN"] = flag["declared_in"] + result["_ALL_RELEASE_FLAGS." + flag["name"] + ".SET_IN"] = set_in + + return result From b1f263c5f8ea8ef5d0380800a162bc4a00364ab1 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Wed, 8 Nov 2023 19:26:25 +0000 Subject: [PATCH 70/85] Finalization for TS: VNDK cleanup. - explicitly specify release config for internal builds (trunk), - remove unnecessary VNDK steps. Ignore-AOSP-First: local first Bug: 304316873 Test: build/make/tools/finalization/build-step-1.sh Change-Id: I709f09b6ca9ce3c30541ab88815761d8688b538c --- .../finalize-aidl-vndk-sdk-resources.sh | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/tools/finalization/finalize-aidl-vndk-sdk-resources.sh b/tools/finalization/finalize-aidl-vndk-sdk-resources.sh index dac3a0cbc8..2a73ea1d1a 100755 --- a/tools/finalization/finalize-aidl-vndk-sdk-resources.sh +++ b/tools/finalization/finalize-aidl-vndk-sdk-resources.sh @@ -103,9 +103,6 @@ function finalize_aidl_vndk_sdk_resources() { local SDK_CODENAME="public static final int $FINAL_PLATFORM_CODENAME_JAVA = CUR_DEVELOPMENT;" local SDK_VERSION="public static final int $FINAL_PLATFORM_CODENAME_JAVA = $FINAL_PLATFORM_SDK_VERSION;" - # target to modify tree and build VNDK - local vndk_m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug DIST_DIR=out/dist" - # The full process can be found at (INTERNAL) go/android-sdk-finalization. # apply droidstubs hack to prevent tools from incrementing an API version @@ -114,20 +111,9 @@ function finalize_aidl_vndk_sdk_resources() { # bionic/NDK finalize_bionic_ndk - # VNDK definitions for new SDK version - cp "$top/development/vndk/tools/definition-tool/datasets/vndk-lib-extra-list-current.txt" \ - "$top/development/vndk/tools/definition-tool/datasets/vndk-lib-extra-list-$FINAL_PLATFORM_SDK_VERSION.txt" - - AIDL_TRANSITIVE_FREEZE=true $vndk_m aidl-freeze-api create_reference_dumps - - # Generate ABI dumps - ANDROID_BUILD_TOP="$top" out/host/linux-x86/bin/create_reference_dumps - - echo "NOTE: THIS INTENTIONALLY MAY FAIL AND REPAIR ITSELF (until 'DONE')" - # Update new versions of files. See update-vndk-list.sh (which requires envsetup.sh) - $vndk_m check-vndk-list || \ - { cp $top/out/soong/vndk/vndk.libraries.txt $top/build/make/target/product/gsi/current.txt; } - echo "DONE: THIS INTENTIONALLY MAY FAIL AND REPAIR ITSELF" + # pre-finalization build target (trunk) + local aidl_m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_RELEASE=trunk TARGET_BUILD_VARIANT=userdebug DIST_DIR=out/dist" + AIDL_TRANSITIVE_FREEZE=true $aidl_m aidl-freeze-api # Finalize SDK From 3fa5db0c0802849f47db5cb8609882783675ef8d Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Thu, 9 Nov 2023 01:18:03 +0000 Subject: [PATCH 71/85] Finalization for Trunk Stable, REL. Ignore-AOSP-First: local first Bug: 304316873 Test: build/make/tools/finalization/build-step-1-and-2.sh Change-Id: I6d5c6d58cad755f44766a77583dfbbd7d612fed4 --- .../finalize-aidl-vndk-sdk-resources.sh | 3 +++ tools/finalization/finalize-sdk-rel.sh | 19 ++++++++----------- tools/finalization/localonly-steps.sh | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/finalization/finalize-aidl-vndk-sdk-resources.sh b/tools/finalization/finalize-aidl-vndk-sdk-resources.sh index 2a73ea1d1a..1667ed4683 100755 --- a/tools/finalization/finalize-aidl-vndk-sdk-resources.sh +++ b/tools/finalization/finalize-aidl-vndk-sdk-resources.sh @@ -115,6 +115,9 @@ function finalize_aidl_vndk_sdk_resources() { local aidl_m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_RELEASE=trunk TARGET_BUILD_VARIANT=userdebug DIST_DIR=out/dist" AIDL_TRANSITIVE_FREEZE=true $aidl_m aidl-freeze-api + # TODO(b/309880485) + # Add back create_reference_dumps and $top/build/make/target/product/gsi/current.txt + # Finalize SDK # frameworks/libs/modules-utils diff --git a/tools/finalization/finalize-sdk-rel.sh b/tools/finalization/finalize-sdk-rel.sh index d4ed3805a6..245305bfad 100755 --- a/tools/finalization/finalize-sdk-rel.sh +++ b/tools/finalization/finalize-sdk-rel.sh @@ -33,10 +33,6 @@ function finalize_sdk_rel() { # in REL mode, resources would correctly set the resources_sdk_int, no fix required revert_resources_sdk_int_fix - # build/make/core/version_defaults.mk - # Mark all versions "released". - sed -i 's/\(PLATFORM_VERSION_CODENAME\.[^[:space:]]*\) := [^[:space:]]*/\1 := REL/g' "$top/build/make/core/version_defaults.mk" - # cts echo "$FINAL_PLATFORM_VERSION" > "$top/cts/tests/tests/os/assets/platform_versions.txt" if [ "$FINAL_PLATFORM_CODENAME" != "$CURRENT_PLATFORM_CODENAME" ]; then @@ -47,18 +43,19 @@ function finalize_sdk_rel() { # system/sepolicy system/sepolicy/tools/finalize-sdk-rel.sh "$top" "$FINAL_PLATFORM_SDK_VERSION" - # prebuilts/abi-dumps/ndk - mkdir -p "$top/prebuilts/abi-dumps/ndk/$FINAL_PLATFORM_SDK_VERSION" - cp -r "$top/prebuilts/abi-dumps/ndk/current/64/" "$top/prebuilts/abi-dumps/ndk/$FINAL_PLATFORM_SDK_VERSION/" - # prebuilts/abi-dumps/platform mkdir -p "$top/prebuilts/abi-dumps/platform/$FINAL_PLATFORM_SDK_VERSION" cp -r "$top/prebuilts/abi-dumps/platform/current/64/" "$top/prebuilts/abi-dumps/platform/$FINAL_PLATFORM_SDK_VERSION/" - if [ "$FINAL_STATE" != "sdk" ] || [ "$FINAL_PLATFORM_CODENAME" == "$CURRENT_PLATFORM_CODENAME" ] ; then + # TODO(b/309880485) + # uncomment and update + # prebuilts/abi-dumps/ndk + #mkdir -p "$top/prebuilts/abi-dumps/ndk/$FINAL_PLATFORM_SDK_VERSION" + #cp -r "$top/prebuilts/abi-dumps/ndk/current/64/" "$top/prebuilts/abi-dumps/ndk/$FINAL_PLATFORM_SDK_VERSION/" + #if [ "$FINAL_STATE" != "sdk" ] || [ "$FINAL_PLATFORM_CODENAME" == "$CURRENT_PLATFORM_CODENAME" ] ; then # prebuilts/abi-dumps/vndk - mv "$top/prebuilts/abi-dumps/vndk/$CURRENT_PLATFORM_CODENAME" "$top/prebuilts/abi-dumps/vndk/$FINAL_PLATFORM_SDK_VERSION" - fi; + #mv "$top/prebuilts/abi-dumps/vndk/$CURRENT_PLATFORM_CODENAME" "$top/prebuilts/abi-dumps/vndk/$FINAL_PLATFORM_SDK_VERSION" + #fi; } finalize_sdk_rel diff --git a/tools/finalization/localonly-steps.sh b/tools/finalization/localonly-steps.sh index 7318ca1013..bebd563bea 100755 --- a/tools/finalization/localonly-steps.sh +++ b/tools/finalization/localonly-steps.sh @@ -7,17 +7,17 @@ function finalize_locally() { source $top/build/make/tools/finalization/environment.sh # default target to modify tree and build SDK - local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug DIST_DIR=out/dist" + local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_RELEASE=fina_1 TARGET_BUILD_VARIANT=userdebug DIST_DIR=out/dist" # adb keys $m adb LOGNAME=android-eng HOSTNAME=google.com "$top/out/host/linux-x86/bin/adb" keygen "$top/vendor/google/security/adb/${FINAL_PLATFORM_VERSION}.adb_key" # Build Platform SDKs. - $top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=sdk TARGET_BUILD_VARIANT=userdebug sdk dist sdk_repo DIST_DIR=out/dist + $top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=sdk TARGET_RELEASE=fina_1 TARGET_BUILD_VARIANT=userdebug sdk dist sdk_repo DIST_DIR=out/dist # Build Modules SDKs. - TARGET_BUILD_VARIANT=userdebug UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true DIST_DIR=out/dist "$top/vendor/google/build/mainline_modules_sdks.sh" --build-release=latest + TARGET_RELEASE=fina_1 TARGET_BUILD_VARIANT=userdebug UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true DIST_DIR=out/dist "$top/vendor/google/build/mainline_modules_sdks.sh" --build-release=latest # Update prebuilts. "$top/prebuilts/build-tools/path/linux-x86/python3" -W ignore::DeprecationWarning "$top/prebuilts/sdk/update_prebuilts.py" --local_mode -f ${FINAL_PLATFORM_SDK_VERSION} -e ${FINAL_MAINLINE_EXTENSION} --bug 1 1 From 987ae3d2ec3f051f7f06ddff058a393254e163a9 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Mon, 13 Nov 2023 14:02:13 -0700 Subject: [PATCH 72/85] Update XML template to reflect null device. Ravenwood doesn't need a device, so add a "null" filter so that atest doesn't hang waiting for one. Bug: 292141694 Test: atest-dev CtsOsTestCasesRavenwood CtsOsTestCases Change-Id: I10ceeae92c7622ea44ecbc315e23babe8b36516a --- core/ravenwood_test_config_template.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/core/ravenwood_test_config_template.xml b/core/ravenwood_test_config_template.xml index b9002687b1..0cae135e6a 100644 --- a/core/ravenwood_test_config_template.xml +++ b/core/ravenwood_test_config_template.xml @@ -22,6 +22,7 @@