From 7f2661f46717bd6b3c8ed20168caf03d71bbabb0 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Thu, 29 Feb 2024 19:12:03 +0000 Subject: [PATCH 01/65] Allowlist for platform signed package/sharedUid-s. Fixes: 308573259 Test: atest android.content.pm.cts.PackageManagerTest Ignore-AOSP-First: file is added in internal branch Change-Id: I02e87e92878770cf21fb5032efb75eb1b222c62f --- 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 e9e32a3450..5969cc884d 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -238,6 +238,7 @@ PRODUCT_PACKAGES += \ org.apache.http.legacy \ otacerts \ PackageInstaller \ + package-shareduid-allowlist.xml \ passwd_system \ perfetto \ ping \ From 2f65ecf1af1ea32aa24bf2e2c551048f2a5fc038 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Sat, 18 Nov 2023 16:54:11 +0800 Subject: [PATCH 02/65] Add window_extensions to all builds Activity Embedding module will be guarded by targetSDK to reduce the app compat impact. Bug: 306666082 Ignore-AOSP-First: need internal-first change to guard with flag Test: m Change-Id: I07e139d9ce60cb4f5e91d33d633cfe89563ba283 --- target/product/base_system_ext.mk | 3 +++ target/product/window_extensions.mk | 17 +++++++----- target/product/window_extensions_base.mk | 34 ++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 target/product/window_extensions_base.mk diff --git a/target/product/base_system_ext.mk b/target/product/base_system_ext.mk index 76f008f323..f0e6ec90c5 100644 --- a/target/product/base_system_ext.mk +++ b/target/product/base_system_ext.mk @@ -28,3 +28,6 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES_SHIPPING_API_LEVEL_34 += \ hwservicemanager \ android.hidl.allocator@1.0-service \ + +# Window Extensions +$(call inherit-product, $(SRC_TARGET_DIR)/product/window_extensions_base.mk) diff --git a/target/product/window_extensions.mk b/target/product/window_extensions.mk index 5f5431f677..d27a613a61 100644 --- a/target/product/window_extensions.mk +++ b/target/product/window_extensions.mk @@ -14,11 +14,14 @@ # limitations under the License. # -# /system_ext packages -PRODUCT_PACKAGES += \ - androidx.window.extensions \ - androidx.window.sidecar - -# properties +# Extension of window_extensions_base.mk to enable the activity embedding +# feature for all apps by default. All large screen devices must inherit +# this in build. Optional for other form factors. +# +# Indicated whether the Activity Embedding feature should be guarded by +# Android 15 to avoid app compat impact. +# If true (or not set), the feature is only enabled for apps with target +# SDK of Android 15 or above. +# If false, the feature is enabled for all apps. PRODUCT_PRODUCT_PROPERTIES += \ - persist.wm.extensions.enabled=true + persist.wm.extensions.activity_embedding_guard_with_android_15=false diff --git a/target/product/window_extensions_base.mk b/target/product/window_extensions_base.mk new file mode 100644 index 0000000000..07ed5e3043 --- /dev/null +++ b/target/product/window_extensions_base.mk @@ -0,0 +1,34 @@ +# +# Copyright (C) 2024 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. +# + +# The base version of window_extensions.mk to be included on all devices. +# Devices that don't support multi-window can choose to drop this. +# TODO(b/326009200): Remove from build that doesn't support multi-window. +# +# Note: by default the Activity Embedding feature is guarded by app's +# targetSDK on Android 15 to avoid app compat impact. +# +# Large screen devices must inherit window_extensions.mk to enable the +# Activity Embedding feature for all apps. + +# /system_ext packages +PRODUCT_PACKAGES += \ + androidx.window.extensions \ + androidx.window.sidecar + +# properties +PRODUCT_PRODUCT_PROPERTIES += \ + persist.wm.extensions.enabled=true From 2f2d445822b7e17dd2c598788e6e0691c793b29f Mon Sep 17 00:00:00 2001 From: Masha Khokhlova Date: Mon, 4 Mar 2024 19:29:32 +0000 Subject: [PATCH 03/65] Bump SDK Extension version to 12 This bump includes Adservices, HealthFitness, Mediaprovider, Tethering, Extservices, OnDevicePersonalization Bug: b/327320298 Test: The build passes Ignore-AOSP-first: Finalization is not performed in AOSP Change-Id: Ia5757052abe48361d03b07125ef70fc329293389 Merged-In: I2f2b6b66262eefe2f0b0821773fda4cc07526d7b --- 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 6c395d1b44..caf4eb2f9a 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 := 11 +PLATFORM_SDK_EXTENSION_VERSION := 12 .KATI_READONLY := PLATFORM_SDK_EXTENSION_VERSION # This is the sdk extension version that PLATFORM_SDK_VERSION ships with. From e0e2f75fc20fe4b070c14cb69bd9492d8b4dcb59 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Wed, 6 Mar 2024 20:49:57 +0000 Subject: [PATCH 04/65] Prepare for V finalization. Bug: 323940469 Test: run locally Ignore-AOSP-First: local first Change-Id: Ie394523f7ea67a5475ad1af98a0586b4421e4c17 --- tools/finalization/cleanup.sh | 4 ++-- tools/finalization/environment.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/finalization/cleanup.sh b/tools/finalization/cleanup.sh index cd87b1d129..e2a059204e 100755 --- a/tools/finalization/cleanup.sh +++ b/tools/finalization/cleanup.sh @@ -14,8 +14,8 @@ function finalize_revert_local_changes_main() { repo forall -c '\ git checkout . ; git revert --abort ; git clean -fdx ;\ - git checkout @ ; git branch fina-step1 -D ; git reset --hard; \ - repo start fina-step1 ; git checkout @ ; git b fina-step1 -D ;' + git checkout @ --detach ; git branch fina-step1 -D ; git reset --hard; \ + repo start fina-step1 ; git checkout @ --detach ; git b fina-step1 -D ;' } finalize_revert_local_changes_main diff --git a/tools/finalization/environment.sh b/tools/finalization/environment.sh index 7961e8bc3e..cadc26f952 100755 --- a/tools/finalization/environment.sh +++ b/tools/finalization/environment.sh @@ -15,7 +15,7 @@ export FINAL_PLATFORM_VERSION='15' # We might or might not fix this in future, but for now let's keep it +1. export FINAL_PLATFORM_SDK_VERSION='35' # Feel free to randomize once in a while to detect buggy version detection code. -export FINAL_MAINLINE_EXTENSION='58' +export FINAL_MAINLINE_EXTENSION='13' # Options: # 'unfinalized' - branch is in development state, From ee964d2353960982e1dd28db31deb215e6299515 Mon Sep 17 00:00:00 2001 From: Peiyong Lin Date: Thu, 29 Feb 2024 01:34:09 +0000 Subject: [PATCH 05/65] Clean up ANGLE on system build configuration. Now that ANGLE on system is in fully released, clean up the build file configuration and remove the flags. Ignore-AOSP-First: Submit in internal first to avoid build breakage. Bug: b/293503000 Test: atest CtsAngleIntegrationHostTestCases Change-Id: Ie8294b6494e2fad44ff102ecf0018916d61b082a --- target/product/angle_default.mk | 2 -- target/product/angle_supported.mk | 29 ----------------------------- target/product/base_system.mk | 4 ---- 3 files changed, 35 deletions(-) delete mode 100644 target/product/angle_supported.mk diff --git a/target/product/angle_default.mk b/target/product/angle_default.mk index fdfc7f5795..72846d3b02 100644 --- a/target/product/angle_default.mk +++ b/target/product/angle_default.mk @@ -17,7 +17,5 @@ # To enable ANGLE as the default system GLES drivers, add # $(call inherit-product, $(SRC_TARGET_DIR)/product/angle_default.mk) to the Makefile. -$(call inherit-product, $(SRC_TARGET_DIR)/product/angle_supported.mk) - PRODUCT_SYSTEM_PROPERTIES += \ persist.graphics.egl=angle diff --git a/target/product/angle_supported.mk b/target/product/angle_supported.mk deleted file mode 100644 index 59e6ea3500..0000000000 --- a/target/product/angle_supported.mk +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright 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. -# - -# To include ANGLE into the image build, add -# $(call inherit-product, $(SRC_TARGET_DIR)/product/angle_supported.mk) to the Makefile. -# By default, this will allow ANGLE binaries to coexist with native GLES drivers. - -ifneq ($(RELEASE_ANGLE_ON_SYSTEM),true) -PRODUCT_PACKAGES += \ - libEGL_angle \ - libGLESv1_CM_angle \ - libGLESv2_angle - -# Set ro.gfx.angle.supported based on if ANGLE is installed in vendor partition -PRODUCT_VENDOR_PROPERTIES += ro.gfx.angle.supported=true -endif diff --git a/target/product/base_system.mk b/target/product/base_system.mk index e9e32a3450..82a6223711 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -384,14 +384,10 @@ ifeq (,$(DISABLE_WALLPAPER_BACKUP)) WallpaperBackup endif -# Moving angle from vendor to system -ifeq ($(RELEASE_ANGLE_ON_SYSTEM),true) PRODUCT_PACKAGES += \ libEGL_angle \ libGLESv1_CM_angle \ libGLESv2_angle -$(call soong_config_set,angle,angle_on_system,true) -endif # For testing purposes ifeq ($(FORCE_AUDIO_SILENT), true) From 4fb99d85e6604aca7af5f72db881c1be07be4be0 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Mon, 11 Mar 2024 18:14:52 +0000 Subject: [PATCH 06/65] Finalization bugfixes. - keep previous platform versions in platform_releases.txt, - fix for the build version test, - after discussion with Yuri, keep non-REL resource sdk_int the same. Bug: 323940469 Test: local run Ignore-AOSP-First: release configs present in internal repo only Change-Id: I6637e109191480ded615ef35c9185d927ddaec40 --- tools/finalization/finalize-sdk-rel.sh | 9 ------- tools/finalization/finalize-sdk-resources.sh | 16 +++++------ ...rameworks_base.apply_resource_sdk_int.diff | 24 ----------------- ...ameworks_base.revert_resource_sdk_int.diff | 27 ------------------- tools/finalization/step-1.sh | 8 +++--- tools/finalization/step-2.sh | 8 +++--- 6 files changed, 16 insertions(+), 76 deletions(-) delete mode 100644 tools/finalization/frameworks_base.apply_resource_sdk_int.diff delete mode 100644 tools/finalization/frameworks_base.revert_resource_sdk_int.diff diff --git a/tools/finalization/finalize-sdk-rel.sh b/tools/finalization/finalize-sdk-rel.sh index 59fe28cb46..17708604f1 100755 --- a/tools/finalization/finalize-sdk-rel.sh +++ b/tools/finalization/finalize-sdk-rel.sh @@ -8,12 +8,6 @@ function revert_droidstubs_hack() { fi } -function revert_resources_sdk_int_fix() { - if grep -q 'public static final int RESOURCES_SDK_INT = SDK_INT;' "$top/frameworks/base/core/java/android/os/Build.java" ; then - patch --strip=1 --no-backup-if-mismatch --directory="$top/frameworks/base" --input=../../build/make/tools/finalization/frameworks_base.revert_resource_sdk_int.diff - fi -} - function apply_prerelease_sdk_hack() { if ! grep -q 'STOPSHIP: hack for the pre-release SDK' "$top/frameworks/base/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java" ; then patch --strip=1 --no-backup-if-mismatch --directory="$top/frameworks/base" --input=../../build/make/tools/finalization/frameworks_base.apply_hack.diff @@ -30,9 +24,6 @@ function finalize_sdk_rel() { # let the apps built with pre-release SDK parse apply_prerelease_sdk_hack - # in REL mode, resources would correctly set the resources_sdk_int, no fix required - revert_resources_sdk_int_fix - # cts echo "$FINAL_PLATFORM_VERSION" > "$top/cts/tests/tests/os/assets/platform_versions.txt" if [ "$FINAL_PLATFORM_CODENAME" != "$CURRENT_PLATFORM_CODENAME" ]; then diff --git a/tools/finalization/finalize-sdk-resources.sh b/tools/finalization/finalize-sdk-resources.sh index 5299376100..28d0bf59d3 100755 --- a/tools/finalization/finalize-sdk-resources.sh +++ b/tools/finalization/finalize-sdk-resources.sh @@ -9,13 +9,6 @@ function apply_droidstubs_hack() { fi } -function apply_resources_sdk_int_fix() { - if ! grep -q 'public static final int RESOURCES_SDK_INT = SDK_INT;' "$top/frameworks/base/core/java/android/os/Build.java" ; then - local base_git_root="$(readlink -f $top/frameworks/base)" - patch --strip=1 --no-backup-if-mismatch --directory="$base_git_root" --input=../../build/make/tools/finalization/frameworks_base.apply_resource_sdk_int.diff - fi -} - function finalize_bionic_ndk() { # Adding __ANDROID_API_<>__. # If this hasn't done then it's not used and not really needed. Still, let's check and add this. @@ -129,8 +122,12 @@ function finalize_sdk_resources() { fi # cts - echo ${FINAL_PLATFORM_VERSION} > "$top/cts/tests/tests/os/assets/platform_releases.txt" - sed -i -e "s/EXPECTED_SDK = $((${FINAL_PLATFORM_SDK_VERSION}-1))/EXPECTED_SDK = ${FINAL_PLATFORM_SDK_VERSION}/g" "$top/cts/tests/tests/os/src/android/os/cts/BuildVersionTest.java" + if ! grep -q "${FINAL_PLATFORM_VERSION}" "$top/cts/tests/tests/os/assets/platform_releases.txt" ; then + echo ${FINAL_PLATFORM_VERSION} >> "$top/cts/tests/tests/os/assets/platform_releases.txt" + fi + if ! grep -q "$((${FINAL_PLATFORM_SDK_VERSION}-1)), ${FINAL_PLATFORM_VERSION}" "$top/cts/tests/tests/os/src/android/os/cts/BuildVersionTest.java" ; then + sed -i -e "s/.*EXPECTED_SDKS = List.of(.*$((${FINAL_PLATFORM_SDK_VERSION}-1))/&, $FINAL_PLATFORM_SDK_VERSION/" "$top/cts/tests/tests/os/src/android/os/cts/BuildVersionTest.java" + fi # libcore sed -i "s%$SDK_CODENAME%$SDK_VERSION%g" "$top/libcore/dalvik/src/main/java/dalvik/annotation/compat/VersionCodes.java" @@ -153,7 +150,6 @@ function finalize_sdk_resources() { # frameworks/base sed -i "s%$SDK_CODENAME%$SDK_VERSION%g" "$top/frameworks/base/core/java/android/os/Build.java" - apply_resources_sdk_int_fix sed -i -e "/=.*$((${FINAL_PLATFORM_SDK_VERSION}-1)),/a \\ SDK_${FINAL_PLATFORM_CODENAME_JAVA} = ${FINAL_PLATFORM_SDK_VERSION}," "$top/frameworks/base/tools/aapt/SdkConstants.h" 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" diff --git a/tools/finalization/frameworks_base.apply_resource_sdk_int.diff b/tools/finalization/frameworks_base.apply_resource_sdk_int.diff deleted file mode 100644 index f0576d0851..0000000000 --- a/tools/finalization/frameworks_base.apply_resource_sdk_int.diff +++ /dev/null @@ -1,24 +0,0 @@ -From cdb47fc90b8d6860ec1dc5efada1f9ccd471618b Mon Sep 17 00:00:00 2001 -From: Alex Buynytskyy -Date: Tue, 11 Apr 2023 22:12:44 +0000 -Subject: [PATCH] Don't force +1 for resource resolution. - -Bug: 277674088 -Fixes: 277674088 -Test: boots, no crashes -Change-Id: I17e743a0f1cf6f98fddd40c358dea5a8b9cc7723 ---- - -diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java -index eb47170..4d3e92b 100755 ---- a/core/java/android/os/Build.java -+++ b/core/java/android/os/Build.java -@@ -493,7 +493,7 @@ - * @hide - */ - @TestApi -- public static final int RESOURCES_SDK_INT = SDK_INT + ACTIVE_CODENAMES.length; -+ public static final int RESOURCES_SDK_INT = SDK_INT; - - /** - * The current lowest supported value of app target SDK. Applications targeting diff --git a/tools/finalization/frameworks_base.revert_resource_sdk_int.diff b/tools/finalization/frameworks_base.revert_resource_sdk_int.diff deleted file mode 100644 index 2ade499e20..0000000000 --- a/tools/finalization/frameworks_base.revert_resource_sdk_int.diff +++ /dev/null @@ -1,27 +0,0 @@ -From c7e460bb19071d867cd7ca04282ce42694f4f358 Mon Sep 17 00:00:00 2001 -From: Alex Buynytskyy -Date: Wed, 12 Apr 2023 01:06:26 +0000 -Subject: [PATCH] Revert "Don't force +1 for resource resolution." - -It's not required for master. - -This reverts commit f1cb683988f81579a76ddbf9993848a4a06dd28c. - -Bug: 277674088 -Test: boots, no crashes -Change-Id: Ia1692548f26496fdc6f1e4f0557213c7996d6823 ---- - -diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java -index 4d3e92b..eb47170 100755 ---- a/core/java/android/os/Build.java -+++ b/core/java/android/os/Build.java -@@ -493,7 +493,7 @@ - * @hide - */ - @TestApi -- public static final int RESOURCES_SDK_INT = SDK_INT; -+ public static final int RESOURCES_SDK_INT = SDK_INT + ACTIVE_CODENAMES.length; - - /** - * The current lowest supported value of app target SDK. Applications targeting diff --git a/tools/finalization/step-1.sh b/tools/finalization/step-1.sh index 0e483d5510..abfd3b8d3a 100755 --- a/tools/finalization/step-1.sh +++ b/tools/finalization/step-1.sh @@ -21,15 +21,17 @@ function finalize_step_1_main() { local top="$(dirname "$0")"/../../../.. source $top/build/make/tools/finalization/environment.sh - local m="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - source $top/build/make/tools/finalization/finalize-sdk-resources.sh # move all changes to finalization branch/topic and upload to gerrit commit_step_1_changes # build to confirm everything is OK - AIDL_FROZEN_REL=true $m + local m_next="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + AIDL_FROZEN_REL=true $m_next + + local m_fina="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=fina_1 TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + AIDL_FROZEN_REL=true $m_fina } finalize_step_1_main diff --git a/tools/finalization/step-2.sh b/tools/finalization/step-2.sh index 356cad023d..c23f3737ab 100755 --- a/tools/finalization/step-2.sh +++ b/tools/finalization/step-2.sh @@ -19,8 +19,6 @@ function finalize_step_2_main() { local top="$(dirname "$0")"/../../../.. source $top/build/make/tools/finalization/environment.sh - local m="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - # prebuilts etc source $top/build/make/tools/finalization/finalize-sdk-rel.sh @@ -28,7 +26,11 @@ function finalize_step_2_main() { commit_step_2_changes # build to confirm everything is OK - AIDL_FROZEN_REL=true $m + local m_next="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + AIDL_FROZEN_REL=true $m_next + + local m_fina="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=fina_2 TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + AIDL_FROZEN_REL=true $m_fina } finalize_step_2_main From cb96277416487a099debcdd7dca0e6f22fb302b2 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Wed, 13 Mar 2024 08:49:57 -0700 Subject: [PATCH 07/65] Put DeviceDiagnostics on phones and tablets only Bug: 321285898 Test: DeviceDiagnostics.apk is on Pixel 7a after build Ignore-AOSP-First: DeviceDiagnostics.apk is internally developed, not in AOSP Change-Id: I166de8a045d0e0a99c0922f3a7daddc1eec88754 --- target/product/base_system.mk | 1 - target/product/handheld_system.mk | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/target/product/base_system.mk b/target/product/base_system.mk index 5969cc884d..231880d737 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -82,7 +82,6 @@ PRODUCT_PACKAGES += \ CtsShimPrivPrebuilt \ debuggerd\ device_config \ - DeviceDiagnostics \ dmctl \ dnsmasq \ dmesgd \ diff --git a/target/product/handheld_system.mk b/target/product/handheld_system.mk index d706372724..851ae8a427 100644 --- a/target/product/handheld_system.mk +++ b/target/product/handheld_system.mk @@ -45,6 +45,7 @@ PRODUCT_PACKAGES += \ CertInstaller \ CredentialManager \ DeviceAsWebcam \ + DeviceDiagnostics \ DocumentsUI \ DownloadProviderUi \ EasterEgg \ From f05c249d2ae7488059bce1bba70b10aa7802fb0a Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Wed, 13 Mar 2024 18:29:25 +0000 Subject: [PATCH 08/65] Finalization bugfixes. Keep isAtLeast* functions compatible with older release configs. Fixes: 329312253 Test: local run + presubmit Ignore-AOSP-First: release configs present in internal repo only Change-Id: I776dd808e2e01e8a1c7a6f9b6171fd84f49cdcdf --- tools/finalization/finalize-sdk-resources.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/finalization/finalize-sdk-resources.sh b/tools/finalization/finalize-sdk-resources.sh index 28d0bf59d3..003b7c04c9 100755 --- a/tools/finalization/finalize-sdk-resources.sh +++ b/tools/finalization/finalize-sdk-resources.sh @@ -34,7 +34,8 @@ function finalize_modules_utils() { echo " /** Checks if the device is running on a release version of Android $FINAL_PLATFORM_CODENAME or newer */ @ChecksSdkIntAtLeast(api = $FINAL_PLATFORM_SDK_VERSION /* BUILD_VERSION_CODES.$FINAL_PLATFORM_CODENAME */) public static boolean isAtLeast${FINAL_PLATFORM_CODENAME:0:1}() { - return SDK_INT >= $FINAL_PLATFORM_SDK_VERSION; + return SDK_INT >= $FINAL_PLATFORM_SDK_VERSION || + (SDK_INT == $(($FINAL_PLATFORM_SDK_VERSION - 1)) && isAtLeastPreReleaseCodename(\"$FINAL_PLATFORM_CODENAME\")); }" > "$tmpfile" local javaFuncRegex='\/\*\*[^{]*isAtLeast'"${shortCodename}"'() {[^{}]*}' @@ -48,7 +49,11 @@ function finalize_modules_utils() { d}' $javaSdkLevel echo "// Checks if the device is running on release version of Android ${FINAL_PLATFORM_CODENAME:0:1} or newer. -inline bool IsAtLeast${FINAL_PLATFORM_CODENAME:0:1}() { return android_get_device_api_level() >= $FINAL_PLATFORM_SDK_VERSION; }" > "$tmpfile" +inline bool IsAtLeast${FINAL_PLATFORM_CODENAME:0:1}() { + return android_get_device_api_level() >= $FINAL_PLATFORM_SDK_VERSION || + (android_get_device_api_level() == $(($FINAL_PLATFORM_SDK_VERSION - 1)) && + detail::IsAtLeastPreReleaseCodename(\"$FINAL_PLATFORM_CODENAME\")); +}" > "$tmpfile" local cppFuncRegex='\/\/[^{]*IsAtLeast'"${shortCodename}"'() {[^{}]*}' local cppFuncReplace="N;N;N;N;N;N; s/$cppFuncRegex/$methodPlaceholder/; /$cppFuncRegex/!{P;D};" From 9b15a4d6e99c417eeac224749daeb35ce2bf9139 Mon Sep 17 00:00:00 2001 From: Miguel Aranda Date: Thu, 14 Mar 2024 09:16:11 +0000 Subject: [PATCH 09/65] Revert "Add window_extensions to all builds" Revert submission 25408015-wm_extensions_for_all Reason for revert: b/329534949 Reverted changes: /q/submissionid:25408015-wm_extensions_for_all Change-Id: Ie5fb0613d4cf0cb137e82b20d781787fd337db0c --- target/product/base_system_ext.mk | 3 --- target/product/window_extensions.mk | 17 +++++------- target/product/window_extensions_base.mk | 34 ------------------------ 3 files changed, 7 insertions(+), 47 deletions(-) delete mode 100644 target/product/window_extensions_base.mk diff --git a/target/product/base_system_ext.mk b/target/product/base_system_ext.mk index f0e6ec90c5..76f008f323 100644 --- a/target/product/base_system_ext.mk +++ b/target/product/base_system_ext.mk @@ -28,6 +28,3 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES_SHIPPING_API_LEVEL_34 += \ hwservicemanager \ android.hidl.allocator@1.0-service \ - -# Window Extensions -$(call inherit-product, $(SRC_TARGET_DIR)/product/window_extensions_base.mk) diff --git a/target/product/window_extensions.mk b/target/product/window_extensions.mk index d27a613a61..5f5431f677 100644 --- a/target/product/window_extensions.mk +++ b/target/product/window_extensions.mk @@ -14,14 +14,11 @@ # limitations under the License. # -# Extension of window_extensions_base.mk to enable the activity embedding -# feature for all apps by default. All large screen devices must inherit -# this in build. Optional for other form factors. -# -# Indicated whether the Activity Embedding feature should be guarded by -# Android 15 to avoid app compat impact. -# If true (or not set), the feature is only enabled for apps with target -# SDK of Android 15 or above. -# If false, the feature is enabled for all apps. +# /system_ext packages +PRODUCT_PACKAGES += \ + androidx.window.extensions \ + androidx.window.sidecar + +# properties PRODUCT_PRODUCT_PROPERTIES += \ - persist.wm.extensions.activity_embedding_guard_with_android_15=false + persist.wm.extensions.enabled=true diff --git a/target/product/window_extensions_base.mk b/target/product/window_extensions_base.mk deleted file mode 100644 index 07ed5e3043..0000000000 --- a/target/product/window_extensions_base.mk +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright (C) 2024 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. -# - -# The base version of window_extensions.mk to be included on all devices. -# Devices that don't support multi-window can choose to drop this. -# TODO(b/326009200): Remove from build that doesn't support multi-window. -# -# Note: by default the Activity Embedding feature is guarded by app's -# targetSDK on Android 15 to avoid app compat impact. -# -# Large screen devices must inherit window_extensions.mk to enable the -# Activity Embedding feature for all apps. - -# /system_ext packages -PRODUCT_PACKAGES += \ - androidx.window.extensions \ - androidx.window.sidecar - -# properties -PRODUCT_PRODUCT_PROPERTIES += \ - persist.wm.extensions.enabled=true From d269659a47000a5ebedea9617a8a4d0cd52b968c Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Wed, 13 Mar 2024 15:40:05 +0000 Subject: [PATCH 10/65] Update Security String to 2024-05-01 Bug: 327392432 Change-Id: I167be7ba5e93b60d61e9f7bc3028e60dd6c99e0a Merged-In: I167be7ba5e93b60d61e9f7bc3028e60dd6c99e0a Merged-In: I92394c4ae0cc35544e72d72cac6cd3a417b62e06 Merged-In: I90c3486766809f47361677f97cdd3ff0d6ca487e Merged-In: Id2b65e35697d27e1bd9a65315b6b5ac7fb918b7a Merged-In: I9edc7171d124f0cfa540fea6f0e06ba877910444 --- 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 985e170c8d..7cf84a2078 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 := 2024-04-01 + PLATFORM_SECURITY_PATCH := 2024-05-01 endif .KATI_READONLY := PLATFORM_SECURITY_PATCH From 5b34f3f6271def4721b0c6244ab31ccb3a64863d Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Fri, 15 Mar 2024 00:29:59 +0000 Subject: [PATCH 11/65] Finalization bugfixes. Keep codenames in the platform_versions.txt to allow for non-REL builds. Bug: 323940469 Test: local run Ignore-AOSP-First: Release configs are interal repo only. Change-Id: I664ac1c32c3aae5175d3b7a36ac763b35181bc22 --- tools/finalization/finalize-sdk-rel.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/finalization/finalize-sdk-rel.sh b/tools/finalization/finalize-sdk-rel.sh index 17708604f1..ca2f20d3b7 100755 --- a/tools/finalization/finalize-sdk-rel.sh +++ b/tools/finalization/finalize-sdk-rel.sh @@ -25,7 +25,9 @@ function finalize_sdk_rel() { apply_prerelease_sdk_hack # cts - echo "$FINAL_PLATFORM_VERSION" > "$top/cts/tests/tests/os/assets/platform_versions.txt" + if ! grep -q "${FINAL_PLATFORM_VERSION}" "$top/cts/tests/tests/os/assets/platform_versions.txt" ; then + echo ${FINAL_PLATFORM_VERSION} >> "$top/cts/tests/tests/os/assets/platform_versions.txt" + fi if [ "$FINAL_PLATFORM_CODENAME" != "$CURRENT_PLATFORM_CODENAME" ]; then echo "$CURRENT_PLATFORM_CODENAME" >> "./cts/tests/tests/os/assets/platform_versions.txt" fi From 786527c4894fc60282e9828bbd4c37e9cc7dea6a Mon Sep 17 00:00:00 2001 From: Chris Li Date: Thu, 14 Mar 2024 13:25:21 +0000 Subject: [PATCH 12/65] Reland WM Extensions for all devices The revert is because there is a prebuilt app using an outdated unreleased sidecar API (from 2022). Bug: 306666082 Test: pass the failure test Change-Id: I74f5f6cff84d7f26466ccdea8bcc982bc363a5d3 --- target/product/base_system_ext.mk | 3 +++ target/product/window_extensions.mk | 17 +++++++----- target/product/window_extensions_base.mk | 34 ++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 target/product/window_extensions_base.mk diff --git a/target/product/base_system_ext.mk b/target/product/base_system_ext.mk index 76f008f323..f0e6ec90c5 100644 --- a/target/product/base_system_ext.mk +++ b/target/product/base_system_ext.mk @@ -28,3 +28,6 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES_SHIPPING_API_LEVEL_34 += \ hwservicemanager \ android.hidl.allocator@1.0-service \ + +# Window Extensions +$(call inherit-product, $(SRC_TARGET_DIR)/product/window_extensions_base.mk) diff --git a/target/product/window_extensions.mk b/target/product/window_extensions.mk index 5f5431f677..d27a613a61 100644 --- a/target/product/window_extensions.mk +++ b/target/product/window_extensions.mk @@ -14,11 +14,14 @@ # limitations under the License. # -# /system_ext packages -PRODUCT_PACKAGES += \ - androidx.window.extensions \ - androidx.window.sidecar - -# properties +# Extension of window_extensions_base.mk to enable the activity embedding +# feature for all apps by default. All large screen devices must inherit +# this in build. Optional for other form factors. +# +# Indicated whether the Activity Embedding feature should be guarded by +# Android 15 to avoid app compat impact. +# If true (or not set), the feature is only enabled for apps with target +# SDK of Android 15 or above. +# If false, the feature is enabled for all apps. PRODUCT_PRODUCT_PROPERTIES += \ - persist.wm.extensions.enabled=true + persist.wm.extensions.activity_embedding_guard_with_android_15=false diff --git a/target/product/window_extensions_base.mk b/target/product/window_extensions_base.mk new file mode 100644 index 0000000000..07ed5e3043 --- /dev/null +++ b/target/product/window_extensions_base.mk @@ -0,0 +1,34 @@ +# +# Copyright (C) 2024 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. +# + +# The base version of window_extensions.mk to be included on all devices. +# Devices that don't support multi-window can choose to drop this. +# TODO(b/326009200): Remove from build that doesn't support multi-window. +# +# Note: by default the Activity Embedding feature is guarded by app's +# targetSDK on Android 15 to avoid app compat impact. +# +# Large screen devices must inherit window_extensions.mk to enable the +# Activity Embedding feature for all apps. + +# /system_ext packages +PRODUCT_PACKAGES += \ + androidx.window.extensions \ + androidx.window.sidecar + +# properties +PRODUCT_PRODUCT_PROPERTIES += \ + persist.wm.extensions.enabled=true From ff11fd70d750f8fc395248a0118ef9cf9b839db4 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 14 Mar 2024 10:48:55 -0700 Subject: [PATCH 13/65] Allow duplicate release config maps and build flag declarations Only include a release_config_map.mk file the first time it appears in the list. If the flag declaration is identical to one already declared, do not raise an error. This eases the process of migrating where flags are declared. Bug: b/328781415 Bug: b/328495189 Test: manual, TH Ignore-AOSP-First: larger topic on git_main, will cp to AOSP. Change-Id: I18316e769438f62071723771762d6e89be98b813 --- core/release_config.mk | 11 ++++++++--- core/release_config.scl | 21 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/core/release_config.mk b/core/release_config.mk index a6152bdb41..36882bb0ce 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -119,12 +119,17 @@ define _declare-release-config endef # Include the config map files and populate _flag_declaration_files. +# If the file is found more than once, only include it the first time. _flag_declaration_files := +_included_config_map_files := $(foreach f, $(config_map_files), \ $(eval FLAG_DECLARATION_FILES:= ) \ - $(eval _included := $(f)) \ - $(eval include $(f)) \ - $(eval _flag_declaration_files += $(FLAG_DECLARATION_FILES)) \ + $(if $(filter $(_included_config_map_files),$(f)),,\ + $(eval _included := $(f)) \ + $(eval include $(f)) \ + $(eval _flag_declaration_files += $(FLAG_DECLARATION_FILES)) \ + $(eval _included_config_map_files += $(f)) \ + ) \ ) FLAG_DECLARATION_FILES := diff --git a/core/release_config.scl b/core/release_config.scl index 662d15507a..629e22328a 100644 --- a/core/release_config.scl +++ b/core/release_config.scl @@ -145,6 +145,21 @@ def _format_value(val): else: return val +def equal_flag_declaration(flag, other): + """Return true if the flag declarations are equal. + + Args: + flag: This flag declaration. + other: Another flag declaration. + + Returns: + Whether the declarations are the same. + """ + for key in "name", "partitions", "default", "appends": + if flag[key] != other[key]: + return False + return True + def release_config(all_flags, all_values): """Return the make variables that should be set for this release config. @@ -163,7 +178,11 @@ def release_config(all_flags, all_values): flags_dict = {} for flag in all_flags: if flag["name"] in flag_names: - fail(flag["declared_in"] + ": Duplicate declaration of flag " + flag["name"]) + if equal_flag_declaration(flag, flags_dict[flag["name"]]): + continue + else: + fail(flag["declared_in"] + ": Duplicate declaration of flag " + flag["name"] + + " (declared first in " + flags_dict[flag["name"]]["declared_in"] + ")") flag_names.append(flag["name"]) flags_dict[flag["name"]] = flag From 10411eeb71c6279d1eefb5b987ed3576caf9cec6 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Fri, 15 Mar 2024 03:14:14 +0000 Subject: [PATCH 14/65] DryRun scripts. Bug: 323940469 Test: run locally Ignore-AOSP-First: local changes first Change-Id: Ia27924a01433e613496e9a624f93d385a08678a3 --- tools/finalization/README.md | 5 +++ tools/finalization/dryrun-cleanup.sh | 25 +++++++++++++++ tools/finalization/dryrun-step-1-and-2.sh | 39 +++++++++++++++++++++++ tools/finalization/dryrun-step-1.sh | 35 ++++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100755 tools/finalization/dryrun-cleanup.sh create mode 100755 tools/finalization/dryrun-step-1-and-2.sh create mode 100755 tools/finalization/dryrun-step-1.sh diff --git a/tools/finalization/README.md b/tools/finalization/README.md index d0aed69ae2..5e2aecd525 100644 --- a/tools/finalization/README.md +++ b/tools/finalization/README.md @@ -19,3 +19,8 @@ Performed in build targets in Finalization branches. ## Utility: [Full cleanup](./cleanup.sh). Remove all local changes and switch each project into head-less state. This is the best state to sync/rebase/finalize the branch. + +## Dry run: +[Full cleanup](./dryrun-cleanup.sh). Remove all local changes and switch each project into head-less state. Also removes "DryRun" branches. +[SDK](./dryrun-step-1.sh). Perform SDK finalization and upload the CLs to Gerrit. +[SDK and REL](./dryrun-step-1-and-2.sh). Perform SDK finalization, plus all necessary changes to switch configuration to REL, and upload the CLs to Gerrit. \ No newline at end of file diff --git a/tools/finalization/dryrun-cleanup.sh b/tools/finalization/dryrun-cleanup.sh new file mode 100755 index 0000000000..ddaffae44c --- /dev/null +++ b/tools/finalization/dryrun-cleanup.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Brings local repository to a remote head state. Also removes all dryrun branches. + +# set -ex + +function finalize_revert_local_changes_main() { + local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/environment.sh + + local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + + # remove the out folder + $m clobber + + repo selfupdate + + repo forall -c '\ + git checkout . ; git revert --abort ; git clean -fdx ;\ + git checkout @ --detach ; git branch fina-step1 -D ; git reset --hard; \ + repo start fina-step1 ; git checkout @ --detach ; git b fina-step1 -D ; \ + git b $FINAL_PLATFORM_CODENAME-SDK-Finalization-DryRun -D; \ + git b $FINAL_PLATFORM_CODENAME-SDK-Finalization-DryRun-Rel -D; ' +} + +finalize_revert_local_changes_main diff --git a/tools/finalization/dryrun-step-1-and-2.sh b/tools/finalization/dryrun-step-1-and-2.sh new file mode 100755 index 0000000000..38fdb0595b --- /dev/null +++ b/tools/finalization/dryrun-step-1-and-2.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Script to perform 1st and 2nd step of Android Finalization, create CLs and upload to Gerrit. + +function commit_step_2_changes() { + repo forall -c '\ + if [[ $(git status --short) ]]; then + repo start "$FINAL_PLATFORM_CODENAME-SDK-Finalization-DryRun-Rel" ; + git add -A . ; + git commit -m "$FINAL_PLATFORM_CODENAME/$FINAL_PLATFORM_SDK_VERSION is now REL" \ + -m "Ignore-AOSP-First: $FINAL_PLATFORM_CODENAME Finalization +Bug: $FINAL_BUG_ID +Test: build"; + + repo upload --cbr --no-verify -o nokeycheck -t -y . ; + fi' +} + +function finalize_step_2_main() { + local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/environment.sh + + source $top/build/make/tools/finalization/finalize-sdk-resources.sh + + source $top/build/make/tools/finalization/localonly-steps.sh + + source $top/build/make/tools/finalization/finalize-sdk-rel.sh + + # move all changes to finalization branch/topic and upload to gerrit + commit_step_2_changes + + # build to confirm everything is OK + local m_next="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + AIDL_FROZEN_REL=true $m_next + + local m_fina="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=fina_2 TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + AIDL_FROZEN_REL=true $m_fina +} + +finalize_step_2_main diff --git a/tools/finalization/dryrun-step-1.sh b/tools/finalization/dryrun-step-1.sh new file mode 100755 index 0000000000..d8893953ab --- /dev/null +++ b/tools/finalization/dryrun-step-1.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# Script to perform a dry run of step 1 of Android Finalization, create CLs and upload to Gerrit. + +function commit_step_1_changes() { + repo forall -c '\ + if [[ $(git status --short) ]]; then + repo start "$FINAL_PLATFORM_CODENAME-SDK-Finalization-DryRun" ; + git add -A . ; + git commit -m "$FINAL_PLATFORM_CODENAME is now $FINAL_PLATFORM_SDK_VERSION" \ + -m "Ignore-AOSP-First: $FINAL_PLATFORM_CODENAME Finalization +Bug: $FINAL_BUG_ID +Test: build"; + + repo upload --cbr --no-verify -o nokeycheck -t -y . ; + fi' +} + +function finalize_step_1_main() { + local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/environment.sh + + source $top/build/make/tools/finalization/finalize-sdk-resources.sh + + # move all changes to finalization branch/topic and upload to gerrit + commit_step_1_changes + + # build to confirm everything is OK + local m_next="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + AIDL_FROZEN_REL=true $m_next + + local m_fina="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=fina_1 TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" + AIDL_FROZEN_REL=true $m_fina +} + +finalize_step_1_main From 539de4dac00351c2ac2f84dd7340ecfd74e45446 Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Wed, 20 Mar 2024 03:16:10 +0000 Subject: [PATCH 15/65] Update Security String to 2024-06-01 Bug: 330382848 Change-Id: Ida6705ee71e4601f976836d73e0dda2ed7033c2a Merged-In: Ida6705ee71e4601f976836d73e0dda2ed7033c2a Merged-In: Id95e0f901c983bd3850235f2830f0ef08650bd26 Merged-In: I8cd6fc37b026f70743250f0d9a2979bf9e9998ae Merged-In: If80822e387cb2a950b47422aa1d1ff2a98cd93cb Merged-In: Iccae3f6836512b2d3a07f9d8bcec7d09c2a34a2b Merged-In: I9edc7171d124f0cfa540fea6f0e06ba877910444 --- 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 7cf84a2078..fa1445b389 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 := 2024-05-01 + PLATFORM_SECURITY_PATCH := 2024-06-01 endif .KATI_READONLY := PLATFORM_SECURITY_PATCH From 133f72f6dc61782151434aedf75d706f5e7ad764 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Tue, 20 Feb 2024 07:48:22 +0000 Subject: [PATCH 16/65] Convert BuildIgnoreApexContritbutions variable to a boolean The ignore list is burdensome to maintain once we start adding the module sdk contents to apex_contributions. Convert the variable to a boolean. When set to true, all contents in `apex_contributions` will be ignored Bug: 308187268 Test: m nothing on aosp,google and google_fullmte devices Ignore-AOSP-first: CL topic does a cleanup of an internal only denylist Change-Id: If899f6eaf5449c2aa789d0bd5b791a3db715c676 --- core/product.mk | 2 +- core/product_config.mk | 21 +-------------------- core/soong_config.mk | 2 +- 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/core/product.mk b/core/product.mk index d64dde2c68..39c350571f 100644 --- a/core/product.mk +++ b/core/product.mk @@ -457,7 +457,7 @@ _product_list_vars += PRODUCT_VALIDATION_CHECKS _product_single_value_vars += PRODUCT_BUILD_FROM_SOURCE_STUB -_product_list_vars += PRODUCT_BUILD_IGNORE_APEX_CONTRIBUTION_CONTENTS +_product_single_value_vars += PRODUCT_BUILD_IGNORE_APEX_CONTRIBUTION_CONTENTS _product_single_value_vars += PRODUCT_HIDDEN_API_EXPORTABLE_STUBS diff --git a/core/product_config.mk b/core/product_config.mk index 2f1f7fa678..2ed292c18e 100644 --- a/core/product_config.mk +++ b/core/product_config.mk @@ -315,26 +315,7 @@ ifeq (true,$(PRODUCT_MODULE_BUILD_FROM_SOURCE)) ignore_apex_contributions := true endif ifeq (true, $(ignore_apex_contributions)) -PRODUCT_BUILD_IGNORE_APEX_CONTRIBUTION_CONTENTS += \ - prebuilt_com.google.android.adservices \ - prebuilt_com.google.android.appsearch \ - prebuilt_com.google.android.art \ - prebuilt_com.google.android.btservices \ - prebuilt_com.google.android.configinfrastructure \ - prebuilt_com.google.android.conscrypt \ - prebuilt_com.google.android.devicelock \ - prebuilt_com.google.android.healthfitness \ - prebuilt_com.google.android.ipsec \ - prebuilt_com.google.android.media \ - prebuilt_com.google.android.mediaprovider \ - prebuilt_com.google.android.ondevicepersonalization \ - prebuilt_com.google.android.os.statsd \ - prebuilt_com.google.android.rkpd \ - prebuilt_com.google.android.scheduling \ - prebuilt_com.google.android.sdkext \ - prebuilt_com.google.android.tethering \ - prebuilt_com.google.android.uwb \ - prebuilt_com.google.android.wifi +PRODUCT_BUILD_IGNORE_APEX_CONTRIBUTION_CONTENTS := true endif ############################################################################# diff --git a/core/soong_config.mk b/core/soong_config.mk index d4c56e5707..3987f66ce1 100644 --- a/core/soong_config.mk +++ b/core/soong_config.mk @@ -335,7 +335,7 @@ $(call add_json_bool, KeepVndk, $(filter true,$(KEEP_VNDK))) $(call add_json_bool, CheckVendorSeappViolations, $(filter true,$(CHECK_VENDOR_SEAPP_VIOLATIONS))) -$(call add_json_list, BuildIgnoreApexContributionContents, $(sort $(PRODUCT_BUILD_IGNORE_APEX_CONTRIBUTION_CONTENTS))) +$(call add_json_bool, BuildIgnoreApexContributionContents, $(PRODUCT_BUILD_IGNORE_APEX_CONTRIBUTION_CONTENTS)) $(call add_json_map, PartitionVarsForBazelMigrationOnlyDoNotUse) $(call add_json_str, ProductDirectory, $(dir $(INTERNAL_PRODUCT))) From a6a99b7ed3615d3c2a4e182e80e9d492bc32aa54 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Mon, 25 Mar 2024 19:23:26 +0000 Subject: [PATCH 17/65] Add go apexes to ignore_apex_contributions allowlist This ensures that we do not ignore apex_contributions for go devices Test: lunch mokey_32-next-userdebug and verify BuildIgnoreApexContributionContents is false Test: presubmit Bug: 331188599 Ignore-AOSP-First: modifies an allowlist which is not present in aosp Change-Id: I4532f3743eb3b7121e1f5e522097c1aba3d9a4fd --- core/product_config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/product_config.mk b/core/product_config.mk index 2ed292c18e..fae2c1ad04 100644 --- a/core/product_config.mk +++ b/core/product_config.mk @@ -308,7 +308,7 @@ endif # TODO(b/308187268): Remove this denylist mechanism # Use PRODUCT_PACKAGES to determine if this is an aosp product. aosp products do not use google signed apexes. ignore_apex_contributions := -ifeq (,$(findstring com.google.android.conscrypt,$(PRODUCT_PACKAGES))) +ifeq (,$(findstring com.google.android.conscrypt,$(PRODUCT_PACKAGES))$(findstring com.google.android.go.conscrypt,$(PRODUCT_PACKAGES))) ignore_apex_contributions := true endif ifeq (true,$(PRODUCT_MODULE_BUILD_FROM_SOURCE)) From 4b88326361029c0d7090c7c8f95783040677351e Mon Sep 17 00:00:00 2001 From: Chris Li Date: Wed, 27 Mar 2024 07:13:07 +0000 Subject: [PATCH 18/65] Remove WM Extensions from wearable Wearable doesn't need WM Extensions. Bug: 306666082 Ignore-AOSP-First: need internal-first change to guard with flag Test: atest CtsWindowManagerJetpackTestCases:SdkAvailabilityTest Change-Id: Idd0f7269ccfacbc2e3030f35a5fd2ebf965b8db2 --- target/product/base_system_ext.mk | 3 --- target/product/media_system_ext.mk | 3 +++ target/product/window_extensions_base.mk | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/target/product/base_system_ext.mk b/target/product/base_system_ext.mk index f0e6ec90c5..76f008f323 100644 --- a/target/product/base_system_ext.mk +++ b/target/product/base_system_ext.mk @@ -28,6 +28,3 @@ PRODUCT_PACKAGES += \ PRODUCT_PACKAGES_SHIPPING_API_LEVEL_34 += \ hwservicemanager \ android.hidl.allocator@1.0-service \ - -# Window Extensions -$(call inherit-product, $(SRC_TARGET_DIR)/product/window_extensions_base.mk) diff --git a/target/product/media_system_ext.mk b/target/product/media_system_ext.mk index 2e20af3d47..30dd2e2711 100644 --- a/target/product/media_system_ext.mk +++ b/target/product/media_system_ext.mk @@ -23,3 +23,6 @@ $(call inherit-product, $(SRC_TARGET_DIR)/product/base_system_ext.mk) # /system_ext packages PRODUCT_PACKAGES += \ vndk_apex_snapshot_package \ + +# Window Extensions +$(call inherit-product, $(SRC_TARGET_DIR)/product/window_extensions_base.mk) diff --git a/target/product/window_extensions_base.mk b/target/product/window_extensions_base.mk index 07ed5e3043..ee0e5e7c89 100644 --- a/target/product/window_extensions_base.mk +++ b/target/product/window_extensions_base.mk @@ -14,9 +14,8 @@ # limitations under the License. # -# The base version of window_extensions.mk to be included on all devices. -# Devices that don't support multi-window can choose to drop this. -# TODO(b/326009200): Remove from build that doesn't support multi-window. +# The base version of window_extensions.mk to be included on all non-wearable +# devices. Devices that don't support multi-window can choose to drop this. # # Note: by default the Activity Embedding feature is guarded by app's # targetSDK on Android 15 to avoid app compat impact. From df5bd53d550b0ef83035cd2fb5f7ec8ec4fb4b86 Mon Sep 17 00:00:00 2001 From: Alex Buynytskyy Date: Thu, 29 Feb 2024 19:12:03 +0000 Subject: [PATCH 19/65] Allowlist for platform signed package/sharedUid-s. Fixes: <308573259> Test: atest android.content.pm.cts.PackageManagerTest Ignore-AOSP-First: file is added in internal branch (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:7f2661f46717bd6b3c8ed20168caf03d71bbabb0) Merged-In: I02e87e92878770cf21fb5032efb75eb1b222c62f Change-Id: I02e87e92878770cf21fb5032efb75eb1b222c62f 24D1-dev is based on 24Q2-release. Therefore, we merged this CL to 24D1-dev. --- 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 e9e32a3450..5969cc884d 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -238,6 +238,7 @@ PRODUCT_PACKAGES += \ org.apache.http.legacy \ otacerts \ PackageInstaller \ + package-shareduid-allowlist.xml \ passwd_system \ perfetto \ ping \ From d6be720337bce468e4a12c7730de6d9fa4f05e34 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 27 Mar 2024 17:37:32 -0700 Subject: [PATCH 20/65] release_config: cleanup how default values are used Set the flag value to the default value, rather than waiting until the end to check if it was set anywhere. This matters when the flag is declared `appends=True`. Bug: none Test: manual Ignore-AOSP-First: Will CP, testing on internal first. Change-Id: I8384cf8e0e0caedb5fb5a343f8be23f37bf4dc87 --- core/release_config.scl | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/core/release_config.scl b/core/release_config.scl index 728fc1b399..c5815dfe30 100644 --- a/core/release_config.scl +++ b/core/release_config.scl @@ -179,18 +179,23 @@ def release_config(all_flags, all_values): validate(all_flags, _all_flags_schema) validate(all_values, _all_values_schema) + # Final values. + values = {} # Validate flags flag_names = [] flags_dict = {} for flag in all_flags: - if flag["name"] in flag_names: - if equal_flag_declaration(flag, flags_dict[flag["name"]]): + name = flag["name"] + if name in flag_names: + if equal_flag_declaration(flag, flags_dict[name]): continue else: - fail(flag["declared_in"] + ": Duplicate declaration of flag " + flag["name"] + - " (declared first in " + flags_dict[flag["name"]]["declared_in"] + ")") - flag_names.append(flag["name"]) - flags_dict[flag["name"]] = flag + fail(flag["declared_in"] + ": Duplicate declaration of flag " + name + + " (declared first in " + flags_dict[name]["declared_in"] + ")") + flag_names.append(name) + flags_dict[name] = flag + # Set the flag value to the default value. + values[name] = {"name": name, "value": _format_value(flag["default"]), "set_in": flag["declared_in"]} # Record which flags go on which partition partitions = {} @@ -206,7 +211,6 @@ def release_config(all_flags, all_values): # 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: @@ -227,19 +231,13 @@ def release_config(all_flags, all_values): 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) + val = _format_value(values[flag["name"]]["value"]) 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 + result["_ALL_RELEASE_FLAGS." + flag["name"] + ".SET_IN"] = values[flag["name"]]["set_in"] result["_ALL_RELEASE_FLAGS." + flag["name"] + ".ORIGIN"] = flag["origin"] return result From 9d92aacbda55b07afde73c066ed85052f8f8e6c0 Mon Sep 17 00:00:00 2001 From: Steven Terrell Date: Thu, 21 Mar 2024 17:22:14 +0000 Subject: [PATCH 21/65] Add trace redactor to system This change adds the trace_redactor binary to system so that it can be called from the Profiling module. Bug: 327423523 Test: build and flash phone, verify binary is avalable at /system/bin. Ignore-AOSP-First: Profiling changes are not in AOSP yet, will merge at later date. Change-Id: I661fca73c02e2904b988b4bddce62f09c7e3a5d7 --- target/product/base_system.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/product/base_system.mk b/target/product/base_system.mk index cb507bb310..f26305de1e 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -334,7 +334,8 @@ endif # Check if the build supports Profiling module ifeq ($(RELEASE_PACKAGE_PROFILING_MODULE),true) PRODUCT_PACKAGES += \ - com.android.profiling + com.android.profiling \ + trace_redactor endif ifeq ($(RELEASE_USE_WEBVIEW_BOOTSTRAP_MODULE),true) From 7847bfcba99825e87fe3071493859e415b796887 Mon Sep 17 00:00:00 2001 From: Anna Bauza Date: Thu, 21 Mar 2024 20:58:52 +0000 Subject: [PATCH 22/65] Refactor SettingsLib to remove redundant resources conditionally Bug: 320878675 Test: manual Change-Id: Ic5862c45dcb3383a736b43fcf98ab58f05149ec7 Ignore-AOSP-First: Feature not yet exposed to AOSP --- 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 cb507bb310..cbd34b2c39 100644 --- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -508,3 +508,4 @@ $(call inherit-product, $(SRC_TARGET_DIR)/product/build_variables.mk) $(call inherit-product,$(SRC_TARGET_DIR)/product/updatable_apex.mk) $(call soong_config_set, bionic, large_system_property_node, $(RELEASE_LARGE_SYSTEM_PROPERTY_NODE)) +$(call soong_config_set, SettingsLib, legacy_avatar_picker_app_enabled, $(if $(RELEASE_AVATAR_PICKER_APP),,true)) From 8350c6ddce5e8da1094d1564382d2f8b7f2a562a Mon Sep 17 00:00:00 2001 From: Ted Bauer Date: Mon, 18 Mar 2024 18:37:50 -0400 Subject: [PATCH 23/65] aconfig: read from new storage in Rust codegen Read storage values for read-only flags, and log failures or mismatches with compiled-in defaults. Continue to return values fetched from the legacy storage. Test: cargo t Bug: 328444881 Ignore-AOSP-First: internal storage migration, this code will be deleted Change-Id: I4651617270129794dec64e324b4aa7836cce7a43 --- tools/aconfig/aconfig/src/codegen/rust.rs | 403 +++++++++++++++++- tools/aconfig/aconfig/src/commands.rs | 16 +- tools/aconfig/aconfig/src/main.rs | 12 +- tools/aconfig/aconfig/templates/rust.template | 80 +++- 4 files changed, 480 insertions(+), 31 deletions(-) diff --git a/tools/aconfig/aconfig/src/codegen/rust.rs b/tools/aconfig/aconfig/src/codegen/rust.rs index 33c3d37633..591781e081 100644 --- a/tools/aconfig/aconfig/src/codegen/rust.rs +++ b/tools/aconfig/aconfig/src/codegen/rust.rs @@ -20,26 +20,32 @@ use tinytemplate::TinyTemplate; use aconfig_protos::{ProtoFlagPermission, ProtoFlagState, ProtoParsedFlag}; +use std::collections::HashMap; + use crate::codegen; use crate::codegen::CodegenMode; use crate::commands::OutputFile; pub fn generate_rust_code( package: &str, + flag_ids: HashMap, parsed_flags_iter: I, codegen_mode: CodegenMode, + allow_instrumentation: bool, ) -> Result where I: Iterator, { - let template_flags: Vec = - parsed_flags_iter.map(|pf| TemplateParsedFlag::new(package, &pf)).collect(); + let template_flags: Vec = parsed_flags_iter + .map(|pf| TemplateParsedFlag::new(package, flag_ids.clone(), &pf)) + .collect(); let has_readwrite = template_flags.iter().any(|item| item.readwrite); let context = TemplateContext { package: package.to_string(), template_flags, modules: package.split('.').map(|s| s.to_string()).collect::>(), has_readwrite, + allow_instrumentation, }; let mut template = TinyTemplate::new(); template.add_template( @@ -62,6 +68,7 @@ struct TemplateContext { pub template_flags: Vec, pub modules: Vec, pub has_readwrite: bool, + pub allow_instrumentation: bool, } #[derive(Serialize)] @@ -69,25 +76,28 @@ struct TemplateParsedFlag { pub readwrite: bool, pub default_value: String, pub name: String, + pub container: String, + pub flag_offset: u16, pub device_config_namespace: String, pub device_config_flag: String, } impl TemplateParsedFlag { #[allow(clippy::nonminimal_bool)] - fn new(package: &str, pf: &ProtoParsedFlag) -> Self { - let template = TemplateParsedFlag { + fn new(package: &str, flag_offsets: HashMap, pf: &ProtoParsedFlag) -> Self { + Self { readwrite: pf.permission() == ProtoFlagPermission::READ_WRITE, default_value: match pf.state() { ProtoFlagState::ENABLED => "true".to_string(), ProtoFlagState::DISABLED => "false".to_string(), }, name: pf.name().to_string(), + container: pf.container().to_string(), + flag_offset: *flag_offsets.get(pf.name()).expect("didnt find package offset :("), device_config_namespace: pf.namespace().to_string(), device_config_flag: codegen::create_device_config_ident(package, pf.name()) .expect("values checked at flag parse time"), - }; - template + } } } @@ -97,6 +107,14 @@ mod tests { const PROD_EXPECTED: &str = r#" //! codegenerated rust flag lib +use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; +use std::path::Path; +use std::io::Write; +use log::{info, error, LevelFilter}; + +static STORAGE_MIGRATION_MARKER_FILE: &str = + "/metadata/aconfig/storage_test_mission_1"; +static MIGRATION_LOG_TAG: &str = "AconfigStorageTestMission1"; /// flag provider pub struct FlagProvider; @@ -492,6 +510,14 @@ pub fn reset_flags() { const EXPORTED_EXPECTED: &str = r#" //! codegenerated rust flag lib +use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; +use std::path::Path; +use std::io::Write; +use log::{info, error, LevelFilter}; + +static STORAGE_MIGRATION_MARKER_FILE: &str = + "/metadata/aconfig/storage_test_mission_1"; +static MIGRATION_LOG_TAG: &str = "AconfigStorageTestMission1"; /// flag provider pub struct FlagProvider; @@ -520,17 +546,20 @@ lazy_static::lazy_static! { impl FlagProvider { /// query flag disabled_rw_exported pub fn disabled_rw_exported(&self) -> bool { - *CACHED_disabled_rw_exported + let result = *CACHED_disabled_rw_exported; + result } /// query flag enabled_fixed_ro_exported pub fn enabled_fixed_ro_exported(&self) -> bool { - *CACHED_enabled_fixed_ro_exported + let result = *CACHED_enabled_fixed_ro_exported; + result } /// query flag enabled_ro_exported pub fn enabled_ro_exported(&self) -> bool { - *CACHED_enabled_ro_exported + let result = *CACHED_enabled_ro_exported; + result } } @@ -558,6 +587,14 @@ pub fn enabled_ro_exported() -> bool { const FORCE_READ_ONLY_EXPECTED: &str = r#" //! codegenerated rust flag lib +use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; +use std::path::Path; +use std::io::Write; +use log::{info, error, LevelFilter}; + +static STORAGE_MIGRATION_MARKER_FILE: &str = + "/metadata/aconfig/storage_test_mission_1"; +static MIGRATION_LOG_TAG: &str = "AconfigStorageTestMission1"; /// flag provider pub struct FlagProvider; @@ -565,32 +602,344 @@ pub struct FlagProvider; impl FlagProvider { /// query flag disabled_ro pub fn disabled_ro(&self) -> bool { - false + let result = false; + + if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + return result; + } + + // This will be called multiple times. Subsequent calls after the first + // are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info), + ); + + unsafe { + let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { + Ok(file) => file, + Err(err) => { + error!("failed to read flag 'disabled_ro': {}", err); + return result; + } + }; + let package_offset = match get_package_offset(&package_map, "com.android.aconfig.test") { + Ok(Some(offset)) => offset, + Ok(None) => { + error!("failed to read flag 'disabled_ro', not found in package map"); + return result; + }, + Err(err) => { + error!("failed to read flag 'disabled_ro': {}", err); + return result; + } + }; + let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { + Ok(val_map) => val_map, + Err(err) => { + error!("failed to read flag 'disabled_ro': {}", err); + return result; + } + }; + let value = match get_boolean_flag_value(&flag_val_map, 0 + package_offset.boolean_offset) { + Ok(val) => val, + Err(err) => { + error!("failed to read flag 'disabled_ro': {}", err); + return result; + } + }; + if false != value { + let default_value = false; + error!("flag mismatch for 'disabled_ro'. Legacy storage was {default_value}, new storage was {value}") + } + } + result } /// query flag disabled_rw pub fn disabled_rw(&self) -> bool { - false + let result = false; + + if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + return result; + } + + // This will be called multiple times. Subsequent calls after the first + // are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info), + ); + + unsafe { + let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { + Ok(file) => file, + Err(err) => { + error!("failed to read flag 'disabled_rw': {}", err); + return result; + } + }; + let package_offset = match get_package_offset(&package_map, "com.android.aconfig.test") { + Ok(Some(offset)) => offset, + Ok(None) => { + error!("failed to read flag 'disabled_rw', not found in package map"); + return result; + }, + Err(err) => { + error!("failed to read flag 'disabled_rw': {}", err); + return result; + } + }; + let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { + Ok(val_map) => val_map, + Err(err) => { + error!("failed to read flag 'disabled_rw': {}", err); + return result; + } + }; + let value = match get_boolean_flag_value(&flag_val_map, 1 + package_offset.boolean_offset) { + Ok(val) => val, + Err(err) => { + error!("failed to read flag 'disabled_rw': {}", err); + return result; + } + }; + if false != value { + let default_value = false; + error!("flag mismatch for 'disabled_rw'. Legacy storage was {default_value}, new storage was {value}") + } + } + result } /// query flag disabled_rw_in_other_namespace pub fn disabled_rw_in_other_namespace(&self) -> bool { - false + let result = false; + + if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + return result; + } + + // This will be called multiple times. Subsequent calls after the first + // are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info), + ); + + unsafe { + let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { + Ok(file) => file, + Err(err) => { + error!("failed to read flag 'disabled_rw_in_other_namespace': {}", err); + return result; + } + }; + let package_offset = match get_package_offset(&package_map, "com.android.aconfig.test") { + Ok(Some(offset)) => offset, + Ok(None) => { + error!("failed to read flag 'disabled_rw_in_other_namespace', not found in package map"); + return result; + }, + Err(err) => { + error!("failed to read flag 'disabled_rw_in_other_namespace': {}", err); + return result; + } + }; + let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { + Ok(val_map) => val_map, + Err(err) => { + error!("failed to read flag 'disabled_rw_in_other_namespace': {}", err); + return result; + } + }; + let value = match get_boolean_flag_value(&flag_val_map, 2 + package_offset.boolean_offset) { + Ok(val) => val, + Err(err) => { + error!("failed to read flag 'disabled_rw_in_other_namespace': {}", err); + return result; + } + }; + if false != value { + let default_value = false; + error!("flag mismatch for 'disabled_rw_in_other_namespace'. Legacy storage was {default_value}, new storage was {value}") + } + } + result } /// query flag enabled_fixed_ro pub fn enabled_fixed_ro(&self) -> bool { - true + let result = true; + + if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + return result; + } + + // This will be called multiple times. Subsequent calls after the first + // are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info), + ); + + unsafe { + let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { + Ok(file) => file, + Err(err) => { + error!("failed to read flag 'enabled_fixed_ro': {}", err); + return result; + } + }; + let package_offset = match get_package_offset(&package_map, "com.android.aconfig.test") { + Ok(Some(offset)) => offset, + Ok(None) => { + error!("failed to read flag 'enabled_fixed_ro', not found in package map"); + return result; + }, + Err(err) => { + error!("failed to read flag 'enabled_fixed_ro': {}", err); + return result; + } + }; + let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { + Ok(val_map) => val_map, + Err(err) => { + error!("failed to read flag 'enabled_fixed_ro': {}", err); + return result; + } + }; + let value = match get_boolean_flag_value(&flag_val_map, 3 + package_offset.boolean_offset) { + Ok(val) => val, + Err(err) => { + error!("failed to read flag 'enabled_fixed_ro': {}", err); + return result; + } + }; + if true != value { + let default_value = true; + error!("flag mismatch for 'enabled_fixed_ro'. Legacy storage was {default_value}, new storage was {value}") + } + } + result } /// query flag enabled_ro pub fn enabled_ro(&self) -> bool { - true + let result = true; + + if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + return result; + } + + // This will be called multiple times. Subsequent calls after the first + // are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info), + ); + + unsafe { + let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { + Ok(file) => file, + Err(err) => { + error!("failed to read flag 'enabled_ro': {}", err); + return result; + } + }; + let package_offset = match get_package_offset(&package_map, "com.android.aconfig.test") { + Ok(Some(offset)) => offset, + Ok(None) => { + error!("failed to read flag 'enabled_ro', not found in package map"); + return result; + }, + Err(err) => { + error!("failed to read flag 'enabled_ro': {}", err); + return result; + } + }; + let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { + Ok(val_map) => val_map, + Err(err) => { + error!("failed to read flag 'enabled_ro': {}", err); + return result; + } + }; + let value = match get_boolean_flag_value(&flag_val_map, 4 + package_offset.boolean_offset) { + Ok(val) => val, + Err(err) => { + error!("failed to read flag 'enabled_ro': {}", err); + return result; + } + }; + if true != value { + let default_value = true; + error!("flag mismatch for 'enabled_ro'. Legacy storage was {default_value}, new storage was {value}") + } + } + result } /// query flag enabled_rw pub fn enabled_rw(&self) -> bool { - true + let result = true; + + if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + return result; + } + + // This will be called multiple times. Subsequent calls after the first + // are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info), + ); + + unsafe { + let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { + Ok(file) => file, + Err(err) => { + error!("failed to read flag 'enabled_rw': {}", err); + return result; + } + }; + let package_offset = match get_package_offset(&package_map, "com.android.aconfig.test") { + Ok(Some(offset)) => offset, + Ok(None) => { + error!("failed to read flag 'enabled_rw', not found in package map"); + return result; + }, + Err(err) => { + error!("failed to read flag 'enabled_rw': {}", err); + return result; + } + }; + let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { + Ok(val_map) => val_map, + Err(err) => { + error!("failed to read flag 'enabled_rw': {}", err); + return result; + } + }; + let value = match get_boolean_flag_value(&flag_val_map, 5 + package_offset.boolean_offset) { + Ok(val) => val, + Err(err) => { + error!("failed to read flag 'enabled_rw': {}", err); + return result; + } + }; + if true != value { + let default_value = true; + error!("flag mismatch for 'enabled_rw'. Legacy storage was {default_value}, new storage was {value}") + } + } + result } } @@ -633,14 +982,22 @@ pub fn enabled_rw() -> bool { true } "#; + use crate::commands::assign_flag_ids; - fn test_generate_rust_code(mode: CodegenMode) { + fn test_generate_rust_code(mode: CodegenMode, instrumentation: bool) { let parsed_flags = crate::test::parse_test_flags(); let modified_parsed_flags = crate::commands::modify_parsed_flags_based_on_mode(parsed_flags, mode).unwrap(); - let generated = - generate_rust_code(crate::test::TEST_PACKAGE, modified_parsed_flags.into_iter(), mode) - .unwrap(); + let flag_ids = + assign_flag_ids(crate::test::TEST_PACKAGE, modified_parsed_flags.iter()).unwrap(); + let generated = generate_rust_code( + crate::test::TEST_PACKAGE, + flag_ids, + modified_parsed_flags.into_iter(), + mode, + instrumentation, + ) + .unwrap(); assert_eq!("src/lib.rs", format!("{}", generated.path.display())); assert_eq!( None, @@ -658,21 +1015,21 @@ pub fn enabled_rw() -> bool { #[test] fn test_generate_rust_code_for_prod() { - test_generate_rust_code(CodegenMode::Production); + test_generate_rust_code(CodegenMode::Production, false); } #[test] fn test_generate_rust_code_for_test() { - test_generate_rust_code(CodegenMode::Test); + test_generate_rust_code(CodegenMode::Test, true); } #[test] fn test_generate_rust_code_for_exported() { - test_generate_rust_code(CodegenMode::Exported); + test_generate_rust_code(CodegenMode::Exported, true); } #[test] fn test_generate_rust_code_for_force_read_only() { - test_generate_rust_code(CodegenMode::ForceReadOnly); + test_generate_rust_code(CodegenMode::ForceReadOnly, true); } } diff --git a/tools/aconfig/aconfig/src/commands.rs b/tools/aconfig/aconfig/src/commands.rs index 7736ce75ee..66bcb82d47 100644 --- a/tools/aconfig/aconfig/src/commands.rs +++ b/tools/aconfig/aconfig/src/commands.rs @@ -218,7 +218,11 @@ pub fn create_cpp_lib(mut input: Input, codegen_mode: CodegenMode) -> Result Result { +pub fn create_rust_lib( + mut input: Input, + codegen_mode: CodegenMode, + allow_instrumentation: bool, +) -> Result { // // TODO(327420679): Enable export mode for native flag library ensure!( codegen_mode != CodegenMode::Exported, @@ -230,8 +234,14 @@ pub fn create_rust_lib(mut input: Input, codegen_mode: CodegenMode) -> Result Command { Command::new("create-rust-lib") .arg(Arg::new("cache").long("cache").required(true)) .arg(Arg::new("out").long("out").required(true)) + .arg( + Arg::new("allow-instrumentation") + .long("allow-instrumentation") + .value_parser(clap::value_parser!(bool)) + .default_value("false"), + ) .arg( Arg::new("mode") .long("mode") @@ -251,8 +257,10 @@ fn main() -> Result<()> { Some(("create-rust-lib", sub_matches)) => { let cache = open_single_file(sub_matches, "cache")?; let mode = get_required_arg::(sub_matches, "mode")?; - let generated_file = - commands::create_rust_lib(cache, *mode).context("failed to create rust lib")?; + let allow_instrumentation = + get_required_arg::(sub_matches, "allow-instrumentation")?; + let generated_file = commands::create_rust_lib(cache, *mode, *allow_instrumentation) + .context("failed to create rust lib")?; let dir = PathBuf::from(get_required_arg::(sub_matches, "out")?); write_output_file_realtive_to_dir(&dir, &generated_file)?; } diff --git a/tools/aconfig/aconfig/templates/rust.template b/tools/aconfig/aconfig/templates/rust.template index f9a2829033..4b1ad835c8 100644 --- a/tools/aconfig/aconfig/templates/rust.template +++ b/tools/aconfig/aconfig/templates/rust.template @@ -1,5 +1,14 @@ //! codegenerated rust flag lib +use aconfig_storage_read_api::\{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; +use std::path::Path; +use std::io::Write; +use log::\{info, error, LevelFilter}; + +static STORAGE_MIGRATION_MARKER_FILE: &str = + "/metadata/aconfig/storage_test_mission_1"; +static MIGRATION_LOG_TAG: &str = "AconfigStorageTestMission1"; + /// flag provider pub struct FlagProvider; @@ -22,11 +31,76 @@ impl FlagProvider \{ {{ for flag in template_flags }} /// query flag {flag.name} pub fn {flag.name}(&self) -> bool \{ - {{ -if flag.readwrite }} + {{ if not allow_instrumentation }} + + {{ -if flag.readwrite }} *CACHED_{flag.name} - {{ -else }} + {{ -else }} {flag.default_value} - {{ -endif }} + {{ -endif }} + + {{ else }} + let result = {{ -if flag.readwrite }} *CACHED_{flag.name}{{ else }} {flag.default_value} {{ -endif }}; + + {{ if flag.readwrite }} + result + {{ else }} + + if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() \{ + return result; + } + + // This will be called multiple times. Subsequent calls after the first + // are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info), + ); + + unsafe \{ + let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) \{ + Ok(file) => file, + Err(err) => \{ + error!("failed to read flag '{flag.name}': \{}", err); + return result; + } + }; + let package_offset = match get_package_offset(&package_map, "{package}") \{ + Ok(Some(offset)) => offset, + Ok(None) => \{ + error!("failed to read flag '{flag.name}', not found in package map"); + return result; + }, + Err(err) => \{ + error!("failed to read flag '{flag.name}': \{}", err); + return result; + } + }; + let flag_val_map = match get_mapped_storage_file("{flag.container}", StorageFileType::FlagVal) \{ + Ok(val_map) => val_map, + Err(err) => \{ + error!("failed to read flag '{flag.name}': \{}", err); + return result; + } + }; + let value = match get_boolean_flag_value(&flag_val_map, {flag.flag_offset} + package_offset.boolean_offset) \{ + Ok(val) => val, + Err(err) => \{ + error!("failed to read flag '{flag.name}': \{}", err); + return result; + } + }; + + if {flag.default_value} != value \{ + let default_value = {flag.default_value}; + error!("flag mismatch for '{flag.name}'. Legacy storage was \{default_value}, new storage was \{value}") + } + } + + result + {{ endif }} + {{ endif }} } {{ endfor }} From c65c7c7f577f4140ff5632ce87a26dc98a75b8dc Mon Sep 17 00:00:00 2001 From: Zhi Dou Date: Tue, 2 Apr 2024 18:49:48 +0000 Subject: [PATCH 24/65] aconfig: prototype AconfigFlagAccessor Bug: n/a Test: atest aconfig.test Ignore-AOSP-First: need to submit with annotation change. will cherry pick to aosp. Change-Id: I62ea458c05fb61973705346c4313535f9b2291be --- tools/aconfig/aconfig/src/codegen/java.rs | 69 +++++++++++++++++-- .../templates/FeatureFlags.java.template | 1 + .../templates/FeatureFlagsImpl.java.template | 2 + .../aconfig/templates/Flags.java.template | 1 + 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/tools/aconfig/aconfig/src/codegen/java.rs b/tools/aconfig/aconfig/src/codegen/java.rs index fab2fa37ba..920d5fac1e 100644 --- a/tools/aconfig/aconfig/src/codegen/java.rs +++ b/tools/aconfig/aconfig/src/codegen/java.rs @@ -180,27 +180,36 @@ mod tests { import android.compat.annotation.UnsupportedAppUsage; /** @hide */ public interface FeatureFlags { + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeFalseForR8 @UnsupportedAppUsage boolean disabledRo(); + @com.android.aconfig.annotations.AconfigFlagAccessor @UnsupportedAppUsage boolean disabledRw(); + @com.android.aconfig.annotations.AconfigFlagAccessor @UnsupportedAppUsage boolean disabledRwExported(); + @com.android.aconfig.annotations.AconfigFlagAccessor @UnsupportedAppUsage boolean disabledRwInOtherNamespace(); + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage boolean enabledFixedRo(); + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage boolean enabledFixedRoExported(); + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage boolean enabledRo(); + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage boolean enabledRoExported(); + @com.android.aconfig.annotations.AconfigFlagAccessor @UnsupportedAppUsage boolean enabledRw(); } @@ -231,43 +240,52 @@ mod tests { /** @hide */ public static final String FLAG_ENABLED_RW = "com.android.aconfig.test.enabled_rw"; + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeFalseForR8 @UnsupportedAppUsage public static boolean disabledRo() { return FEATURE_FLAGS.disabledRo(); } + @com.android.aconfig.annotations.AconfigFlagAccessor @UnsupportedAppUsage public static boolean disabledRw() { return FEATURE_FLAGS.disabledRw(); } + @com.android.aconfig.annotations.AconfigFlagAccessor @UnsupportedAppUsage public static boolean disabledRwExported() { return FEATURE_FLAGS.disabledRwExported(); } + @com.android.aconfig.annotations.AconfigFlagAccessor @UnsupportedAppUsage public static boolean disabledRwInOtherNamespace() { return FEATURE_FLAGS.disabledRwInOtherNamespace(); } + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage public static boolean enabledFixedRo() { return FEATURE_FLAGS.enabledFixedRo(); } + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage public static boolean enabledFixedRoExported() { return FEATURE_FLAGS.enabledFixedRoExported(); } + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage public static boolean enabledRo() { return FEATURE_FLAGS.enabledRo(); } + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage public static boolean enabledRoExported() { return FEATURE_FLAGS.enabledRoExported(); } + @com.android.aconfig.annotations.AconfigFlagAccessor @UnsupportedAppUsage public static boolean enabledRw() { return FEATURE_FLAGS.enabledRw(); @@ -458,12 +476,13 @@ mod tests { other_namespace_is_cached = true; } - + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean disabledRo() { return false; } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean disabledRw() { @@ -472,6 +491,7 @@ mod tests { } return disabledRw; } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean disabledRwExported() { @@ -480,6 +500,7 @@ mod tests { } return disabledRwExported; } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean disabledRwInOtherNamespace() { @@ -488,26 +509,31 @@ mod tests { } return disabledRwInOtherNamespace; } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean enabledFixedRo() { return true; } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean enabledFixedRoExported() { return true; } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean enabledRo() { return true; } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean enabledRoExported() { return true; } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean enabledRw() { @@ -566,13 +592,15 @@ mod tests { public static final String FLAG_ENABLED_FIXED_RO_EXPORTED = "com.android.aconfig.test.enabled_fixed_ro_exported"; /** @hide */ public static final String FLAG_ENABLED_RO_EXPORTED = "com.android.aconfig.test.enabled_ro_exported"; - + @com.android.aconfig.annotations.AconfigFlagAccessor public static boolean disabledRwExported() { return FEATURE_FLAGS.disabledRwExported(); } + @com.android.aconfig.annotations.AconfigFlagAccessor public static boolean enabledFixedRoExported() { return FEATURE_FLAGS.enabledFixedRoExported(); } + @com.android.aconfig.annotations.AconfigFlagAccessor public static boolean enabledRoExported() { return FEATURE_FLAGS.enabledRoExported(); } @@ -584,8 +612,11 @@ mod tests { package com.android.aconfig.test; /** @hide */ public interface FeatureFlags { + @com.android.aconfig.annotations.AconfigFlagAccessor boolean disabledRwExported(); + @com.android.aconfig.annotations.AconfigFlagAccessor boolean enabledFixedRoExported(); + @com.android.aconfig.annotations.AconfigFlagAccessor boolean enabledRoExported(); } "#; @@ -623,7 +654,7 @@ mod tests { } aconfig_test_is_cached = true; } - + @com.android.aconfig.annotations.AconfigFlagAccessor @Override public boolean disabledRwExported() { if (!aconfig_test_is_cached) { @@ -631,7 +662,7 @@ mod tests { } return disabledRwExported; } - + @com.android.aconfig.annotations.AconfigFlagAccessor @Override public boolean enabledFixedRoExported() { if (!aconfig_test_is_cached) { @@ -639,7 +670,7 @@ mod tests { } return enabledFixedRoExported; } - + @com.android.aconfig.annotations.AconfigFlagAccessor @Override public boolean enabledRoExported() { if (!aconfig_test_is_cached) { @@ -761,54 +792,63 @@ mod tests { import android.compat.annotation.UnsupportedAppUsage; /** @hide */ public final class FeatureFlagsImpl implements FeatureFlags { + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean disabledRo() { throw new UnsupportedOperationException( "Method is not implemented."); } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean disabledRw() { throw new UnsupportedOperationException( "Method is not implemented."); } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean disabledRwExported() { throw new UnsupportedOperationException( "Method is not implemented."); } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean disabledRwInOtherNamespace() { throw new UnsupportedOperationException( "Method is not implemented."); } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean enabledFixedRo() { throw new UnsupportedOperationException( "Method is not implemented."); } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean enabledFixedRoExported() { throw new UnsupportedOperationException( "Method is not implemented."); } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean enabledRo() { throw new UnsupportedOperationException( "Method is not implemented."); } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean enabledRoExported() { throw new UnsupportedOperationException( "Method is not implemented."); } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean enabledRw() { @@ -861,21 +901,27 @@ mod tests { import android.compat.annotation.UnsupportedAppUsage; /** @hide */ public interface FeatureFlags { + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeFalseForR8 @UnsupportedAppUsage boolean disabledRo(); + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeFalseForR8 @UnsupportedAppUsage boolean disabledRw(); + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeFalseForR8 @UnsupportedAppUsage boolean disabledRwInOtherNamespace(); + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage boolean enabledFixedRo(); + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage boolean enabledRo(); + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage boolean enabledRw(); @@ -887,31 +933,37 @@ mod tests { import android.compat.annotation.UnsupportedAppUsage; /** @hide */ public final class FeatureFlagsImpl implements FeatureFlags { + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean disabledRo() { return false; } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean disabledRw() { return false; } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean disabledRwInOtherNamespace() { return false; } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean enabledFixedRo() { return true; } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean enabledRo() { return true; } + @com.android.aconfig.annotations.AconfigFlagAccessor @Override @UnsupportedAppUsage public boolean enabledRw() { @@ -938,32 +990,37 @@ mod tests { public static final String FLAG_ENABLED_RO = "com.android.aconfig.test.enabled_ro"; /** @hide */ public static final String FLAG_ENABLED_RW = "com.android.aconfig.test.enabled_rw"; - + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeFalseForR8 @UnsupportedAppUsage public static boolean disabledRo() { return FEATURE_FLAGS.disabledRo(); } + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeFalseForR8 @UnsupportedAppUsage public static boolean disabledRw() { return FEATURE_FLAGS.disabledRw(); } + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeFalseForR8 @UnsupportedAppUsage public static boolean disabledRwInOtherNamespace() { return FEATURE_FLAGS.disabledRwInOtherNamespace(); } + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage public static boolean enabledFixedRo() { return FEATURE_FLAGS.enabledFixedRo(); } + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage public static boolean enabledRo() { return FEATURE_FLAGS.enabledRo(); } + @com.android.aconfig.annotations.AconfigFlagAccessor @com.android.aconfig.annotations.AssumeTrueForR8 @UnsupportedAppUsage public static boolean enabledRw() { diff --git a/tools/aconfig/aconfig/templates/FeatureFlags.java.template b/tools/aconfig/aconfig/templates/FeatureFlags.java.template index 13edcb4e52..b90b201ebf 100644 --- a/tools/aconfig/aconfig/templates/FeatureFlags.java.template +++ b/tools/aconfig/aconfig/templates/FeatureFlags.java.template @@ -6,6 +6,7 @@ import android.compat.annotation.UnsupportedAppUsage; /** @hide */ public interface FeatureFlags \{ {{ for item in flag_elements }} + @com.android.aconfig.annotations.AconfigFlagAccessor {{ -if not item.is_read_write }} {{ -if item.default_value }} @com.android.aconfig.annotations.AssumeTrueForR8 diff --git a/tools/aconfig/aconfig/templates/FeatureFlagsImpl.java.template b/tools/aconfig/aconfig/templates/FeatureFlagsImpl.java.template index 12b2fc1ddd..704f25bb75 100644 --- a/tools/aconfig/aconfig/templates/FeatureFlagsImpl.java.template +++ b/tools/aconfig/aconfig/templates/FeatureFlagsImpl.java.template @@ -45,6 +45,7 @@ public final class FeatureFlagsImpl implements FeatureFlags \{ {{ endfor- }} {{ -endif }}{#- end of runtime_lookup_required #} {{ -for flag in flag_elements }} + @com.android.aconfig.annotations.AconfigFlagAccessor @Override {{ -if not library_exported }} @UnsupportedAppUsage @@ -66,6 +67,7 @@ public final class FeatureFlagsImpl implements FeatureFlags \{ /** @hide */ public final class FeatureFlagsImpl implements FeatureFlags \{ {{ for flag in flag_elements }} + @com.android.aconfig.annotations.AconfigFlagAccessor @Override {{ -if not library_exported }} @UnsupportedAppUsage diff --git a/tools/aconfig/aconfig/templates/Flags.java.template b/tools/aconfig/aconfig/templates/Flags.java.template index e105991369..55db924595 100644 --- a/tools/aconfig/aconfig/templates/Flags.java.template +++ b/tools/aconfig/aconfig/templates/Flags.java.template @@ -10,6 +10,7 @@ public final class Flags \{ public static final String FLAG_{item.flag_name_constant_suffix} = "{item.device_config_flag}"; {{- endfor }} {{ -for item in flag_elements}} + @com.android.aconfig.annotations.AconfigFlagAccessor {{ -if not item.is_read_write }} {{ -if item.default_value }} @com.android.aconfig.annotations.AssumeTrueForR8 From 86bacb36f4f406f5c55d22bba7a6b95cfdc6e92b Mon Sep 17 00:00:00 2001 From: Ted Bauer Date: Wed, 3 Apr 2024 17:07:08 +0000 Subject: [PATCH 25/65] aconfig: instrument actual flag read APIs The logging instrumentation for the storage migration contained a bug; we want to instrument the actual flag read APIs, not the FlagProvider. Bug: 328444881 Test: m Change-Id: I6973ccf69005e812ac443ac5e7e14293db7b0845 Ignore-AOSP-First: internal storage migration, this code will be deleted --- tools/aconfig/aconfig/src/codegen/rust.rs | 345 +----------------- tools/aconfig/aconfig/templates/rust.template | 127 ++++--- 2 files changed, 76 insertions(+), 396 deletions(-) diff --git a/tools/aconfig/aconfig/src/codegen/rust.rs b/tools/aconfig/aconfig/src/codegen/rust.rs index 591781e081..604259386f 100644 --- a/tools/aconfig/aconfig/src/codegen/rust.rs +++ b/tools/aconfig/aconfig/src/codegen/rust.rs @@ -114,7 +114,7 @@ use log::{info, error, LevelFilter}; static STORAGE_MIGRATION_MARKER_FILE: &str = "/metadata/aconfig/storage_test_mission_1"; -static MIGRATION_LOG_TAG: &str = "AconfigStorageTestMission1"; +static MIGRATION_LOG_TAG: &str = "AconfigTestMission1"; /// flag provider pub struct FlagProvider; @@ -517,7 +517,7 @@ use log::{info, error, LevelFilter}; static STORAGE_MIGRATION_MARKER_FILE: &str = "/metadata/aconfig/storage_test_mission_1"; -static MIGRATION_LOG_TAG: &str = "AconfigStorageTestMission1"; +static MIGRATION_LOG_TAG: &str = "AconfigTestMission1"; /// flag provider pub struct FlagProvider; @@ -546,20 +546,17 @@ lazy_static::lazy_static! { impl FlagProvider { /// query flag disabled_rw_exported pub fn disabled_rw_exported(&self) -> bool { - let result = *CACHED_disabled_rw_exported; - result + *CACHED_disabled_rw_exported } /// query flag enabled_fixed_ro_exported pub fn enabled_fixed_ro_exported(&self) -> bool { - let result = *CACHED_enabled_fixed_ro_exported; - result + *CACHED_enabled_fixed_ro_exported } /// query flag enabled_ro_exported pub fn enabled_ro_exported(&self) -> bool { - let result = *CACHED_enabled_ro_exported; - result + *CACHED_enabled_ro_exported } } @@ -594,7 +591,7 @@ use log::{info, error, LevelFilter}; static STORAGE_MIGRATION_MARKER_FILE: &str = "/metadata/aconfig/storage_test_mission_1"; -static MIGRATION_LOG_TAG: &str = "AconfigStorageTestMission1"; +static MIGRATION_LOG_TAG: &str = "AconfigTestMission1"; /// flag provider pub struct FlagProvider; @@ -602,344 +599,32 @@ pub struct FlagProvider; impl FlagProvider { /// query flag disabled_ro pub fn disabled_ro(&self) -> bool { - let result = false; - - if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { - return result; - } - - // This will be called multiple times. Subsequent calls after the first - // are noops. - logger::init( - logger::Config::default() - .with_tag_on_device(MIGRATION_LOG_TAG) - .with_max_level(LevelFilter::Info), - ); - - unsafe { - let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { - Ok(file) => file, - Err(err) => { - error!("failed to read flag 'disabled_ro': {}", err); - return result; - } - }; - let package_offset = match get_package_offset(&package_map, "com.android.aconfig.test") { - Ok(Some(offset)) => offset, - Ok(None) => { - error!("failed to read flag 'disabled_ro', not found in package map"); - return result; - }, - Err(err) => { - error!("failed to read flag 'disabled_ro': {}", err); - return result; - } - }; - let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { - Ok(val_map) => val_map, - Err(err) => { - error!("failed to read flag 'disabled_ro': {}", err); - return result; - } - }; - let value = match get_boolean_flag_value(&flag_val_map, 0 + package_offset.boolean_offset) { - Ok(val) => val, - Err(err) => { - error!("failed to read flag 'disabled_ro': {}", err); - return result; - } - }; - if false != value { - let default_value = false; - error!("flag mismatch for 'disabled_ro'. Legacy storage was {default_value}, new storage was {value}") - } - } - result + false } /// query flag disabled_rw pub fn disabled_rw(&self) -> bool { - let result = false; - - if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { - return result; - } - - // This will be called multiple times. Subsequent calls after the first - // are noops. - logger::init( - logger::Config::default() - .with_tag_on_device(MIGRATION_LOG_TAG) - .with_max_level(LevelFilter::Info), - ); - - unsafe { - let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { - Ok(file) => file, - Err(err) => { - error!("failed to read flag 'disabled_rw': {}", err); - return result; - } - }; - let package_offset = match get_package_offset(&package_map, "com.android.aconfig.test") { - Ok(Some(offset)) => offset, - Ok(None) => { - error!("failed to read flag 'disabled_rw', not found in package map"); - return result; - }, - Err(err) => { - error!("failed to read flag 'disabled_rw': {}", err); - return result; - } - }; - let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { - Ok(val_map) => val_map, - Err(err) => { - error!("failed to read flag 'disabled_rw': {}", err); - return result; - } - }; - let value = match get_boolean_flag_value(&flag_val_map, 1 + package_offset.boolean_offset) { - Ok(val) => val, - Err(err) => { - error!("failed to read flag 'disabled_rw': {}", err); - return result; - } - }; - if false != value { - let default_value = false; - error!("flag mismatch for 'disabled_rw'. Legacy storage was {default_value}, new storage was {value}") - } - } - result + false } /// query flag disabled_rw_in_other_namespace pub fn disabled_rw_in_other_namespace(&self) -> bool { - let result = false; - - if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { - return result; - } - - // This will be called multiple times. Subsequent calls after the first - // are noops. - logger::init( - logger::Config::default() - .with_tag_on_device(MIGRATION_LOG_TAG) - .with_max_level(LevelFilter::Info), - ); - - unsafe { - let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { - Ok(file) => file, - Err(err) => { - error!("failed to read flag 'disabled_rw_in_other_namespace': {}", err); - return result; - } - }; - let package_offset = match get_package_offset(&package_map, "com.android.aconfig.test") { - Ok(Some(offset)) => offset, - Ok(None) => { - error!("failed to read flag 'disabled_rw_in_other_namespace', not found in package map"); - return result; - }, - Err(err) => { - error!("failed to read flag 'disabled_rw_in_other_namespace': {}", err); - return result; - } - }; - let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { - Ok(val_map) => val_map, - Err(err) => { - error!("failed to read flag 'disabled_rw_in_other_namespace': {}", err); - return result; - } - }; - let value = match get_boolean_flag_value(&flag_val_map, 2 + package_offset.boolean_offset) { - Ok(val) => val, - Err(err) => { - error!("failed to read flag 'disabled_rw_in_other_namespace': {}", err); - return result; - } - }; - if false != value { - let default_value = false; - error!("flag mismatch for 'disabled_rw_in_other_namespace'. Legacy storage was {default_value}, new storage was {value}") - } - } - result + false } /// query flag enabled_fixed_ro pub fn enabled_fixed_ro(&self) -> bool { - let result = true; - - if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { - return result; - } - - // This will be called multiple times. Subsequent calls after the first - // are noops. - logger::init( - logger::Config::default() - .with_tag_on_device(MIGRATION_LOG_TAG) - .with_max_level(LevelFilter::Info), - ); - - unsafe { - let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { - Ok(file) => file, - Err(err) => { - error!("failed to read flag 'enabled_fixed_ro': {}", err); - return result; - } - }; - let package_offset = match get_package_offset(&package_map, "com.android.aconfig.test") { - Ok(Some(offset)) => offset, - Ok(None) => { - error!("failed to read flag 'enabled_fixed_ro', not found in package map"); - return result; - }, - Err(err) => { - error!("failed to read flag 'enabled_fixed_ro': {}", err); - return result; - } - }; - let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { - Ok(val_map) => val_map, - Err(err) => { - error!("failed to read flag 'enabled_fixed_ro': {}", err); - return result; - } - }; - let value = match get_boolean_flag_value(&flag_val_map, 3 + package_offset.boolean_offset) { - Ok(val) => val, - Err(err) => { - error!("failed to read flag 'enabled_fixed_ro': {}", err); - return result; - } - }; - if true != value { - let default_value = true; - error!("flag mismatch for 'enabled_fixed_ro'. Legacy storage was {default_value}, new storage was {value}") - } - } - result + true } /// query flag enabled_ro pub fn enabled_ro(&self) -> bool { - let result = true; - - if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { - return result; - } - - // This will be called multiple times. Subsequent calls after the first - // are noops. - logger::init( - logger::Config::default() - .with_tag_on_device(MIGRATION_LOG_TAG) - .with_max_level(LevelFilter::Info), - ); - - unsafe { - let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { - Ok(file) => file, - Err(err) => { - error!("failed to read flag 'enabled_ro': {}", err); - return result; - } - }; - let package_offset = match get_package_offset(&package_map, "com.android.aconfig.test") { - Ok(Some(offset)) => offset, - Ok(None) => { - error!("failed to read flag 'enabled_ro', not found in package map"); - return result; - }, - Err(err) => { - error!("failed to read flag 'enabled_ro': {}", err); - return result; - } - }; - let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { - Ok(val_map) => val_map, - Err(err) => { - error!("failed to read flag 'enabled_ro': {}", err); - return result; - } - }; - let value = match get_boolean_flag_value(&flag_val_map, 4 + package_offset.boolean_offset) { - Ok(val) => val, - Err(err) => { - error!("failed to read flag 'enabled_ro': {}", err); - return result; - } - }; - if true != value { - let default_value = true; - error!("flag mismatch for 'enabled_ro'. Legacy storage was {default_value}, new storage was {value}") - } - } - result + true } /// query flag enabled_rw pub fn enabled_rw(&self) -> bool { - let result = true; - - if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { - return result; - } - - // This will be called multiple times. Subsequent calls after the first - // are noops. - logger::init( - logger::Config::default() - .with_tag_on_device(MIGRATION_LOG_TAG) - .with_max_level(LevelFilter::Info), - ); - - unsafe { - let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { - Ok(file) => file, - Err(err) => { - error!("failed to read flag 'enabled_rw': {}", err); - return result; - } - }; - let package_offset = match get_package_offset(&package_map, "com.android.aconfig.test") { - Ok(Some(offset)) => offset, - Ok(None) => { - error!("failed to read flag 'enabled_rw', not found in package map"); - return result; - }, - Err(err) => { - error!("failed to read flag 'enabled_rw': {}", err); - return result; - } - }; - let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { - Ok(val_map) => val_map, - Err(err) => { - error!("failed to read flag 'enabled_rw': {}", err); - return result; - } - }; - let value = match get_boolean_flag_value(&flag_val_map, 5 + package_offset.boolean_offset) { - Ok(val) => val, - Err(err) => { - error!("failed to read flag 'enabled_rw': {}", err); - return result; - } - }; - if true != value { - let default_value = true; - error!("flag mismatch for 'enabled_rw'. Legacy storage was {default_value}, new storage was {value}") - } - } - result + true } } @@ -1020,16 +705,16 @@ pub fn enabled_rw() -> bool { #[test] fn test_generate_rust_code_for_test() { - test_generate_rust_code(CodegenMode::Test, true); + test_generate_rust_code(CodegenMode::Test, false); } #[test] fn test_generate_rust_code_for_exported() { - test_generate_rust_code(CodegenMode::Exported, true); + test_generate_rust_code(CodegenMode::Exported, false); } #[test] fn test_generate_rust_code_for_force_read_only() { - test_generate_rust_code(CodegenMode::ForceReadOnly, true); + test_generate_rust_code(CodegenMode::ForceReadOnly, false); } } diff --git a/tools/aconfig/aconfig/templates/rust.template b/tools/aconfig/aconfig/templates/rust.template index 4b1ad835c8..fe07ac5488 100644 --- a/tools/aconfig/aconfig/templates/rust.template +++ b/tools/aconfig/aconfig/templates/rust.template @@ -7,7 +7,7 @@ use log::\{info, error, LevelFilter}; static STORAGE_MIGRATION_MARKER_FILE: &str = "/metadata/aconfig/storage_test_mission_1"; -static MIGRATION_LOG_TAG: &str = "AconfigStorageTestMission1"; +static MIGRATION_LOG_TAG: &str = "AconfigTestMission1"; /// flag provider pub struct FlagProvider; @@ -31,76 +31,11 @@ impl FlagProvider \{ {{ for flag in template_flags }} /// query flag {flag.name} pub fn {flag.name}(&self) -> bool \{ - {{ if not allow_instrumentation }} - {{ -if flag.readwrite }} *CACHED_{flag.name} {{ -else }} {flag.default_value} {{ -endif }} - - {{ else }} - let result = {{ -if flag.readwrite }} *CACHED_{flag.name}{{ else }} {flag.default_value} {{ -endif }}; - - {{ if flag.readwrite }} - result - {{ else }} - - if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() \{ - return result; - } - - // This will be called multiple times. Subsequent calls after the first - // are noops. - logger::init( - logger::Config::default() - .with_tag_on_device(MIGRATION_LOG_TAG) - .with_max_level(LevelFilter::Info), - ); - - unsafe \{ - let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) \{ - Ok(file) => file, - Err(err) => \{ - error!("failed to read flag '{flag.name}': \{}", err); - return result; - } - }; - let package_offset = match get_package_offset(&package_map, "{package}") \{ - Ok(Some(offset)) => offset, - Ok(None) => \{ - error!("failed to read flag '{flag.name}', not found in package map"); - return result; - }, - Err(err) => \{ - error!("failed to read flag '{flag.name}': \{}", err); - return result; - } - }; - let flag_val_map = match get_mapped_storage_file("{flag.container}", StorageFileType::FlagVal) \{ - Ok(val_map) => val_map, - Err(err) => \{ - error!("failed to read flag '{flag.name}': \{}", err); - return result; - } - }; - let value = match get_boolean_flag_value(&flag_val_map, {flag.flag_offset} + package_offset.boolean_offset) \{ - Ok(val) => val, - Err(err) => \{ - error!("failed to read flag '{flag.name}': \{}", err); - return result; - } - }; - - if {flag.default_value} != value \{ - let default_value = {flag.default_value}; - error!("flag mismatch for '{flag.name}'. Legacy storage was \{default_value}, new storage was \{value}") - } - } - - result - {{ endif }} - {{ endif }} } {{ endfor }} @@ -117,7 +52,67 @@ pub fn {flag.name}() -> bool \{ PROVIDER.{flag.name}() {{ -else }} pub fn {flag.name}() -> bool \{ + {{ if not allow_instrumentation }} {flag.default_value} + {{ else }} + + let result = {flag.default_value}; + if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() \{ + return result; + } + + // This will be called multiple times. Subsequent calls after the first + // are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info), + ); + + unsafe \{ + let package_map = match get_mapped_storage_file("{flag.container}", StorageFileType::PackageMap) \{ + Ok(file) => file, + Err(err) => \{ + error!("failed to read flag '{flag.name}': \{}", err); + return result; + } + }; + let package_offset = match get_package_offset(&package_map, "{package}") \{ + Ok(Some(offset)) => offset, + Ok(None) => \{ + error!("failed to read flag '{flag.name}', not found in package map"); + return result; + }, + Err(err) => \{ + error!("failed to read flag '{flag.name}': \{}", err); + return result; + } + }; + let flag_val_map = match get_mapped_storage_file("{flag.container}", StorageFileType::FlagVal) \{ + Ok(val_map) => val_map, + Err(err) => \{ + error!("failed to read flag '{flag.name}': \{}", err); + return result; + } + }; + let value = match get_boolean_flag_value(&flag_val_map, {flag.flag_offset} + package_offset.boolean_offset) \{ + Ok(val) => val, + Err(err) => \{ + error!("failed to read flag '{flag.name}': \{}", err); + return result; + } + }; + + if result != value \{ + error!("error: flag mismatch for '{flag.name}'. Legacy storage was \{result}, new storage was \{value}") + } else \{ + let default_value = {flag.default_value}; + info!("success! flag '{flag.name}' contained correct value. Legacy storage was \{default_value}, new storage was \{value}") + } + } + + result + {{ endif }} {{ -endif }} } {{ endfor }} From e851b8f7491d2a4599b67ee9b8b4c4550f3efc3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Thu, 4 Apr 2024 09:47:29 +0200 Subject: [PATCH 26/65] finalization: step-*.sh: optionally skip `repo upload` Teach the step-*.sh scripts to parse command line options. Add support for --dry-run, which will skip the part where the CLs are uploaded: useful for local experiments. Bug: 323940469 Test: croot && build/tools/finalization/step-1.sh --dry-run # verify no CLs uploaded Ignore-AOSP-first: VIC finalization happens outside AOSP Change-Id: Ia58da02ae7a69c24f8332c90d1c779884e3a1dab --- tools/finalization/command-line-options.sh | 8 ++++++++ tools/finalization/step-0.sh | 5 +++-- tools/finalization/step-1.sh | 5 +++-- tools/finalization/step-2.sh | 5 +++-- 4 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 tools/finalization/command-line-options.sh diff --git a/tools/finalization/command-line-options.sh b/tools/finalization/command-line-options.sh new file mode 100644 index 0000000000..1c5df46cbb --- /dev/null +++ b/tools/finalization/command-line-options.sh @@ -0,0 +1,8 @@ +ARGV=$(getopt --options '' --long dry-run -- "$@") +eval set -- "$ARGV" +while true; do + case "$1" in + --dry-run) repo_upload_dry_run_arg="--dry-run"; shift ;; + *) break + esac +done diff --git a/tools/finalization/step-0.sh b/tools/finalization/step-0.sh index e61c644de0..8da866c0dc 100755 --- a/tools/finalization/step-0.sh +++ b/tools/finalization/step-0.sh @@ -15,12 +15,13 @@ function commit_step_0_changes() { -m "Ignore-AOSP-First: VINTF $FINAL_BOARD_API_LEVEL Finalization Bug: $FINAL_BUG_ID Test: build"; - repo upload --cbr --no-verify -o nokeycheck -t -y . ; + repo upload '"$repo_upload_dry_run_arg"' --cbr --no-verify -o nokeycheck -t -y . ; fi' } function finalize_step_0_main() { local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/command-line-options.sh source $top/build/make/tools/finalization/environment.sh local m="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" @@ -34,4 +35,4 @@ function finalize_step_0_main() { AIDL_FROZEN_REL=true $m } -finalize_step_0_main +finalize_step_0_main $@ diff --git a/tools/finalization/step-1.sh b/tools/finalization/step-1.sh index abfd3b8d3a..ea947b95a6 100755 --- a/tools/finalization/step-1.sh +++ b/tools/finalization/step-1.sh @@ -13,12 +13,13 @@ function commit_step_1_changes() { -m "Ignore-AOSP-First: $FINAL_PLATFORM_CODENAME Finalization Bug: $FINAL_BUG_ID Test: build"; - repo upload --cbr --no-verify -o nokeycheck -t -y . ; + repo upload '"$repo_upload_dry_run_arg"' --cbr --no-verify -o nokeycheck -t -y . ; fi' } function finalize_step_1_main() { local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/command-line-options.sh source $top/build/make/tools/finalization/environment.sh source $top/build/make/tools/finalization/finalize-sdk-resources.sh @@ -34,4 +35,4 @@ function finalize_step_1_main() { AIDL_FROZEN_REL=true $m_fina } -finalize_step_1_main +finalize_step_1_main $@ diff --git a/tools/finalization/step-2.sh b/tools/finalization/step-2.sh index c23f3737ab..d07989e888 100755 --- a/tools/finalization/step-2.sh +++ b/tools/finalization/step-2.sh @@ -11,12 +11,13 @@ function commit_step_2_changes() { Bug: $FINAL_BUG_ID Test: build"; - repo upload --cbr --no-verify -o nokeycheck -t -y . ; + repo upload '"$repo_upload_dry_run_arg"' --cbr --no-verify -o nokeycheck -t -y . ; fi' } function finalize_step_2_main() { local top="$(dirname "$0")"/../../../.. + source $top/build/make/tools/finalization/command-line-options.sh source $top/build/make/tools/finalization/environment.sh # prebuilts etc @@ -33,4 +34,4 @@ function finalize_step_2_main() { AIDL_FROZEN_REL=true $m_fina } -finalize_step_2_main +finalize_step_2_main $@ From 514d5228a2dd88c2e166597682801c0e16673533 Mon Sep 17 00:00:00 2001 From: Ted Bauer Date: Wed, 3 Apr 2024 20:18:57 +0000 Subject: [PATCH 27/65] Add common prefix for logging new storage reads Bug: 328444881 Test: m Change-Id: I93e9d43811bd4d93451c4e4da46474cd93986c63 --- tools/aconfig/aconfig/src/codegen/rust.rs | 6 +++--- tools/aconfig/aconfig/templates/rust.template | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/aconfig/aconfig/src/codegen/rust.rs b/tools/aconfig/aconfig/src/codegen/rust.rs index 604259386f..ec1784a867 100644 --- a/tools/aconfig/aconfig/src/codegen/rust.rs +++ b/tools/aconfig/aconfig/src/codegen/rust.rs @@ -110,7 +110,7 @@ mod tests { use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; use std::path::Path; use std::io::Write; -use log::{info, error, LevelFilter}; +use log::{log, LevelFilter, Level}; static STORAGE_MIGRATION_MARKER_FILE: &str = "/metadata/aconfig/storage_test_mission_1"; @@ -513,7 +513,7 @@ pub fn reset_flags() { use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; use std::path::Path; use std::io::Write; -use log::{info, error, LevelFilter}; +use log::{log, LevelFilter, Level}; static STORAGE_MIGRATION_MARKER_FILE: &str = "/metadata/aconfig/storage_test_mission_1"; @@ -587,7 +587,7 @@ pub fn enabled_ro_exported() -> bool { use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; use std::path::Path; use std::io::Write; -use log::{info, error, LevelFilter}; +use log::{log, LevelFilter, Level}; static STORAGE_MIGRATION_MARKER_FILE: &str = "/metadata/aconfig/storage_test_mission_1"; diff --git a/tools/aconfig/aconfig/templates/rust.template b/tools/aconfig/aconfig/templates/rust.template index fe07ac5488..766fee9e68 100644 --- a/tools/aconfig/aconfig/templates/rust.template +++ b/tools/aconfig/aconfig/templates/rust.template @@ -3,7 +3,7 @@ use aconfig_storage_read_api::\{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; use std::path::Path; use std::io::Write; -use log::\{info, error, LevelFilter}; +use log::\{log, LevelFilter, Level}; static STORAGE_MIGRATION_MARKER_FILE: &str = "/metadata/aconfig/storage_test_mission_1"; @@ -73,41 +73,41 @@ pub fn {flag.name}() -> bool \{ let package_map = match get_mapped_storage_file("{flag.container}", StorageFileType::PackageMap) \{ Ok(file) => file, Err(err) => \{ - error!("failed to read flag '{flag.name}': \{}", err); + log!(Level::Error, "AconfigTestMission1: error: failed to read flag '{flag.name}': \{err}"); return result; } }; let package_offset = match get_package_offset(&package_map, "{package}") \{ Ok(Some(offset)) => offset, Ok(None) => \{ - error!("failed to read flag '{flag.name}', not found in package map"); + log!(Level::Error, "AconfigTestMission1: error: failed to read flag '{flag.name}': did not find offset"); return result; }, Err(err) => \{ - error!("failed to read flag '{flag.name}': \{}", err); + log!(Level::Error, "AconfigTestMission1: error: failed to read flag '{flag.name}': \{err}"); return result; } }; let flag_val_map = match get_mapped_storage_file("{flag.container}", StorageFileType::FlagVal) \{ Ok(val_map) => val_map, Err(err) => \{ - error!("failed to read flag '{flag.name}': \{}", err); + log!(Level::Error, "AconfigTestMission1: error: failed to read flag '{flag.name}': \{err}"); return result; } }; let value = match get_boolean_flag_value(&flag_val_map, {flag.flag_offset} + package_offset.boolean_offset) \{ Ok(val) => val, Err(err) => \{ - error!("failed to read flag '{flag.name}': \{}", err); + log!(Level::Error, "AconfigTestMission1: error: failed to read flag '{flag.name}': \{err}"); return result; } }; if result != value \{ - error!("error: flag mismatch for '{flag.name}'. Legacy storage was \{result}, new storage was \{value}") + log!(Level::Error, "AconfigTestMission1: error: flag mismatch for '{flag.name}'. Legacy storage was \{result}, new storage was \{value}"); } else \{ let default_value = {flag.default_value}; - info!("success! flag '{flag.name}' contained correct value. Legacy storage was \{default_value}, new storage was \{value}") + log!(Level::Info, "AconfigTestMission1: success! flag '{flag.name}' contained correct value. Legacy storage was \{default_value}, new storage was \{value}"); } } From 920037c8d2bf9fbf8bd4e78a47aefc75dc1436e2 Mon Sep 17 00:00:00 2001 From: Devin Moore Date: Fri, 5 Apr 2024 15:32:38 +0000 Subject: [PATCH 28/65] Remove AIDL_FROZEN_REL from step-1/step-2 finalization That variable is used to ensure all VINTF interfaces are frozen and is needed for vFRC/VINTF finalization is step-0. Since SDK finalization (step-1 and step-2) are done at a different time, they shouldn't care about unfrozen VINTF interfaces. Ignore-AOSP-First: b/304316873#comment10 Test: na Bug: 333039895 Change-Id: Ica6807599d5b18078ecea96d939e147d4785749e --- tools/finalization/build-step-1-and-m.sh | 3 +-- tools/finalization/dryrun-step-1-and-2.sh | 4 ++-- tools/finalization/dryrun-step-1.sh | 4 ++-- tools/finalization/step-1.sh | 4 ++-- tools/finalization/step-2.sh | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tools/finalization/build-step-1-and-m.sh b/tools/finalization/build-step-1-and-m.sh index 0e7129f342..88bb3474d2 100755 --- a/tools/finalization/build-step-1-and-m.sh +++ b/tools/finalization/build-step-1-and-m.sh @@ -9,10 +9,9 @@ function finalize_main_step1_and_m() { local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" # This command tests: - # The release state for AIDL. # ABI difference between user and userdebug builds. # Resource/SDK finalization. - AIDL_FROZEN_REL=true $m + $m } finalize_main_step1_and_m diff --git a/tools/finalization/dryrun-step-1-and-2.sh b/tools/finalization/dryrun-step-1-and-2.sh index 38fdb0595b..f883bca673 100755 --- a/tools/finalization/dryrun-step-1-and-2.sh +++ b/tools/finalization/dryrun-step-1-and-2.sh @@ -30,10 +30,10 @@ function finalize_step_2_main() { # build to confirm everything is OK local m_next="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - AIDL_FROZEN_REL=true $m_next + $m_next local m_fina="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=fina_2 TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - AIDL_FROZEN_REL=true $m_fina + $m_fina } finalize_step_2_main diff --git a/tools/finalization/dryrun-step-1.sh b/tools/finalization/dryrun-step-1.sh index d8893953ab..0f2bc635a0 100755 --- a/tools/finalization/dryrun-step-1.sh +++ b/tools/finalization/dryrun-step-1.sh @@ -26,10 +26,10 @@ function finalize_step_1_main() { # build to confirm everything is OK local m_next="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - AIDL_FROZEN_REL=true $m_next + $m_next local m_fina="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=fina_1 TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - AIDL_FROZEN_REL=true $m_fina + $m_fina } finalize_step_1_main diff --git a/tools/finalization/step-1.sh b/tools/finalization/step-1.sh index ea947b95a6..adc917e8de 100755 --- a/tools/finalization/step-1.sh +++ b/tools/finalization/step-1.sh @@ -29,10 +29,10 @@ function finalize_step_1_main() { # build to confirm everything is OK local m_next="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - AIDL_FROZEN_REL=true $m_next + $m_next local m_fina="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=fina_1 TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - AIDL_FROZEN_REL=true $m_fina + $m_fina } finalize_step_1_main $@ diff --git a/tools/finalization/step-2.sh b/tools/finalization/step-2.sh index d07989e888..862c8f5217 100755 --- a/tools/finalization/step-2.sh +++ b/tools/finalization/step-2.sh @@ -28,10 +28,10 @@ function finalize_step_2_main() { # build to confirm everything is OK local m_next="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - AIDL_FROZEN_REL=true $m_next + $m_next local m_fina="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=fina_2 TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" - AIDL_FROZEN_REL=true $m_fina + $m_fina } finalize_step_2_main $@ From 6c6a1b5b8e9c51f984b965ad659ac5c967c8e0ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Mon, 8 Apr 2024 16:18:47 +0200 Subject: [PATCH 29/65] finalization: use same repo branch during dry-run Teach step-*.sh to re-use the same branch name if running in dry-run mode. This is useful for running the steps sequentially: if using different branch names, each 'repo start' will undo the changes created during the previous step-*.sh. Bug: 323940469 Test: croot && build/tools/finalization/step-1.sh --dry-run && build/tools/finalization/step-2.sh --dry-run Ignore-AOSP-first: VIC finalization happens outside AOSP Change-Id: I720f294f6abf5a8b276bb30f8c531fcbea749b76 --- tools/finalization/command-line-options.sh | 2 +- tools/finalization/step-0.sh | 5 +++-- tools/finalization/step-1.sh | 5 +++-- tools/finalization/step-2.sh | 5 +++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/finalization/command-line-options.sh b/tools/finalization/command-line-options.sh index 1c5df46cbb..d9397c2699 100644 --- a/tools/finalization/command-line-options.sh +++ b/tools/finalization/command-line-options.sh @@ -2,7 +2,7 @@ ARGV=$(getopt --options '' --long dry-run -- "$@") eval set -- "$ARGV" while true; do case "$1" in - --dry-run) repo_upload_dry_run_arg="--dry-run"; shift ;; + --dry-run) repo_upload_dry_run_arg="--dry-run"; repo_branch="finalization-dry-run"; shift ;; *) break esac done diff --git a/tools/finalization/step-0.sh b/tools/finalization/step-0.sh index 8da866c0dc..2087f6e670 100755 --- a/tools/finalization/step-0.sh +++ b/tools/finalization/step-0.sh @@ -9,7 +9,7 @@ function commit_step_0_changes() { set +e repo forall -c '\ if [[ $(git status --short) ]]; then - repo start "VINTF-$FINAL_BOARD_API_LEVEL-Finalization" ; + repo start "'$repo_branch'" ; git add -A . ; git commit -m "Vendor API level $FINAL_BOARD_API_LEVEL is now frozen" \ -m "Ignore-AOSP-First: VINTF $FINAL_BOARD_API_LEVEL Finalization @@ -21,8 +21,9 @@ Test: build"; function finalize_step_0_main() { local top="$(dirname "$0")"/../../../.. - source $top/build/make/tools/finalization/command-line-options.sh source $top/build/make/tools/finalization/environment.sh + local repo_branch="VINTF-$FINAL_BOARD_API_LEVEL-Finalization" + source $top/build/make/tools/finalization/command-line-options.sh local m="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug" diff --git a/tools/finalization/step-1.sh b/tools/finalization/step-1.sh index adc917e8de..736d64110e 100755 --- a/tools/finalization/step-1.sh +++ b/tools/finalization/step-1.sh @@ -7,7 +7,7 @@ function commit_step_1_changes() { set +e repo forall -c '\ if [[ $(git status --short) ]]; then - repo start "$FINAL_PLATFORM_CODENAME-SDK-Finalization" ; + repo start "'$repo_branch'" ; git add -A . ; git commit -m "$FINAL_PLATFORM_CODENAME is now $FINAL_PLATFORM_SDK_VERSION and extension version $FINAL_MAINLINE_EXTENSION" \ -m "Ignore-AOSP-First: $FINAL_PLATFORM_CODENAME Finalization @@ -19,8 +19,9 @@ Test: build"; function finalize_step_1_main() { local top="$(dirname "$0")"/../../../.. - source $top/build/make/tools/finalization/command-line-options.sh source $top/build/make/tools/finalization/environment.sh + local repo_branch="$FINAL_PLATFORM_CODENAME-SDK-Finalization" + source $top/build/make/tools/finalization/command-line-options.sh source $top/build/make/tools/finalization/finalize-sdk-resources.sh diff --git a/tools/finalization/step-2.sh b/tools/finalization/step-2.sh index 862c8f5217..52e388722e 100755 --- a/tools/finalization/step-2.sh +++ b/tools/finalization/step-2.sh @@ -4,7 +4,7 @@ function commit_step_2_changes() { repo forall -c '\ if [[ $(git status --short) ]]; then - repo start "$FINAL_PLATFORM_CODENAME-SDK-Finalization-Rel" ; + repo start "'$repo_branch'" ; git add -A . ; git commit -m "$FINAL_PLATFORM_CODENAME/$FINAL_PLATFORM_SDK_VERSION is now REL" \ -m "Ignore-AOSP-First: $FINAL_PLATFORM_CODENAME Finalization @@ -17,8 +17,9 @@ Test: build"; function finalize_step_2_main() { local top="$(dirname "$0")"/../../../.. - source $top/build/make/tools/finalization/command-line-options.sh source $top/build/make/tools/finalization/environment.sh + local repo_branch="$FINAL_PLATFORM_CODENAME-SDK-Finalization-Rel" + source $top/build/make/tools/finalization/command-line-options.sh # prebuilts etc source $top/build/make/tools/finalization/finalize-sdk-rel.sh From f13fd59f550e972ce0494750f01140eb7231bb1a Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Tue, 9 Apr 2024 09:54:23 -0700 Subject: [PATCH 30/65] Update api_levels.go instead of api_constants.bzl This is a revert of aosp/2573034, but as a separate cl because the filename has been changed. We're reverting aosp/2573034 because the bazel migration has been cancelled and that api_constants.bzl file was changed to not be used. Ignore-AOSP-First: Someone else renamed this file in internal-only. Bug: 315353489 Test: Manually ran this snippet of shell script Change-Id: I3a51be1119109d2a6cf3959bdc8a48192872580f --- tools/finalization/finalize-sdk-resources.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/finalization/finalize-sdk-resources.sh b/tools/finalization/finalize-sdk-resources.sh index 003b7c04c9..10266ed1da 100755 --- a/tools/finalization/finalize-sdk-resources.sh +++ b/tools/finalization/finalize-sdk-resources.sh @@ -120,10 +120,10 @@ function finalize_sdk_resources() { local build_tools_source="$top/development/sdk/build_tools_source.prop_template" sed -i -e 's/Pkg\.Revision.*/Pkg\.Revision=${PLATFORM_SDK_VERSION}.0.0/g' $build_tools_source - # build/bazel - local codename_version="\"${FINAL_PLATFORM_CODENAME}\": ${FINAL_PLATFORM_SDK_VERSION}" - if ! grep -q "$codename_version" "$top/build/bazel/rules/common/api_constants.bzl" ; then - sed -i -e "/:.*$((${FINAL_PLATFORM_SDK_VERSION}-1)),/a \\ $codename_version," "$top/build/bazel/rules/common/api_constants.bzl" + # build/soong + local codename_version="\"${FINAL_PLATFORM_CODENAME}\": ${FINAL_PLATFORM_SDK_VERSION}" + if ! grep -q "$codename_version" "$top/build/soong/android/api_levels.go" ; then + sed -i -e "/:.*$((${FINAL_PLATFORM_SDK_VERSION}-1)),/a \\\t\t$codename_version," "$top/build/soong/android/api_levels.go" fi # cts From 7f277d5854c6151014b87630ee7716901cce0d1f Mon Sep 17 00:00:00 2001 From: Ted Bauer Date: Wed, 10 Apr 2024 14:30:05 +0000 Subject: [PATCH 31/65] aconfig: comment out new storage invocations We need to comment all new storage invocations so we can make some changes to the new storage API in AOSP and have them submit cleanly. Bug: 301491148 Test: m Change-Id: I13ce906efc0a80a47452e12bbf9d4e7c0b2c4b99 Ignore-AOSP-First: internal storage migration, this code will be deleted --- tools/aconfig/aconfig/src/codegen/rust.rs | 6 +++--- tools/aconfig/aconfig/templates/rust.template | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/aconfig/aconfig/src/codegen/rust.rs b/tools/aconfig/aconfig/src/codegen/rust.rs index 604259386f..6e6c9e28df 100644 --- a/tools/aconfig/aconfig/src/codegen/rust.rs +++ b/tools/aconfig/aconfig/src/codegen/rust.rs @@ -107,7 +107,7 @@ mod tests { const PROD_EXPECTED: &str = r#" //! codegenerated rust flag lib -use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; +// use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; use std::path::Path; use std::io::Write; use log::{info, error, LevelFilter}; @@ -510,7 +510,7 @@ pub fn reset_flags() { const EXPORTED_EXPECTED: &str = r#" //! codegenerated rust flag lib -use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; +// use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; use std::path::Path; use std::io::Write; use log::{info, error, LevelFilter}; @@ -584,7 +584,7 @@ pub fn enabled_ro_exported() -> bool { const FORCE_READ_ONLY_EXPECTED: &str = r#" //! codegenerated rust flag lib -use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; +// use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; use std::path::Path; use std::io::Write; use log::{info, error, LevelFilter}; diff --git a/tools/aconfig/aconfig/templates/rust.template b/tools/aconfig/aconfig/templates/rust.template index fe07ac5488..3cc989e6b8 100644 --- a/tools/aconfig/aconfig/templates/rust.template +++ b/tools/aconfig/aconfig/templates/rust.template @@ -1,6 +1,6 @@ //! codegenerated rust flag lib -use aconfig_storage_read_api::\{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; +// use aconfig_storage_read_api::\{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; use std::path::Path; use std::io::Write; use log::\{info, error, LevelFilter}; @@ -61,6 +61,7 @@ pub fn {flag.name}() -> bool \{ return result; } + /* // This will be called multiple times. Subsequent calls after the first // are noops. logger::init( @@ -111,6 +112,8 @@ pub fn {flag.name}() -> bool \{ } } + */ + result {{ endif }} {{ -endif }} From 023fa5dc1742e6a6a5b411bdc2860d2378c61e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Fri, 12 Apr 2024 13:59:31 +0200 Subject: [PATCH 32/65] finalization: do not generate the ADB keys The ADB keys have already been generated for Android 15. Remove that step from the scripts. Bug: 323940469 Test: TH Ignore-AOSP-first: VIC finalization happens outside AOSP Change-Id: I83184740bfc1db3104e320b76638253a5892507c --- tools/finalization/localonly-steps.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/finalization/localonly-steps.sh b/tools/finalization/localonly-steps.sh index bebd563bea..4084450af6 100755 --- a/tools/finalization/localonly-steps.sh +++ b/tools/finalization/localonly-steps.sh @@ -10,8 +10,9 @@ function finalize_locally() { 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" + # The keys are already generated for Android 15. Keeping the command (commented out) for future reference. + # $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_RELEASE=fina_1 TARGET_BUILD_VARIANT=userdebug sdk dist sdk_repo DIST_DIR=out/dist From cdb07595a1a2e41e747c75cccb551c9efb8216f8 Mon Sep 17 00:00:00 2001 From: Gurpreet Singh Date: Thu, 18 Apr 2024 15:01:36 +0000 Subject: [PATCH 33/65] Change build-release target for building module sdks --build-release=latest => Include all new APIs in API tracking files along with the @FlaggedAPI annotation prefix. --build-release=next => Include only those new APIs in API tracking files for which the flag is enabled. Also the @FlaggedAPI annotation prefix is removed from API tracking files. Ignore-AOSP-first: VIC finalization happens outside AOSP Bug: 335454564 Test: croot && build/tools/finalization/localonly-steps.sh Change-Id: I3fdd71ac385835b3b961336d86604e86dfed31cf --- tools/finalization/localonly-steps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/finalization/localonly-steps.sh b/tools/finalization/localonly-steps.sh index bebd563bea..9c6f1723cf 100755 --- a/tools/finalization/localonly-steps.sh +++ b/tools/finalization/localonly-steps.sh @@ -17,7 +17,7 @@ function finalize_locally() { $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_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 + 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=next # 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 28e19ef89d1285665a6d7465f0567fe1d11c8c2e Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Thu, 18 Apr 2024 10:55:59 +0800 Subject: [PATCH 34/65] Do not copy platform ABI dumps from current In trunk stable, the ABI dumps in "current" directory are not what we intend to finalize. They need to be removed. The step will be replaced with a command that builds ABI dumps. Ignore-AOSP-First: merge conflict Test: build/make/tools/finalization/finalize-sdk-rel.sh Bug: 333532038 Change-Id: I08896b637b34861e73cff4d829941d9fb5c56475 --- tools/finalization/finalize-sdk-rel.sh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/tools/finalization/finalize-sdk-rel.sh b/tools/finalization/finalize-sdk-rel.sh index ca2f20d3b7..11bc25c114 100755 --- a/tools/finalization/finalize-sdk-rel.sh +++ b/tools/finalization/finalize-sdk-rel.sh @@ -33,15 +33,7 @@ function finalize_sdk_rel() { fi git -C "$top/cts" mv hostsidetests/theme/assets/${FINAL_PLATFORM_CODENAME} hostsidetests/theme/assets/${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/" - - # 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/" + # TODO(b/333532038): Create ABI dumps in prebuilts/abi-dumps/platform } finalize_sdk_rel From 38f95f07d2df2fd42ba2699ef3ea27e789058eaf Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 19 Apr 2024 11:52:47 +0100 Subject: [PATCH 35/65] Use new metalava jar-to-diff command Replaces the use of `--input-jar-file` and `--api-xml` with the newly added `jar-to-diff` command. Test: TARGETS=$(for i in api.xml system-api.xml module-lib-api.xml system-server-api.xml test-api.xml; do echo out/target/common/obj/$i; done) m $TARGETS # Diff $TARGETS with and without this change to make sure that # they are identical, which they are. (cherry picked from https://android-review.googlesource.com/q/commit:56ac6da961eb660c8ea59c5bb9d71a67433702f5) Merged-In: I6a78febb4b2e4d06a0b3aea29fb4a7f94c9ab9a4 Change-Id: I6a78febb4b2e4d06a0b3aea29fb4a7f94c9ab9a4 --- core/main.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/main.mk b/core/main.mk index 04b6b33228..f43f0bbe99 100644 --- a/core/main.mk +++ b/core/main.mk @@ -1914,7 +1914,7 @@ else ifeq ($(TARGET_BUILD_UNBUNDLED),$(TARGET_BUILD_UNBUNDLED_IMAGE)) $(api_xmls): $(hide) echo "Converting API file to XML: $@" $(hide) mkdir -p $(dir $@) - $(hide) $(APICHECK_COMMAND) --input-api-jar $< --api-xml $@ + $(hide) $(APICHECK_COMMAND) jar-to-jdiff $< $@ $(foreach xml,$(sort $(api_xmls)),$(call declare-1p-target,$(xml),)) From e072257bdaf20c5d0a09f5908123d2d283dedfd3 Mon Sep 17 00:00:00 2001 From: Xuanang Zhao Date: Tue, 23 Apr 2024 02:19:21 +0000 Subject: [PATCH 36/65] Add new trendy team module for Pearl team Bug: 332479829 Ignore-AOSP-First: internal config Change-Id: Ia1ebbf5c6b010b381aa70ba0edd7b00fd05c0e59 --- teams/Android.bp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/teams/Android.bp b/teams/Android.bp index bae8e80548..28193d885c 100644 --- a/teams/Android.bp +++ b/teams/Android.bp @@ -4350,6 +4350,13 @@ team { trendy_team_id: "5823575353065472", } +team { + name: "trendy_team_pixel_pearl", + + // go/trendy/manage/engineers/6326219602231296 + trendy_team_id: "6326219602231296", +} + team { name: "trendy_team_ar_sensors_context_hub", From b18cd886255764690a6367fcf787023138503e25 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Tue, 16 Apr 2024 17:08:45 +0800 Subject: [PATCH 37/65] Create ABI dumps for APEX libraries at finalization step 2 Ignore-AOSP-First: merge conflict Test: build/make/tools/finalization/finalize-sdk-rel.sh Bug: 333532038 Change-Id: I4e6d8f7e2489d51899ca878a3c965e5a14799cc3 --- tools/finalization/finalize-sdk-rel.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/finalization/finalize-sdk-rel.sh b/tools/finalization/finalize-sdk-rel.sh index 11bc25c114..c169ee52b3 100755 --- a/tools/finalization/finalize-sdk-rel.sh +++ b/tools/finalization/finalize-sdk-rel.sh @@ -33,7 +33,9 @@ function finalize_sdk_rel() { fi git -C "$top/cts" mv hostsidetests/theme/assets/${FINAL_PLATFORM_CODENAME} hostsidetests/theme/assets/${FINAL_PLATFORM_SDK_VERSION} - # TODO(b/333532038): Create ABI dumps in prebuilts/abi-dumps/platform + # prebuilts/abi-dumps/platform + "$top/build/soong/soong_ui.bash" --make-mode TARGET_RELEASE=fina_2 TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug create_reference_dumps + ANDROID_BUILD_TOP="$top" "$top/out/host/linux-x86/bin/create_reference_dumps" -release fina_2 --build-variant userdebug --lib-variant APEX } finalize_sdk_rel From 8e7df8df159dae5bb246dc82c1e8d1073fbc31af Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Mon, 8 Apr 2024 17:45:26 +0000 Subject: [PATCH 38/65] Drop INDIVIDUALLY_TOGGLEABLE_PREBUILT_MODULES This list is used to create soong config namespaces per toggle-able module, and set source_build property. internal and partner branches now use RELEASE_APEX_CONTRIBUTIONS_* for source vs selection, so remove this mechanism to prevent confusing behaviors when these two mechanisms have conflicting values. `art_module.source_build` is a special-case which uses an additional variable `ART_MODULE_SOURCE_BUILD`. This will be tracked in https://r.android.com/3037396 Bug: 308188056 Test: presubmits Test: downloaded this CL in v-aml branch, m out/soong/prebuilt_info.json; file is identical Ignore-AOSP-First: This needs to be submitted in internal first to prevent merge conflicts Change-Id: I3f9cbb24d6f3a7a0312683906826708147f469ee --- core/android_soong_config_vars.mk | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk index bcf9fe8966..1e38dcb15e 100644 --- a/core/android_soong_config_vars.mk +++ b/core/android_soong_config_vars.mk @@ -74,36 +74,6 @@ ifdef TARGET_BOARD_AUTO $(call add_soong_config_var_value, ANDROID, target_board_auto, $(TARGET_BOARD_AUTO)) endif -# Ensure that those mainline modules who have individually toggleable prebuilts -# are controlled by the MODULE_BUILD_FROM_SOURCE environment variable by -# default. -INDIVIDUALLY_TOGGLEABLE_PREBUILT_MODULES := \ - adservices \ - appsearch \ - btservices \ - configinfrastructure \ - conscrypt \ - devicelock \ - healthfitness \ - ipsec \ - media \ - mediaprovider \ - mediaprovider \ - ondevicepersonalization \ - permission \ - rkpd \ - scheduling \ - sdkext \ - statsd \ - tethering \ - uwb \ - wifi \ - mediaprovider \ - -$(foreach m, $(INDIVIDUALLY_TOGGLEABLE_PREBUILT_MODULES),\ - $(if $(call soong_config_get,$(m)_module,source_build),,\ - $(call soong_config_set,$(m)_module,source_build,$(MODULE_BUILD_FROM_SOURCE)))) - # Apex build mode variables ifdef APEX_BUILD_FOR_PRE_S_DEVICES $(call add_soong_config_var_value,ANDROID,library_linking_strategy,prefer_static) From ddd7bd099e6b5e7ccffa4e2d46cb2da5d92791e8 Mon Sep 17 00:00:00 2001 From: Ted Bauer Date: Wed, 24 Apr 2024 17:32:32 +0000 Subject: [PATCH 39/65] Update test mission 1 marker file directory We changed the marker file directory and SELinux policy in aosp/3025525, so update the directory here as well. Bug: 328444881 Test: m Change-Id: I28531491b3273fff1b135c9342847a878610679b Ignore-AOSP-First: internal storage migration --- tools/aconfig/aconfig/src/codegen/rust.rs | 6 +++--- tools/aconfig/aconfig/templates/rust.template | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/aconfig/aconfig/src/codegen/rust.rs b/tools/aconfig/aconfig/src/codegen/rust.rs index db3003d7e5..341979e58d 100644 --- a/tools/aconfig/aconfig/src/codegen/rust.rs +++ b/tools/aconfig/aconfig/src/codegen/rust.rs @@ -113,7 +113,7 @@ use std::io::Write; use log::{log, LevelFilter, Level}; static STORAGE_MIGRATION_MARKER_FILE: &str = - "/metadata/aconfig/storage_test_mission_1"; + "/metadata/aconfig_test_missions/mission_1"; static MIGRATION_LOG_TAG: &str = "AconfigTestMission1"; /// flag provider @@ -516,7 +516,7 @@ use std::io::Write; use log::{log, LevelFilter, Level}; static STORAGE_MIGRATION_MARKER_FILE: &str = - "/metadata/aconfig/storage_test_mission_1"; + "/metadata/aconfig_test_missions/mission_1"; static MIGRATION_LOG_TAG: &str = "AconfigTestMission1"; /// flag provider @@ -590,7 +590,7 @@ use std::io::Write; use log::{log, LevelFilter, Level}; static STORAGE_MIGRATION_MARKER_FILE: &str = - "/metadata/aconfig/storage_test_mission_1"; + "/metadata/aconfig_test_missions/mission_1"; static MIGRATION_LOG_TAG: &str = "AconfigTestMission1"; /// flag provider diff --git a/tools/aconfig/aconfig/templates/rust.template b/tools/aconfig/aconfig/templates/rust.template index 2f97c14fca..f5d86117fa 100644 --- a/tools/aconfig/aconfig/templates/rust.template +++ b/tools/aconfig/aconfig/templates/rust.template @@ -6,7 +6,7 @@ use std::io::Write; use log::\{log, LevelFilter, Level}; static STORAGE_MIGRATION_MARKER_FILE: &str = - "/metadata/aconfig/storage_test_mission_1"; + "/metadata/aconfig_test_missions/mission_1"; static MIGRATION_LOG_TAG: &str = "AconfigTestMission1"; /// flag provider From fbcbcc609a38def49d54f4a1e864bfc2f7c40e26 Mon Sep 17 00:00:00 2001 From: Ted Bauer Date: Wed, 24 Apr 2024 20:58:43 +0000 Subject: [PATCH 40/65] Use get_package_read_context API in Rust codegen Bug: 328444881 Test: m Change-Id: I1f0a5e147a823c8fbebf601a8de9129e206f4454 Ignore-AOSP-First: internal storage migration --- tools/aconfig/aconfig/src/codegen/rust.rs | 6 +++--- tools/aconfig/aconfig/templates/rust.template | 14 ++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tools/aconfig/aconfig/src/codegen/rust.rs b/tools/aconfig/aconfig/src/codegen/rust.rs index db3003d7e5..f94e643958 100644 --- a/tools/aconfig/aconfig/src/codegen/rust.rs +++ b/tools/aconfig/aconfig/src/codegen/rust.rs @@ -107,7 +107,7 @@ mod tests { const PROD_EXPECTED: &str = r#" //! codegenerated rust flag lib -// use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; +use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_read_context}; use std::path::Path; use std::io::Write; use log::{log, LevelFilter, Level}; @@ -510,7 +510,7 @@ pub fn reset_flags() { const EXPORTED_EXPECTED: &str = r#" //! codegenerated rust flag lib -// use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; +use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_read_context}; use std::path::Path; use std::io::Write; use log::{log, LevelFilter, Level}; @@ -584,7 +584,7 @@ pub fn enabled_ro_exported() -> bool { const FORCE_READ_ONLY_EXPECTED: &str = r#" //! codegenerated rust flag lib -// use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; +use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_read_context}; use std::path::Path; use std::io::Write; use log::{log, LevelFilter, Level}; diff --git a/tools/aconfig/aconfig/templates/rust.template b/tools/aconfig/aconfig/templates/rust.template index 2f97c14fca..a1381b49b4 100644 --- a/tools/aconfig/aconfig/templates/rust.template +++ b/tools/aconfig/aconfig/templates/rust.template @@ -1,6 +1,6 @@ //! codegenerated rust flag lib -// use aconfig_storage_read_api::\{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_offset}; +use aconfig_storage_read_api::\{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_read_context}; use std::path::Path; use std::io::Write; use log::\{log, LevelFilter, Level}; @@ -61,7 +61,6 @@ pub fn {flag.name}() -> bool \{ return result; } - /* // This will be called multiple times. Subsequent calls after the first // are noops. logger::init( @@ -78,10 +77,11 @@ pub fn {flag.name}() -> bool \{ return result; } }; - let package_offset = match get_package_offset(&package_map, "{package}") \{ - Ok(Some(offset)) => offset, + + let package_read_context = match get_package_read_context(&package_map, "{package}") \{ + Ok(Some(context)) => context, Ok(None) => \{ - log!(Level::Error, "AconfigTestMission1: error: failed to read flag '{flag.name}': did not find offset"); + log!(Level::Error, "AconfigTestMission1: error: failed to read flag '{flag.name}': did not get context"); return result; }, Err(err) => \{ @@ -96,7 +96,7 @@ pub fn {flag.name}() -> bool \{ return result; } }; - let value = match get_boolean_flag_value(&flag_val_map, {flag.flag_offset} + package_offset.boolean_offset) \{ + let value = match get_boolean_flag_value(&flag_val_map, {flag.flag_offset} + package_read_context.boolean_start_index) \{ Ok(val) => val, Err(err) => \{ log!(Level::Error, "AconfigTestMission1: error: failed to read flag '{flag.name}': \{err}"); @@ -112,8 +112,6 @@ pub fn {flag.name}() -> bool \{ } } - */ - result {{ endif }} {{ -endif }} From 06dad4f3c202211bef9220697fac0594ffc67d16 Mon Sep 17 00:00:00 2001 From: Gurpreet Singh Date: Mon, 29 Apr 2024 13:20:34 +0000 Subject: [PATCH 41/65] V is 35. It's not bromine, it's not a gauge of film: it's the next Android release. Set final state to "sdk" marking step-1 of finalization as complete. Ignore-AOSP-First: Finalization is not performed in AOSP. Bug: 335304236 Test: presubmit Change-Id: Ifebf6ce36c5aa5c987d434085ca812f18e97ad4f --- 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 cadc26f952..6593e78399 100755 --- a/tools/finalization/environment.sh +++ b/tools/finalization/environment.sh @@ -22,7 +22,7 @@ export FINAL_MAINLINE_EXTENSION='13' # 'vintf' - VINTF is finalized # 'sdk' - VINTF and SDK/API are finalized # 'rel' - branch is finalized, switched to REL -export FINAL_STATE='vintf' +export FINAL_STATE='sdk' export BUILD_FROM_SOURCE_STUB=true From a7d2200a710497170ac3de17a613929955f8ebd5 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Wed, 7 Feb 2024 17:12:53 +0800 Subject: [PATCH 42/65] Add the step to generate LLNDK ABI dumps Test: build/make/tools/finalization/finalize-vintf-resources.sh Bug: 314010764 Ignore-AOSP-First: Finalization scripts are not on AOSP Change-Id: Ibe77d2f2aa70d3cc85086c00bb3eba00da0986f5 --- tools/finalization/finalize-vintf-resources.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/finalization/finalize-vintf-resources.sh b/tools/finalization/finalize-vintf-resources.sh index a55d8e1a1a..d532b25346 100755 --- a/tools/finalization/finalize-vintf-resources.sh +++ b/tools/finalization/finalize-vintf-resources.sh @@ -16,8 +16,6 @@ function finalize_vintf_resources() { export TARGET_RELEASE=fina_0 export TARGET_PRODUCT=aosp_arm64 - # TODO(b/314010764): finalize LL_NDK - # system/sepolicy "$top/system/sepolicy/tools/finalize-vintf-resources.sh" "$top" "$FINAL_BOARD_API_LEVEL" @@ -25,7 +23,11 @@ function finalize_vintf_resources() { # pre-finalization build target (trunk) local aidl_m="$top/build/soong/soong_ui.bash --make-mode" - AIDL_TRANSITIVE_FREEZE=true $aidl_m aidl-freeze-api + AIDL_TRANSITIVE_FREEZE=true $aidl_m aidl-freeze-api create_reference_dumps + + # Generate LLNDK ABI dumps + # This command depends on ANDROID_BUILD_TOP + "$ANDROID_HOST_OUT/bin/create_reference_dumps" -release "$TARGET_RELEASE" --build-variant "$TARGET_BUILD_VARIANT" --lib-variant LLNDK } function create_new_compat_matrix_and_kernel_configs() { From b5e3f0c2d244e1b1bf888ea91069013d5bda7d5d Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 7 Mar 2024 17:08:05 -0800 Subject: [PATCH 43/65] Look for release_config_map.mk in more projects This allows us to split up build/release for better clarity. Bug: b/328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: If810780de164b74c3e3ebc35260384843de2c084 Change-Id: If810780de164b74c3e3ebc35260384843de2c084 --- core/release_config.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/release_config.mk b/core/release_config.mk index 8d19bc7b2a..a6152bdb41 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -41,7 +41,9 @@ # 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) \ +config_map_files := $(wildcard build/trunk_release/release_config_map.mk) \ + $(wildcard build/release/release_config_map.mk) \ + $(wildcard vendor/google_shared/build/release/release_config_map.mk) \ $(if $(wildcard vendor/google/release/release_config_map.mk), \ vendor/google/release/release_config_map.mk, \ $(sort \ From 7dd547294de054115a5c10c64bdb483a9cb8c5ee Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 14 Mar 2024 10:48:55 -0700 Subject: [PATCH 44/65] Allow duplicate release config maps and build flag declarations Only include a release_config_map.mk file the first time it appears in the list. If the flag declaration is identical to one already declared, do not raise an error. This eases the process of migrating where flags are declared. Bug: b/328781415 Bug: b/328495189 Test: manual, TH Ignore-AOSP-First: cherry-pick Change-Id: I18316e769438f62071723771762d6e89be98b813 Merged-In: I18316e769438f62071723771762d6e89be98b813 --- core/release_config.mk | 11 ++++++++--- core/release_config.scl | 21 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/core/release_config.mk b/core/release_config.mk index a6152bdb41..36882bb0ce 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -119,12 +119,17 @@ define _declare-release-config endef # Include the config map files and populate _flag_declaration_files. +# If the file is found more than once, only include it the first time. _flag_declaration_files := +_included_config_map_files := $(foreach f, $(config_map_files), \ $(eval FLAG_DECLARATION_FILES:= ) \ - $(eval _included := $(f)) \ - $(eval include $(f)) \ - $(eval _flag_declaration_files += $(FLAG_DECLARATION_FILES)) \ + $(if $(filter $(_included_config_map_files),$(f)),,\ + $(eval _included := $(f)) \ + $(eval include $(f)) \ + $(eval _flag_declaration_files += $(FLAG_DECLARATION_FILES)) \ + $(eval _included_config_map_files += $(f)) \ + ) \ ) FLAG_DECLARATION_FILES := diff --git a/core/release_config.scl b/core/release_config.scl index 662d15507a..629e22328a 100644 --- a/core/release_config.scl +++ b/core/release_config.scl @@ -145,6 +145,21 @@ def _format_value(val): else: return val +def equal_flag_declaration(flag, other): + """Return true if the flag declarations are equal. + + Args: + flag: This flag declaration. + other: Another flag declaration. + + Returns: + Whether the declarations are the same. + """ + for key in "name", "partitions", "default", "appends": + if flag[key] != other[key]: + return False + return True + def release_config(all_flags, all_values): """Return the make variables that should be set for this release config. @@ -163,7 +178,11 @@ def release_config(all_flags, all_values): flags_dict = {} for flag in all_flags: if flag["name"] in flag_names: - fail(flag["declared_in"] + ": Duplicate declaration of flag " + flag["name"]) + if equal_flag_declaration(flag, flags_dict[flag["name"]]): + continue + else: + fail(flag["declared_in"] + ": Duplicate declaration of flag " + flag["name"] + + " (declared first in " + flags_dict[flag["name"]]["declared_in"] + ")") flag_names.append(flag["name"]) flags_dict[flag["name"]] = flag From 08924a47a4f0b6dad9162c4026cc4c9af0447519 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 20 Mar 2024 12:24:21 -0700 Subject: [PATCH 45/65] Defer "no such release config" error This allows product-specific release config maps to declare release configs. Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I862f167062ee647af00a4ec7d4af2966c6be44a8 Change-Id: I862f167062ee647af00a4ec7d4af2966c6be44a8 --- core/release_config.mk | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/core/release_config.mk b/core/release_config.mk index 36882bb0ce..a7b5b3ff38 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -133,6 +133,18 @@ $(foreach f, $(config_map_files), \ ) FLAG_DECLARATION_FILES := +# Verify that all inherited/overridden release configs are declared. +$(foreach config,$(_all_release_configs),\ + $(foreach r,$(all_release_configs.$(r).OVERRIDES),\ + $(if $(strip $(_all_release_configs.$(r).FILES)$(_all_release_configs.$(r).OVERRIDES)),,\ + $(error Release config $(config) [declared in: $(_all_release_configs.$(r).DECLARED_IN)] inherits from non-existent $(r).)\ +))) +# Verify that alias configs do not have config files. +$(foreach r,$(_all_release_configs),\ + $(if $(_all_release_configs.$(r).ALIAS),$(if $(_all_release_configs.$(r).FILES),\ + $(error Alias release config "$(r)" may not specify release config files $(_all_release_configs.$(r).FILES))\ +))) + ifeq ($(TARGET_RELEASE),) # We allow some internal paths to explicitly set TARGET_RELEASE to the # empty string. For the most part, 'make' treats unset and empty string as @@ -148,8 +160,12 @@ ifeq ($(TARGET_RELEASE),) TARGET_RELEASE = trunk_staging endif -ifeq ($(filter $(_all_release_configs), $(TARGET_RELEASE)),) - $(error No release config found for TARGET_RELEASE: $(TARGET_RELEASE). Available releases are: $(_all_release_configs)) +# During pass 1 of product config, using a non-existent release config is not an error. +# We can safely assume that we are doing pass 1 if DUMP_MANY_VARS=="PRODUCT_RELEASE_CONFIG_MAPS". +ifneq (PRODUCT_RELEASE_CONFIG_MAPS,$(DUMP_MANY_VARS)) + ifeq ($(filter $(_all_release_configs), $(TARGET_RELEASE)),) + $(error No release config found for TARGET_RELEASE: $(TARGET_RELEASE). Available releases are: $(_all_release_configs)) + endif endif # Choose flag files @@ -177,7 +193,7 @@ $(call _apply-release-config-overrides,$(TARGET_RELEASE)) define declare-release-config $(error declare-release-config can only be called from inside release_config_map.mk files) endef -define apply-release-config-overrides +define _apply-release-config-overrides $(error invalid use of apply-release-config-overrides) endef @@ -192,12 +208,6 @@ TARGET_RELEASE:= endif .KATI_READONLY := TARGET_RELEASE -# Verify that alias configs do not have config files. -$(foreach r,$(_all_release_configs),\ - $(if $(_all_release_configs.$(r).ALIAS),$(if $(_all_release_configs.$(r).FILES),\ - $(error Alias release config "$(r)" may not specify release config files $(_all_release_configs.$(r).FILES))\ -))) - $(foreach config, $(_all_release_configs), \ $(eval _all_release_configs.$(config).DECLARED_IN:= ) \ $(eval _all_release_configs.$(config).FILES:= ) \ From afd6a265a98b7423e79e86641cab2ec493c681d0 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Fri, 29 Mar 2024 14:50:50 -0700 Subject: [PATCH 46/65] Do not use build/trunk_release/release_config_map.mk We won't be adding build/trunk_release to the manifest. Bug: 328495189 Test: TH Ignore-AOSP-First: cherry-pick Merged-In: I0ef2a900568daccfbd2ef1d8949674e6f2a63e00 Change-Id: I0ef2a900568daccfbd2ef1d8949674e6f2a63e00 --- core/release_config.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/release_config.mk b/core/release_config.mk index a7b5b3ff38..3e51af5a44 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -41,8 +41,7 @@ # 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/trunk_release/release_config_map.mk) \ - $(wildcard build/release/release_config_map.mk) \ +config_map_files := $(wildcard build/release/release_config_map.mk) \ $(wildcard vendor/google_shared/build/release/release_config_map.mk) \ $(if $(wildcard vendor/google/release/release_config_map.mk), \ vendor/google/release/release_config_map.mk, \ From 69b2ed6610740f220245c5d51e4d08284561396a Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 1 May 2024 11:24:08 -0700 Subject: [PATCH 47/65] Enable build flags in protobuf If RELEASE_BUILD_FLAGS_IN_PROTOBUF is False, then the results from out/release-config are ignored and we do the old processing. The following additional logic all goes away once the migration to protobuf is finished. - If we found .textproto files that don't have corresponding .mk files, we require protobuf. - If we found .mk files that don't have corresponding .textproto files, we require legacy (make) processing. - If PRODUCT_RELEASE_CONFIG_MAPS specifies .textproto files, we require protobuf. In order to further isolate migration, the choice can be determined on a release-config by release-config basis. in each release config directory, we look for: - `build_config/DEFAULT=proto` - `build_config/DEFAULT=make` - `build_config/${TARGET_RELEASE}=proto` - `build_config/${TARGET_RELEASE}=make` The last such file found determines which code path is used. Bug: 328495189 Test: manual, TH Ignore-AOSP-First: cherrypick Merged-In: I1d84db76b157082fc7db1b3cb7c9afe8cdf46cbf Change-Id: I1d84db76b157082fc7db1b3cb7c9afe8cdf46cbf --- core/release_config.mk | 94 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/core/release_config.mk b/core/release_config.mk index 3e51af5a44..bb519804d1 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -41,6 +41,7 @@ # 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. +_must_protobuf := config_map_files := $(wildcard build/release/release_config_map.mk) \ $(wildcard vendor/google_shared/build/release/release_config_map.mk) \ $(if $(wildcard vendor/google/release/release_config_map.mk), \ @@ -53,13 +54,85 @@ config_map_files := $(wildcard build/release/release_config_map.mk) \ ) \ ) +protobuf_map_files := $(wildcard build/release/release_config_map.textproto) \ + $(wildcard vendor/google_shared/build/release/release_config_map.textproto) \ + $(if $(wildcard vendor/google/release/release_config_map.textproto), \ + vendor/google/release/release_config_map.textproto, \ + $(sort \ + $(wildcard device/*/release/release_config_map.textproto) \ + $(wildcard device/*/*/release/release_config_map.textproto) \ + $(wildcard vendor/*/release/release_config_map.textproto) \ + $(wildcard vendor/*/*/release/release_config_map.textproto) \ + ) \ + ) + # PRODUCT_RELEASE_CONFIG_MAPS is set by Soong using an initial run of product # config to capture only the list of config maps needed by the build. # Keep them in the order provided, but remove duplicates. +# Treat .mk and .textproto as equal for duplicate elimination, but force +# protobuf if any PRODUCT_RELEASE_CONFIG_MAPS specify .textproto. $(foreach map,$(PRODUCT_RELEASE_CONFIG_MAPS), \ - $(if $(filter $(map),$(config_map_files)),,$(eval config_map_files += $(map))) \ + $(if $(filter $(basename $(map)),$(basename $(config_map_files))),, \ + $(eval config_map_files += $(map))) \ + $(if $(filter $(basename $(map)).textproto,$(map)),$(eval _must_protobuf := true)) \ ) + +# If we are missing the textproto version of any of $(config_map_files), we cannot use protobuf. +_can_protobuf := true +$(foreach map,$(config_map_files), \ + $(if $(wildcard $(basename $(map)).textproto),,$(eval _can_protobuf :=)) \ +) +# If we are missing the mk version of any of $(protobuf_map_files), we must use protobuf. +$(foreach map,$(protobuf_map_files), \ + $(if $(wildcard $(basename $(map)).mk),,$(eval _must_protobuf := true)) \ +) + +ifneq (,$(_must_protobuf)) + ifeq (,$(_can_protobuf)) + # We must use protobuf, but we cannot use protobuf. + $(error release config is a mixture of .scl and .textproto) + endif +endif + +_use_protobuf := +ifneq (,$(_must_protobuf)) + _use_protobuf := true +else + ifneq ($(_can_protobuf),) + # Determine the default + $(foreach map,$(config_map_files), \ + $(if $(wildcard $(dir $(map))/build_config/DEFAULT=proto),$(eval _use_protobuf := true)) \ + $(if $(wildcard $(dir $(map))/build_config/DEFAULT=make),$(eval _use_protobuf := )) \ + ) + # Update for this specific release config only (no inheritance). + $(foreach map,$(config_map_files), \ + $(if $(wildcard $(dir $(map))/build_config/$(TARGET_RELEASE)=proto),$(eval _use_protobuf := true)) \ + $(if $(wildcard $(dir $(map))/build_config/$(TARGET_RELEASE)=make),$(eval _use_protobuf := )) \ + ) + endif +endif + +ifneq (,$(_use_protobuf)) + # The .textproto files are the canonical source of truth. + _args := $(foreach map,$(config_map_files), --map $(map) ) + ifneq (,$(_must_protobuf)) + # Disable the build flag in release-config. + _args += --guard=false + endif + $(KATI_shell_no_rerun $(OUT_DIR)/release-config $(_args) >$(OUT_DIR)/release-config.out && touch -t 200001010000 $(OUT_DIR)/release-config.out) + $(if $(filter-out 0,$(.SHELLSTATUS)),$(error release-config failed to run)) + # This will also set _all_release_configs for us. + $(eval include $(OUT_DIR)/soong/release-config/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).mk) + $(KATI_extra_file_deps $(OUT_DIR)/release-config $(config_map_files)) + ifeq (,$(_must_protobuf)$(RELEASE_BUILD_FLAGS_IN_PROTOBUF)) + _use_protobuf := + endif +endif +ifeq (,$(_use_protobuf)) + # The .mk files are the canonical source of truth. + + # Declare an alias release-config # # This should be used to declare a release as an alias of another, meaning no @@ -144,6 +217,9 @@ $(foreach r,$(_all_release_configs),\ $(error Alias release config "$(r)" may not specify release config files $(_all_release_configs.$(r).FILES))\ ))) +# Use makefiles +endif + ifeq ($(TARGET_RELEASE),) # We allow some internal paths to explicitly set TARGET_RELEASE to the # empty string. For the most part, 'make' treats unset and empty string as @@ -167,6 +243,7 @@ ifneq (PRODUCT_RELEASE_CONFIG_MAPS,$(DUMP_MANY_VARS)) endif endif +ifeq (,$(_use_protobuf)) # Choose flag files # Don't sort this, use it in the order they gave us. # Do allow duplicate entries, retaining only the first usage. @@ -196,6 +273,9 @@ define _apply-release-config-overrides $(error invalid use of apply-release-config-overrides) endef +# use makefiles +endif + # 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) @@ -207,15 +287,20 @@ TARGET_RELEASE:= endif .KATI_READONLY := TARGET_RELEASE +ifeq (,$(_use_protobuf)) $(foreach config, $(_all_release_configs), \ $(eval _all_release_configs.$(config).DECLARED_IN:= ) \ $(eval _all_release_configs.$(config).FILES:= ) \ ) +applied_releases:= +# use makefiles +endif _all_release_configs:= config_map_files:= -applied_releases:= +protobuf_map_files:= +ifeq (,$(_use_protobuf)) # ----------------------------------------------------------------- # Flag declarations and values # ----------------------------------------------------------------- @@ -252,3 +337,8 @@ filename_to_starlark:= # outside of the source tree. $(call run-starlark,$(OUT_DIR)/release_config_entrypoint.scl,$(OUT_DIR)/release_config_entrypoint.scl,--allow_external_entrypoint) +# use makefiles +endif +_can_protobuf := +_must_protobuf := +_use_protobuf := From 65c8dbb781ecd1abe0f8289d9d72cace74a4482b Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 9 May 2024 15:18:21 -0700 Subject: [PATCH 48/65] Avoid re-running kati unnecessarily. Bug: 339707888 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: I0447a127aee7e5ef34d7ae81a3b8bead7c7bc95b Change-Id: I0447a127aee7e5ef34d7ae81a3b8bead7c7bc95b --- core/release_config.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/release_config.mk b/core/release_config.mk index bb519804d1..97c8dd3571 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -120,7 +120,8 @@ ifneq (,$(_use_protobuf)) # Disable the build flag in release-config. _args += --guard=false endif - $(KATI_shell_no_rerun $(OUT_DIR)/release-config $(_args) >$(OUT_DIR)/release-config.out && touch -t 200001010000 $(OUT_DIR)/release-config.out) + _flags_file:=$(OUT_DIR)/soong/release-config/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).mk + $(KATI_shell_no_rerun $(OUT_DIR)/release-config $(_args) >$(OUT_DIR)/release-config.out 2>&1 && touch -t 200001010000 $(OUT_DIR)/release-config.out $(_flags_file)) $(if $(filter-out 0,$(.SHELLSTATUS)),$(error release-config failed to run)) # This will also set _all_release_configs for us. $(eval include $(OUT_DIR)/soong/release-config/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).mk) From c3e104f97f5c6ff4522b7b6dcba1b4e06ff394bf Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Tue, 14 May 2024 13:54:13 -0700 Subject: [PATCH 49/65] Provide a function in envsetup.sh to get the host arch directly It's very simple logic, and running get_build_var to do it is slow and has side effects (like needing a lunch target, creating an out directory, etc.) Test: source envsetup.sh Change-Id: If260efd21713874fba7c15dbc0fd23442d776f8a --- core/envsetup.mk | 1 + envsetup.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/core/envsetup.mk b/core/envsetup.mk index 1c3a1b3b6b..3271079abc 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -255,6 +255,7 @@ endif HOST_PREBUILT_ARCH := x86 # This is the standard way to name a directory containing prebuilt host # objects. E.g., prebuilt/$(HOST_PREBUILT_TAG)/cc +# This must match the logic in get_host_prebuilt_prefix in envsetup.sh HOST_PREBUILT_TAG := $(BUILD_OS)-$(HOST_PREBUILT_ARCH) # TARGET_COPY_OUT_* are all relative to the staging directory, ie PRODUCT_OUT. diff --git a/envsetup.sh b/envsetup.sh index 50fec5146a..ff3c3a60eb 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -196,6 +196,19 @@ function get_build_var() (\cd $T; build/soong/soong_ui.bash --dumpvar-mode $1) } +# This logic matches envsetup.mk +function get_host_prebuilt_prefix +{ + local un=$(uname) + if [[ $un == "Linux" ]] ; then + echo linux-x86 + elif [[ $un == "Darwin" ]] ; then + echo darwin-x86 + else + echo "Error: Invalid host operating system: $un" 1>&2 + fi +} + # check to see if the supplied product is one we can build function check_product() { From a2440a3e4a26447a080ca710042faf20a96b8db2 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Wed, 15 May 2024 15:49:34 +0800 Subject: [PATCH 50/65] Create APEX ABI dumps with next release configuration Next release configuration maps the codename to the finalized API level, but fina_2 doesn't. Ignore-AOSP-First: Finalization scripts are not on AOSP Test: build/make/tools/finalization/finalize-sdk-rel.sh Bug: 340507697 Change-Id: I00e55bf350ff5b5f5b10f9e74ceff38b0660dde3 --- tools/finalization/finalize-sdk-rel.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/finalization/finalize-sdk-rel.sh b/tools/finalization/finalize-sdk-rel.sh index c169ee52b3..c49f974bcd 100755 --- a/tools/finalization/finalize-sdk-rel.sh +++ b/tools/finalization/finalize-sdk-rel.sh @@ -34,8 +34,8 @@ function finalize_sdk_rel() { git -C "$top/cts" mv hostsidetests/theme/assets/${FINAL_PLATFORM_CODENAME} hostsidetests/theme/assets/${FINAL_PLATFORM_SDK_VERSION} # prebuilts/abi-dumps/platform - "$top/build/soong/soong_ui.bash" --make-mode TARGET_RELEASE=fina_2 TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug create_reference_dumps - ANDROID_BUILD_TOP="$top" "$top/out/host/linux-x86/bin/create_reference_dumps" -release fina_2 --build-variant userdebug --lib-variant APEX + "$top/build/soong/soong_ui.bash" --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug create_reference_dumps + ANDROID_BUILD_TOP="$top" "$top/out/host/linux-x86/bin/create_reference_dumps" -release next --build-variant userdebug --lib-variant APEX } finalize_sdk_rel From cfb69bd198554d6a382d9f717492dac4bbbd5ad1 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 16 May 2024 18:19:06 +0000 Subject: [PATCH 51/65] Revert "Avoid re-running kati unnecessarily." This reverts commit 65c8dbb781ecd1abe0f8289d9d72cace74a4482b. Reason for revert: Causes build flag changes to be ignored sometimes. Better fix is in progress. Merged-In: Ic85be1da3765656cef8da4ec03d0b1ca7d5d625e Change-Id: Ic85be1da3765656cef8da4ec03d0b1ca7d5d625e --- core/release_config.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/release_config.mk b/core/release_config.mk index 97c8dd3571..bb519804d1 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -120,8 +120,7 @@ ifneq (,$(_use_protobuf)) # Disable the build flag in release-config. _args += --guard=false endif - _flags_file:=$(OUT_DIR)/soong/release-config/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).mk - $(KATI_shell_no_rerun $(OUT_DIR)/release-config $(_args) >$(OUT_DIR)/release-config.out 2>&1 && touch -t 200001010000 $(OUT_DIR)/release-config.out $(_flags_file)) + $(KATI_shell_no_rerun $(OUT_DIR)/release-config $(_args) >$(OUT_DIR)/release-config.out && touch -t 200001010000 $(OUT_DIR)/release-config.out) $(if $(filter-out 0,$(.SHELLSTATUS)),$(error release-config failed to run)) # This will also set _all_release_configs for us. $(eval include $(OUT_DIR)/soong/release-config/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).mk) From 5e325d4228bbea264ef7b8d7d764b68398d2a3fb Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 16 May 2024 18:19:06 +0000 Subject: [PATCH 52/65] Revert "Avoid re-running kati unnecessarily." This reverts commit 65c8dbb781ecd1abe0f8289d9d72cace74a4482b. Reason for revert: Causes build flag changes to be ignored sometimes. Better fix is in progress. Ignore-AOSP-First: aosp/3092541 is this change Change-Id: Ic85be1da3765656cef8da4ec03d0b1ca7d5d625e --- core/release_config.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/release_config.mk b/core/release_config.mk index 97c8dd3571..bb519804d1 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -120,8 +120,7 @@ ifneq (,$(_use_protobuf)) # Disable the build flag in release-config. _args += --guard=false endif - _flags_file:=$(OUT_DIR)/soong/release-config/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).mk - $(KATI_shell_no_rerun $(OUT_DIR)/release-config $(_args) >$(OUT_DIR)/release-config.out 2>&1 && touch -t 200001010000 $(OUT_DIR)/release-config.out $(_flags_file)) + $(KATI_shell_no_rerun $(OUT_DIR)/release-config $(_args) >$(OUT_DIR)/release-config.out && touch -t 200001010000 $(OUT_DIR)/release-config.out) $(if $(filter-out 0,$(.SHELLSTATUS)),$(error release-config failed to run)) # This will also set _all_release_configs for us. $(eval include $(OUT_DIR)/soong/release-config/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).mk) From caa75d4c3a54d7c6810e829ac53e039ec45bb18d Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 16 May 2024 10:46:49 -0700 Subject: [PATCH 53/65] Mark files used in release configs as kati dependencies Bug: 341117082 Bug: 328495189 Bug: 339707888 Test: manual, TH Merged-In: I4377846844ad172a2760de309ee343b980e893f1 Change-Id: I4377846844ad172a2760de309ee343b980e893f1 --- core/release_config.mk | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/core/release_config.mk b/core/release_config.mk index bb519804d1..5fe3d3905a 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -13,6 +13,16 @@ # limitations under the License. +# ----------------------------------------------------------------- +# Determine which pass this is. +# ----------------------------------------------------------------- +# On the first pass, we are asked for only PRODUCT_RELEASE_CONFIG_MAPS, +# on the second pass, we are asked for whatever else is wanted. +_final_product_config_pass:= +ifneq (PRODUCT_RELEASE_CONFIG_MAPS,$(DUMP_MANY_VARS)) + _final_product_config_pass:=true +endif + # ----------------------------------------------------------------- # Choose the flag files # ----------------------------------------------------------------- @@ -90,7 +100,7 @@ $(foreach map,$(protobuf_map_files), \ ifneq (,$(_must_protobuf)) ifeq (,$(_can_protobuf)) - # We must use protobuf, but we cannot use protobuf. + # We must use protobuf, but we cannot use protobuf. $(error release config is a mixture of .scl and .textproto) endif endif @@ -120,11 +130,22 @@ ifneq (,$(_use_protobuf)) # Disable the build flag in release-config. _args += --guard=false endif - $(KATI_shell_no_rerun $(OUT_DIR)/release-config $(_args) >$(OUT_DIR)/release-config.out && touch -t 200001010000 $(OUT_DIR)/release-config.out) + _flags_file:=$(OUT_DIR)/soong/release-config/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).vars + # release-config generates $(_flags_varmk) + _flags_varmk:=$(_flags_file:.vars=.varmk) + $(shell $(OUT_DIR)/release-config $(_args) >$(OUT_DIR)/release-config.out 2>&1 && touch -t 200001010000 $(_flags_varmk)) $(if $(filter-out 0,$(.SHELLSTATUS)),$(error release-config failed to run)) - # This will also set _all_release_configs for us. - $(eval include $(OUT_DIR)/soong/release-config/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).mk) - $(KATI_extra_file_deps $(OUT_DIR)/release-config $(config_map_files)) + ifneq (,$(_final_product_config_pass)) + # Save the final version of the config. + $(shell if ! cmp --quiet $(_flags_varmk) $(_flags_file); then cp $(_flags_varmk) $(_flags_file); fi) + # This will also set _all_release_configs and _used_files for us. + $(eval include $(_flags_file)) + $(KATI_extra_file_deps $(OUT_DIR)/release-config $(protobuf_map_files) $(_flags_file)) + else + # This is the first pass of product config. + $(eval include $(_flags_varmk)) + endif + _used_files := ifeq (,$(_must_protobuf)$(RELEASE_BUILD_FLAGS_IN_PROTOBUF)) _use_protobuf := endif @@ -237,7 +258,7 @@ endif # During pass 1 of product config, using a non-existent release config is not an error. # We can safely assume that we are doing pass 1 if DUMP_MANY_VARS=="PRODUCT_RELEASE_CONFIG_MAPS". -ifneq (PRODUCT_RELEASE_CONFIG_MAPS,$(DUMP_MANY_VARS)) +ifneq (,$(_final_product_config_pass)) ifeq ($(filter $(_all_release_configs), $(TARGET_RELEASE)),) $(error No release config found for TARGET_RELEASE: $(TARGET_RELEASE). Available releases are: $(_all_release_configs)) endif From 551cc0da01d5ff38cb275475c844b7e6ebc6d5e4 Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Tue, 21 May 2024 23:43:49 +0000 Subject: [PATCH 54/65] Update Security String to 2024-07-01 Bug: 336526332 Change-Id: I6682f8b9c34c64ba638f02cbcc8dba9b3e6712fb Merged-In: I6682f8b9c34c64ba638f02cbcc8dba9b3e6712fb Merged-In: I34f13eec06f72ec1b8e2da7dbe9b1d42a3f16f01 Merged-In: I7259693a3393ce3b9d4cc3be40d8e5483dfb171a Merged-In: I5e96b7cf7fe9abda270a436d103f945f940342dc Merged-In: I9edc7171d124f0cfa540fea6f0e06ba877910444 --- 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 fa1445b389..efa3b4aa84 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 := 2024-06-01 + PLATFORM_SECURITY_PATCH := 2024-07-01 endif .KATI_READONLY := PLATFORM_SECURITY_PATCH From 3ada31ed55bb3c37c164fd4659b395b863112f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Kongstad?= Date: Wed, 22 May 2024 08:30:29 +0200 Subject: [PATCH 55/65] finalization: set FINAL_STATE to 'rel' VIC is set to REL. Accordingly, set FINAL_STATE to 'rel' to prevent the finalization scripts from running steps that have already been merged. Bug: 335304236 Test: treehugger (main-fina-2-release succeed) Ignore-AOSP-FIRST: arrives in aosp with ap3a Change-Id: Id42c3ae2ffead62ac6019690f0586d8db8d22ef8 --- 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 6593e78399..f68a68b650 100755 --- a/tools/finalization/environment.sh +++ b/tools/finalization/environment.sh @@ -22,7 +22,7 @@ export FINAL_MAINLINE_EXTENSION='13' # 'vintf' - VINTF is finalized # 'sdk' - VINTF and SDK/API are finalized # 'rel' - branch is finalized, switched to REL -export FINAL_STATE='sdk' +export FINAL_STATE='rel' export BUILD_FROM_SOURCE_STUB=true From 6b081071b82981b49ae90b38e11cb069669791f3 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Wed, 22 May 2024 14:40:11 -0700 Subject: [PATCH 56/65] Deliver all_release_configs.json as a build artifact Bug: 328495189 Test: manual Ignore-AOSP-First: cherry-pick Merged-In: Iebb07c303e6eae51d6c74dd80aa5ac2024b5629e Change-Id: Iebb07c303e6eae51d6c74dd80aa5ac2024b5629e --- core/release_config.mk | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core/release_config.mk b/core/release_config.mk index 5fe3d3905a..ae48bcf4a7 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -130,7 +130,8 @@ ifneq (,$(_use_protobuf)) # Disable the build flag in release-config. _args += --guard=false endif - _flags_file:=$(OUT_DIR)/soong/release-config/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).vars + _flags_dir:=$(OUT_DIR)/soong/release-config + _flags_file:=$(_flags_dir)/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).vars # release-config generates $(_flags_varmk) _flags_varmk:=$(_flags_file:.vars=.varmk) $(shell $(OUT_DIR)/release-config $(_args) >$(OUT_DIR)/release-config.out 2>&1 && touch -t 200001010000 $(_flags_varmk)) @@ -148,7 +149,21 @@ ifneq (,$(_use_protobuf)) _used_files := ifeq (,$(_must_protobuf)$(RELEASE_BUILD_FLAGS_IN_PROTOBUF)) _use_protobuf := + else + _base_all_release := all_release_configs-$(TARGET_PRODUCT) + $(call dist-for-goals,droid,\ + $(_flags_dir)/$(_base_all_release).pb:build_flags/all_release_configs.pb \ + $(_flags_dir)/$(_base_all_release).textproto:build_flags/all_release_configs.textproto \ + $(_flags_dir)/$(_base_all_release).json:build_flags/all_release_configs.json \ + ) +# These are always created, add an empty rule for them to keep ninja happy. +$(_flags_dir)/$(_base_all_release).pb $(_flags_dir)/$(_base_all_release).textproto $(_flags_dir)/$(_base_all_release).json: + : created by $(OUT_DIR)/release-config + _base_all_release := endif + _flags_dir:= + _flags_file:= + _flags_varmk:= endif ifeq (,$(_use_protobuf)) # The .mk files are the canonical source of truth. From 8663122eac15285a508091474e791d1257797ae7 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Thu, 30 May 2024 13:42:25 -0700 Subject: [PATCH 57/65] Require protobuf for build flags This change forces build flags from .scl to .textproto format. Bug: 328495189 Bug: 338450506 Test: manual, TH Ignore-AOSP-First: DNMA in aosp-main to avoid aosp-main-future Merged-In: Ia33aae158d62c12666d97449cea0c02b60550a21 Change-Id: Ia33aae158d62c12666d97449cea0c02b60550a21 --- core/release_config.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/release_config.mk b/core/release_config.mk index cfdfbcc6bb..24f7c61e5d 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -49,9 +49,6 @@ endif # 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. -_must_protobuf := config_map_files := $(wildcard build/release/release_config_map.mk) \ $(wildcard vendor/google_shared/build/release/release_config_map.mk) \ $(if $(wildcard vendor/google/release/release_config_map.mk), \ @@ -64,7 +61,7 @@ config_map_files := $(wildcard build/release/release_config_map.mk) \ ) \ ) -protobuf_map_files := $(wildcard build/release/release_config_map.textproto) \ +protobuf_map_files := build/release/release_config_map.textproto \ $(wildcard vendor/google_shared/build/release/release_config_map.textproto) \ $(if $(wildcard vendor/google/release/release_config_map.textproto), \ vendor/google/release/release_config_map.textproto, \ @@ -76,6 +73,9 @@ protobuf_map_files := $(wildcard build/release/release_config_map.textproto) \ ) \ ) +# Remove support for the legacy approach. +_must_protobuf := true + # PRODUCT_RELEASE_CONFIG_MAPS is set by Soong using an initial run of product # config to capture only the list of config maps needed by the build. # Keep them in the order provided, but remove duplicates. From 07609e780a3fdb466d60591e3071fff0471b7037 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Mon, 3 Jun 2024 17:39:10 +0000 Subject: [PATCH 58/65] Override map for enabling Go mainline module prebuilts The release config maps in `v/g_sh/b/r/gms_mainline_go/required` will be used to enable Go mainline prebuilts of mandatory modules by both internal google products and partner OEMs. Addition of `v/g_sh/b/r/gms_mainline_go/optional` is product dependent, and will have to be added separately Bug: 342265627 Test: lunch mokey_go32-ap3a-userdebug Test: verified that the following vars are same before and after change Test: get_build_var RELEASE_APEX_CONTRIBUTIONS_ADBD # go prebuilt Test: get_build_var RELEASE_APEX_CONTRIBUTIONS_REMOTEKEYPROVISIONING # go prebuilt Test: get_build_var RELEASE_APEX_CONTRIBUTIONS_UWB # go prebuilt Ignore-AOSP-First: part of a topic Change-Id: Ib80c4eef669dcfc3eaf8bb8dc5b9eb011d335fd0 --- target/product/go_defaults.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/product/go_defaults.mk b/target/product/go_defaults.mk index 7fbc09db74..dd6a955ce7 100644 --- a/target/product/go_defaults.mk +++ b/target/product/go_defaults.mk @@ -17,7 +17,8 @@ # Inherit common Android Go defaults. $(call inherit-product, build/make/target/product/go_defaults_common.mk) -PRODUCT_RELEASE_CONFIG_MAPS += $(wildcard vendor/google_shared/build/release/go_devices/release_config_map.mk) +# Product config map to toggle between sources and prebuilts of required mainline modules +PRODUCT_RELEASE_CONFIG_MAPS += $(wildcard vendor/google_shared/build/release/gms_mainline_go/required/release_config_map.textproto) # TODO (b/342265627): Remove v/g/r once all the flags have been moved to v/g_s/b/r PRODUCT_RELEASE_CONFIG_MAPS += $(wildcard vendor/google/release/go_devices/release_config_map.mk) From d0b3b82d20dbfad5b105dc99953b9983e95368d2 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Mon, 3 Jun 2024 22:04:56 +0000 Subject: [PATCH 59/65] DO NOT MERGE ANYWHERE Revert "Require protobuf for build flags" This reverts commit 8663122eac15285a508091474e791d1257797ae7. Reason for revert: Was DNMA aosp/main with same ChangeId. Will resubmit with new one, so that it actually merges. Change-Id: Ifa1b3b3901b88882f5ea790b0cc582bd828a8619 --- core/release_config.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/release_config.mk b/core/release_config.mk index 24f7c61e5d..cfdfbcc6bb 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -49,6 +49,9 @@ endif # 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. +_must_protobuf := config_map_files := $(wildcard build/release/release_config_map.mk) \ $(wildcard vendor/google_shared/build/release/release_config_map.mk) \ $(if $(wildcard vendor/google/release/release_config_map.mk), \ @@ -61,7 +64,7 @@ config_map_files := $(wildcard build/release/release_config_map.mk) \ ) \ ) -protobuf_map_files := build/release/release_config_map.textproto \ +protobuf_map_files := $(wildcard build/release/release_config_map.textproto) \ $(wildcard vendor/google_shared/build/release/release_config_map.textproto) \ $(if $(wildcard vendor/google/release/release_config_map.textproto), \ vendor/google/release/release_config_map.textproto, \ @@ -73,9 +76,6 @@ protobuf_map_files := build/release/release_config_map.textproto \ ) \ ) -# Remove support for the legacy approach. -_must_protobuf := true - # PRODUCT_RELEASE_CONFIG_MAPS is set by Soong using an initial run of product # config to capture only the list of config maps needed by the build. # Keep them in the order provided, but remove duplicates. From 2ef7438ff50d25be2e516ff7c38b0520133d33f2 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Tue, 4 Jun 2024 11:45:53 -0700 Subject: [PATCH 60/65] Require protobuf for build flags This change forces build flags from .scl to .textproto format. This change resubmits commit 8663122eac15285a508091474e791d1257797ae7 such that it will merge downstream. Bug: 328495189 Bug: 338450506 Test: manual, TH Ignore-AOSP-First: DNMA in aosp-main to avoid aosp-main-future Change-Id: I024f620b55e5e655f2b7b4764b217744334f7995 --- core/release_config.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/release_config.mk b/core/release_config.mk index cfdfbcc6bb..24f7c61e5d 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -49,9 +49,6 @@ endif # 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. -_must_protobuf := config_map_files := $(wildcard build/release/release_config_map.mk) \ $(wildcard vendor/google_shared/build/release/release_config_map.mk) \ $(if $(wildcard vendor/google/release/release_config_map.mk), \ @@ -64,7 +61,7 @@ config_map_files := $(wildcard build/release/release_config_map.mk) \ ) \ ) -protobuf_map_files := $(wildcard build/release/release_config_map.textproto) \ +protobuf_map_files := build/release/release_config_map.textproto \ $(wildcard vendor/google_shared/build/release/release_config_map.textproto) \ $(if $(wildcard vendor/google/release/release_config_map.textproto), \ vendor/google/release/release_config_map.textproto, \ @@ -76,6 +73,9 @@ protobuf_map_files := $(wildcard build/release/release_config_map.textproto) \ ) \ ) +# Remove support for the legacy approach. +_must_protobuf := true + # PRODUCT_RELEASE_CONFIG_MAPS is set by Soong using an initial run of product # config to capture only the list of config maps needed by the build. # Keep them in the order provided, but remove duplicates. From b89bb9d547c3bfdcd6943ffaf8e407508e22fd1a Mon Sep 17 00:00:00 2001 From: Yihan Dong Date: Fri, 7 Jun 2024 12:02:03 +0800 Subject: [PATCH 61/65] fix wrong mts folder issue Bug: 345042907 Test: m mts-mainline-infra Ignore-AOSP-First: For internal use Change-Id: I457403b0f9b50179d7b6ca9e13d1040b2a039b54 --- core/tasks/tools/compatibility.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/tasks/tools/compatibility.mk b/core/tasks/tools/compatibility.mk index 86c23f83d5..9189c2d58e 100644 --- a/core/tasks/tools/compatibility.mk +++ b/core/tasks/tools/compatibility.mk @@ -29,7 +29,9 @@ special_mts_test_suites := special_mts_test_suites += mcts special_mts_test_suites += $(mts_modules) -ifneq ($(filter $(special_mts_test_suites),$(subst -, ,$(test_suite_name))),) +ifneq ($(filter $(special_mts_test_suites),$(patsubst mcts-%,%,$(test_suite_name))),) + test_suite_subdir := android-mts +else ifneq ($(filter $(special_mts_test_suites),$(patsubst mts-%,%,$(test_suite_name))),) test_suite_subdir := android-mts else test_suite_subdir := android-$(test_suite_name) From eda868679481b32556b87024aca735c8de28800b Mon Sep 17 00:00:00 2001 From: Lance Chang Date: Sun, 9 Jun 2024 09:54:32 -0700 Subject: [PATCH 62/65] Add build number if TARGET_BUILD_APPS_WITH_BUILD_NUMBER is defined This change allows unbundled app builds to embed the build number in the version name by defining TARGET_BUILD_APPS_WITH_BUILD_NUMBER, so that APK files from a build can be easily identified. Ignore-AOSP-First: changes in topics with internal-only projects Test: manual build Bug: 340311907 Change-Id: I9a7e4f96f0d92c19d832933b5c68bd6b75ce9ce6 --- core/config.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/config.mk b/core/config.mk index 43304d5f8c..949ea54e91 100644 --- a/core/config.mk +++ b/core/config.mk @@ -1193,6 +1193,11 @@ RSCOMPAT_NO_USAGEIO_API_LEVELS := 8 9 10 11 12 13 APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION) +# Add BUILD_NUMBER to apps if TARGET_BUILD_APPS_WITH_BUILD_NUMBER is defined. +ifeq ($(TARGET_BUILD_APPS_WITH_BUILD_NUMBER),true) + APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)-$(BUILD_NUMBER_FROM_FILE) +endif + # ANDROID_WARNING_ALLOWED_PROJECTS is generated by build/soong. define find_warning_allowed_projects $(filter $(ANDROID_WARNING_ALLOWED_PROJECTS),$(1)/) From f61420f4c10708b7c908f43dd7d7f2443566460d Mon Sep 17 00:00:00 2001 From: Ankur Bakshi Date: Tue, 11 Jun 2024 04:04:13 +0000 Subject: [PATCH 63/65] Update Security String to 2024-08-01 Bug: 342381152 Change-Id: Iefbd1fff39d557fa352a53662d70bc734a255564 Merged-In: Iefbd1fff39d557fa352a53662d70bc734a255564 Merged-In: Ib4bd1d2496bab1fd22db8b7b362aa88631dd320a Merged-In: I2c5897803882d448ad511596d8d1c3650c065518 Merged-In: I9edc7171d124f0cfa540fea6f0e06ba877910444 --- 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 efa3b4aa84..42c351ca60 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 := 2024-07-01 + PLATFORM_SECURITY_PATCH := 2024-08-01 endif .KATI_READONLY := PLATFORM_SECURITY_PATCH From 7c282854f3148515deee26a70ff289f20a4fb62f Mon Sep 17 00:00:00 2001 From: Lance Chang Date: Mon, 10 Jun 2024 22:27:42 -0700 Subject: [PATCH 64/65] Change TARGET_BUILD_APPS_WITH_BUILD_NUMBER to a product variable This change allows unbundled app builds to embed the build number in the version name by defining PRODUCT_BUILD_APPS_WITH_BUILD_NUMBER, so that APK files from a build can be easily identified. Ignore-AOSP-First: changes in topics with internal-only projects Test: manual build Bug: 340311907 Change-Id: If7feda5eec2bc1e54a90b4adae1bd6da19e3ea45 --- core/config.mk | 4 ++-- core/product.mk | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/config.mk b/core/config.mk index 949ea54e91..4bb9a42943 100644 --- a/core/config.mk +++ b/core/config.mk @@ -1193,8 +1193,8 @@ RSCOMPAT_NO_USAGEIO_API_LEVELS := 8 9 10 11 12 13 APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION) -# Add BUILD_NUMBER to apps if TARGET_BUILD_APPS_WITH_BUILD_NUMBER is defined. -ifeq ($(TARGET_BUILD_APPS_WITH_BUILD_NUMBER),true) +# Add BUILD_NUMBER to apps if PRODUCT_BUILD_APPS_WITH_BUILD_NUMBER is defined. +ifeq ($(PRODUCT_BUILD_APPS_WITH_BUILD_NUMBER),true) APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)-$(BUILD_NUMBER_FROM_FILE) endif diff --git a/core/product.mk b/core/product.mk index 7908e1dcfe..d469c0e737 100644 --- a/core/product.mk +++ b/core/product.mk @@ -493,6 +493,9 @@ _product_single_value_vars += PRODUCT_16K_DEVELOPER_OPTION # by this flag. _product_single_value_vars += PRODUCT_NOT_DEBUGGABLE_IN_USERDEBUG +# If set, the default value of the versionName of apps will include the build number. +_product_single_value_vars += PRODUCT_BUILD_APPS_WITH_BUILD_NUMBER + .KATI_READONLY := _product_single_value_vars _product_list_vars _product_var_list :=$= $(_product_single_value_vars) $(_product_list_vars) From e8e66b8aa803653e250dc4dabb122dc3f9beab2a Mon Sep 17 00:00:00 2001 From: Ted Bauer Date: Thu, 13 Jun 2024 19:09:56 +0000 Subject: [PATCH 65/65] Read from new storage in Rust R/W flags Bug: 346991641 Test: m Change-Id: I23b7f7e8a1b43bbd5f49012c95a130d91098f92a Ignore-AOSP-First: internal storage migration, this code will be deleted --- tools/aconfig/aconfig/src/codegen/rust.rs | 661 +++++++++++++++++- tools/aconfig/aconfig/templates/rust.template | 64 +- .../aconfig_storage_read_api/src/lib.rs | 2 +- 3 files changed, 709 insertions(+), 18 deletions(-) diff --git a/tools/aconfig/aconfig/src/codegen/rust.rs b/tools/aconfig/aconfig/src/codegen/rust.rs index 7268e33a8e..45488b05f2 100644 --- a/tools/aconfig/aconfig/src/codegen/rust.rs +++ b/tools/aconfig/aconfig/src/codegen/rust.rs @@ -40,12 +40,14 @@ where .map(|pf| TemplateParsedFlag::new(package, flag_ids.clone(), &pf)) .collect(); let has_readwrite = template_flags.iter().any(|item| item.readwrite); + let container = (template_flags.first().expect("zero template flags").container).to_string(); let context = TemplateContext { package: package.to_string(), template_flags, modules: package.split('.').map(|s| s.to_string()).collect::>(), has_readwrite, allow_instrumentation, + container, }; let mut template = TinyTemplate::new(); template.add_template( @@ -69,6 +71,7 @@ struct TemplateContext { pub modules: Vec, pub has_readwrite: bool, pub allow_instrumentation: bool, + pub container: String, } #[derive(Serialize)] @@ -107,7 +110,7 @@ mod tests { const PROD_EXPECTED: &str = r#" //! codegenerated rust flag lib -use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_read_context}; +use aconfig_storage_read_api::{Mmap, AconfigStorageError, StorageFileType, PackageReadContext, get_mapped_storage_file, get_boolean_flag_value, get_package_read_context}; use std::path::Path; use std::io::Write; use log::{log, LevelFilter, Level}; @@ -244,6 +247,634 @@ pub fn enabled_ro_exported() -> bool { true } +/// query flag enabled_rw +#[inline(always)] +pub fn enabled_rw() -> bool { + PROVIDER.enabled_rw() +} +"#; + + const PROD_INSTRUMENTED_EXPECTED: &str = r#" +//! codegenerated rust flag lib +use aconfig_storage_read_api::{Mmap, AconfigStorageError, StorageFileType, PackageReadContext, get_mapped_storage_file, get_boolean_flag_value, get_package_read_context}; +use std::path::Path; +use std::io::Write; +use log::{log, LevelFilter, Level}; + +static STORAGE_MIGRATION_MARKER_FILE: &str = + "/metadata/aconfig_test_missions/mission_1"; +static MIGRATION_LOG_TAG: &str = "AconfigTestMission1"; + +/// flag provider +pub struct FlagProvider; + +lazy_static::lazy_static! { + + static ref PACKAGE_OFFSET: Result, AconfigStorageError> = unsafe { + get_mapped_storage_file("system", StorageFileType::PackageMap) + .and_then(|package_map| get_package_read_context(&package_map, "com.android.aconfig.test")) + .map(|context| context.map(|c| c.boolean_start_index)) + }; + + static ref FLAG_VAL_MAP: Result = unsafe { + get_mapped_storage_file("system", StorageFileType::FlagVal) + }; + /// flag value cache for disabled_rw + + static ref CACHED_disabled_rw: bool = { + let result = flags_rust::GetServerConfigurableFlag( + "aconfig_flags.aconfig_test", + "com.android.aconfig.test.disabled_rw", + "false") == "true"; + + if Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + // This will be called multiple times. Subsequent calls after the first are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info)); + + let aconfig_storage_result = FLAG_VAL_MAP + .as_ref() + .map_err(|err| format!("failed to get flag val map: {err}")) + .and_then(|flag_val_map| { + PACKAGE_OFFSET + .as_ref() + .map_err(|err| format!("failed to get package read offset: {err}")) + .and_then(|package_offset| { + match package_offset { + Some(offset) => { + get_boolean_flag_value(&flag_val_map, offset + 1) + .map_err(|err| format!("failed to get flag: {err}")) + }, + None => Err("no context found for package 'com.android.aconfig.test'".to_string()) + } + }) + }); + + match aconfig_storage_result { + Ok(storage_result) if storage_result == result => { + log!(Level::Info, "AconfigTestMission1: success! flag 'disabled_rw' contained correct value. Legacy storage was {result}, new storage was {storage_result}"); + }, + Ok(storage_result) => { + log!(Level::Error, "AconfigTestMission1: error: mismatch for flag 'disabled_rw'. Legacy storage was {result}, new storage was {storage_result}"); + }, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: {err}") + } + } + } + + result + }; + + /// flag value cache for disabled_rw_exported + + static ref CACHED_disabled_rw_exported: bool = { + let result = flags_rust::GetServerConfigurableFlag( + "aconfig_flags.aconfig_test", + "com.android.aconfig.test.disabled_rw_exported", + "false") == "true"; + + if Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + // This will be called multiple times. Subsequent calls after the first are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info)); + + let aconfig_storage_result = FLAG_VAL_MAP + .as_ref() + .map_err(|err| format!("failed to get flag val map: {err}")) + .and_then(|flag_val_map| { + PACKAGE_OFFSET + .as_ref() + .map_err(|err| format!("failed to get package read offset: {err}")) + .and_then(|package_offset| { + match package_offset { + Some(offset) => { + get_boolean_flag_value(&flag_val_map, offset + 2) + .map_err(|err| format!("failed to get flag: {err}")) + }, + None => Err("no context found for package 'com.android.aconfig.test'".to_string()) + } + }) + }); + + match aconfig_storage_result { + Ok(storage_result) if storage_result == result => { + log!(Level::Info, "AconfigTestMission1: success! flag 'disabled_rw_exported' contained correct value. Legacy storage was {result}, new storage was {storage_result}"); + }, + Ok(storage_result) => { + log!(Level::Error, "AconfigTestMission1: error: mismatch for flag 'disabled_rw_exported'. Legacy storage was {result}, new storage was {storage_result}"); + }, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: {err}") + } + } + } + + result + }; + + /// flag value cache for disabled_rw_in_other_namespace + + static ref CACHED_disabled_rw_in_other_namespace: bool = { + let result = flags_rust::GetServerConfigurableFlag( + "aconfig_flags.other_namespace", + "com.android.aconfig.test.disabled_rw_in_other_namespace", + "false") == "true"; + + if Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + // This will be called multiple times. Subsequent calls after the first are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info)); + + let aconfig_storage_result = FLAG_VAL_MAP + .as_ref() + .map_err(|err| format!("failed to get flag val map: {err}")) + .and_then(|flag_val_map| { + PACKAGE_OFFSET + .as_ref() + .map_err(|err| format!("failed to get package read offset: {err}")) + .and_then(|package_offset| { + match package_offset { + Some(offset) => { + get_boolean_flag_value(&flag_val_map, offset + 3) + .map_err(|err| format!("failed to get flag: {err}")) + }, + None => Err("no context found for package 'com.android.aconfig.test'".to_string()) + } + }) + }); + + match aconfig_storage_result { + Ok(storage_result) if storage_result == result => { + log!(Level::Info, "AconfigTestMission1: success! flag 'disabled_rw_in_other_namespace' contained correct value. Legacy storage was {result}, new storage was {storage_result}"); + }, + Ok(storage_result) => { + log!(Level::Error, "AconfigTestMission1: error: mismatch for flag 'disabled_rw_in_other_namespace'. Legacy storage was {result}, new storage was {storage_result}"); + }, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: {err}") + } + } + } + + result + }; + + /// flag value cache for enabled_rw + + static ref CACHED_enabled_rw: bool = { + let result = flags_rust::GetServerConfigurableFlag( + "aconfig_flags.aconfig_test", + "com.android.aconfig.test.enabled_rw", + "true") == "true"; + + if Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + // This will be called multiple times. Subsequent calls after the first are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info)); + + let aconfig_storage_result = FLAG_VAL_MAP + .as_ref() + .map_err(|err| format!("failed to get flag val map: {err}")) + .and_then(|flag_val_map| { + PACKAGE_OFFSET + .as_ref() + .map_err(|err| format!("failed to get package read offset: {err}")) + .and_then(|package_offset| { + match package_offset { + Some(offset) => { + get_boolean_flag_value(&flag_val_map, offset + 8) + .map_err(|err| format!("failed to get flag: {err}")) + }, + None => Err("no context found for package 'com.android.aconfig.test'".to_string()) + } + }) + }); + + match aconfig_storage_result { + Ok(storage_result) if storage_result == result => { + log!(Level::Info, "AconfigTestMission1: success! flag 'enabled_rw' contained correct value. Legacy storage was {result}, new storage was {storage_result}"); + }, + Ok(storage_result) => { + log!(Level::Error, "AconfigTestMission1: error: mismatch for flag 'enabled_rw'. Legacy storage was {result}, new storage was {storage_result}"); + }, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: {err}") + } + } + } + + result + }; + +} + +impl FlagProvider { + + + /// query flag disabled_ro + pub fn disabled_ro(&self) -> bool { + false + } + + /// query flag disabled_rw + pub fn disabled_rw(&self) -> bool { + *CACHED_disabled_rw + } + + /// query flag disabled_rw_exported + pub fn disabled_rw_exported(&self) -> bool { + *CACHED_disabled_rw_exported + } + + /// query flag disabled_rw_in_other_namespace + pub fn disabled_rw_in_other_namespace(&self) -> bool { + *CACHED_disabled_rw_in_other_namespace + } + + /// query flag enabled_fixed_ro + pub fn enabled_fixed_ro(&self) -> bool { + true + } + + /// query flag enabled_fixed_ro_exported + pub fn enabled_fixed_ro_exported(&self) -> bool { + true + } + + /// query flag enabled_ro + pub fn enabled_ro(&self) -> bool { + true + } + + /// query flag enabled_ro_exported + pub fn enabled_ro_exported(&self) -> bool { + true + } + + /// query flag enabled_rw + pub fn enabled_rw(&self) -> bool { + *CACHED_enabled_rw + } + + +} + +/// flag provider +pub static PROVIDER: FlagProvider = FlagProvider; + + +/// query flag disabled_ro +#[inline(always)] +pub fn disabled_ro() -> bool { + + + let result = false; + if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + return result; + } + + // This will be called multiple times. Subsequent calls after the first + // are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info), + ); + + unsafe { + let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { + Ok(file) => file, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'disabled_ro': {err}"); + return result; + } + }; + + let package_read_context = match get_package_read_context(&package_map, "com.android.aconfig.test") { + Ok(Some(context)) => context, + Ok(None) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'disabled_ro': did not get context"); + return result; + }, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'disabled_ro': {err}"); + return result; + } + }; + let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { + Ok(val_map) => val_map, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'disabled_ro': {err}"); + return result; + } + }; + let value = match get_boolean_flag_value(&flag_val_map, 0 + package_read_context.boolean_start_index) { + Ok(val) => val, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'disabled_ro': {err}"); + return result; + } + }; + + if result != value { + log!(Level::Error, "AconfigTestMission1: error: flag mismatch for 'disabled_ro'. Legacy storage was {result}, new storage was {value}"); + } else { + let default_value = false; + log!(Level::Info, "AconfigTestMission1: success! flag 'disabled_ro' contained correct value. Legacy storage was {default_value}, new storage was {value}"); + } + } + + result + +} + +/// query flag disabled_rw +#[inline(always)] +pub fn disabled_rw() -> bool { + PROVIDER.disabled_rw() +} + +/// query flag disabled_rw_exported +#[inline(always)] +pub fn disabled_rw_exported() -> bool { + PROVIDER.disabled_rw_exported() +} + +/// query flag disabled_rw_in_other_namespace +#[inline(always)] +pub fn disabled_rw_in_other_namespace() -> bool { + PROVIDER.disabled_rw_in_other_namespace() +} + +/// query flag enabled_fixed_ro +#[inline(always)] +pub fn enabled_fixed_ro() -> bool { + + + let result = true; + if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + return result; + } + + // This will be called multiple times. Subsequent calls after the first + // are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info), + ); + + unsafe { + let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { + Ok(file) => file, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_fixed_ro': {err}"); + return result; + } + }; + + let package_read_context = match get_package_read_context(&package_map, "com.android.aconfig.test") { + Ok(Some(context)) => context, + Ok(None) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_fixed_ro': did not get context"); + return result; + }, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_fixed_ro': {err}"); + return result; + } + }; + let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { + Ok(val_map) => val_map, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_fixed_ro': {err}"); + return result; + } + }; + let value = match get_boolean_flag_value(&flag_val_map, 4 + package_read_context.boolean_start_index) { + Ok(val) => val, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_fixed_ro': {err}"); + return result; + } + }; + + if result != value { + log!(Level::Error, "AconfigTestMission1: error: flag mismatch for 'enabled_fixed_ro'. Legacy storage was {result}, new storage was {value}"); + } else { + let default_value = true; + log!(Level::Info, "AconfigTestMission1: success! flag 'enabled_fixed_ro' contained correct value. Legacy storage was {default_value}, new storage was {value}"); + } + } + + result + +} + +/// query flag enabled_fixed_ro_exported +#[inline(always)] +pub fn enabled_fixed_ro_exported() -> bool { + + + let result = true; + if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + return result; + } + + // This will be called multiple times. Subsequent calls after the first + // are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info), + ); + + unsafe { + let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { + Ok(file) => file, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_fixed_ro_exported': {err}"); + return result; + } + }; + + let package_read_context = match get_package_read_context(&package_map, "com.android.aconfig.test") { + Ok(Some(context)) => context, + Ok(None) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_fixed_ro_exported': did not get context"); + return result; + }, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_fixed_ro_exported': {err}"); + return result; + } + }; + let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { + Ok(val_map) => val_map, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_fixed_ro_exported': {err}"); + return result; + } + }; + let value = match get_boolean_flag_value(&flag_val_map, 5 + package_read_context.boolean_start_index) { + Ok(val) => val, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_fixed_ro_exported': {err}"); + return result; + } + }; + + if result != value { + log!(Level::Error, "AconfigTestMission1: error: flag mismatch for 'enabled_fixed_ro_exported'. Legacy storage was {result}, new storage was {value}"); + } else { + let default_value = true; + log!(Level::Info, "AconfigTestMission1: success! flag 'enabled_fixed_ro_exported' contained correct value. Legacy storage was {default_value}, new storage was {value}"); + } + } + + result + +} + +/// query flag enabled_ro +#[inline(always)] +pub fn enabled_ro() -> bool { + + + let result = true; + if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + return result; + } + + // This will be called multiple times. Subsequent calls after the first + // are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info), + ); + + unsafe { + let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { + Ok(file) => file, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_ro': {err}"); + return result; + } + }; + + let package_read_context = match get_package_read_context(&package_map, "com.android.aconfig.test") { + Ok(Some(context)) => context, + Ok(None) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_ro': did not get context"); + return result; + }, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_ro': {err}"); + return result; + } + }; + let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { + Ok(val_map) => val_map, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_ro': {err}"); + return result; + } + }; + let value = match get_boolean_flag_value(&flag_val_map, 6 + package_read_context.boolean_start_index) { + Ok(val) => val, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_ro': {err}"); + return result; + } + }; + + if result != value { + log!(Level::Error, "AconfigTestMission1: error: flag mismatch for 'enabled_ro'. Legacy storage was {result}, new storage was {value}"); + } else { + let default_value = true; + log!(Level::Info, "AconfigTestMission1: success! flag 'enabled_ro' contained correct value. Legacy storage was {default_value}, new storage was {value}"); + } + } + + result + +} + +/// query flag enabled_ro_exported +#[inline(always)] +pub fn enabled_ro_exported() -> bool { + + + let result = true; + if !Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() { + return result; + } + + // This will be called multiple times. Subsequent calls after the first + // are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info), + ); + + unsafe { + let package_map = match get_mapped_storage_file("system", StorageFileType::PackageMap) { + Ok(file) => file, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_ro_exported': {err}"); + return result; + } + }; + + let package_read_context = match get_package_read_context(&package_map, "com.android.aconfig.test") { + Ok(Some(context)) => context, + Ok(None) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_ro_exported': did not get context"); + return result; + }, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_ro_exported': {err}"); + return result; + } + }; + let flag_val_map = match get_mapped_storage_file("system", StorageFileType::FlagVal) { + Ok(val_map) => val_map, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_ro_exported': {err}"); + return result; + } + }; + let value = match get_boolean_flag_value(&flag_val_map, 7 + package_read_context.boolean_start_index) { + Ok(val) => val, + Err(err) => { + log!(Level::Error, "AconfigTestMission1: error: failed to read flag 'enabled_ro_exported': {err}"); + return result; + } + }; + + if result != value { + log!(Level::Error, "AconfigTestMission1: error: flag mismatch for 'enabled_ro_exported'. Legacy storage was {result}, new storage was {value}"); + } else { + let default_value = true; + log!(Level::Info, "AconfigTestMission1: success! flag 'enabled_ro_exported' contained correct value. Legacy storage was {default_value}, new storage was {value}"); + } + } + + result + +} + /// query flag enabled_rw #[inline(always)] pub fn enabled_rw() -> bool { @@ -510,7 +1141,7 @@ pub fn reset_flags() { const EXPORTED_EXPECTED: &str = r#" //! codegenerated rust flag lib -use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_read_context}; +use aconfig_storage_read_api::{Mmap, AconfigStorageError, StorageFileType, PackageReadContext, get_mapped_storage_file, get_boolean_flag_value, get_package_read_context}; use std::path::Path; use std::io::Write; use log::{log, LevelFilter, Level}; @@ -584,7 +1215,7 @@ pub fn enabled_ro_exported() -> bool { const FORCE_READ_ONLY_EXPECTED: &str = r#" //! codegenerated rust flag lib -use aconfig_storage_read_api::{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_read_context}; +use aconfig_storage_read_api::{Mmap, AconfigStorageError, StorageFileType, PackageReadContext, get_mapped_storage_file, get_boolean_flag_value, get_package_read_context}; use std::path::Path; use std::io::Write; use log::{log, LevelFilter, Level}; @@ -669,7 +1300,7 @@ pub fn enabled_rw() -> bool { "#; use crate::commands::assign_flag_ids; - fn test_generate_rust_code(mode: CodegenMode, instrumentation: bool) { + fn test_generate_rust_code(mode: CodegenMode, allow_instrumentation: bool, expected: &str) { let parsed_flags = crate::test::parse_test_flags(); let modified_parsed_flags = crate::commands::modify_parsed_flags_based_on_mode(parsed_flags, mode).unwrap(); @@ -680,19 +1311,14 @@ pub fn enabled_rw() -> bool { flag_ids, modified_parsed_flags.into_iter(), mode, - instrumentation, + allow_instrumentation, ) .unwrap(); assert_eq!("src/lib.rs", format!("{}", generated.path.display())); assert_eq!( None, crate::test::first_significant_code_diff( - match mode { - CodegenMode::Production => PROD_EXPECTED, - CodegenMode::Test => TEST_EXPECTED, - CodegenMode::Exported => EXPORTED_EXPECTED, - CodegenMode::ForceReadOnly => FORCE_READ_ONLY_EXPECTED, - }, + expected, &String::from_utf8(generated.contents).unwrap() ) ); @@ -700,21 +1326,26 @@ pub fn enabled_rw() -> bool { #[test] fn test_generate_rust_code_for_prod() { - test_generate_rust_code(CodegenMode::Production, false); + test_generate_rust_code(CodegenMode::Production, false, PROD_EXPECTED); + } + + #[test] + fn test_generate_rust_code_for_prod_instrumented() { + test_generate_rust_code(CodegenMode::Production, true, PROD_INSTRUMENTED_EXPECTED); } #[test] fn test_generate_rust_code_for_test() { - test_generate_rust_code(CodegenMode::Test, false); + test_generate_rust_code(CodegenMode::Test, false, TEST_EXPECTED); } #[test] fn test_generate_rust_code_for_exported() { - test_generate_rust_code(CodegenMode::Exported, false); + test_generate_rust_code(CodegenMode::Exported, false, EXPORTED_EXPECTED); } #[test] fn test_generate_rust_code_for_force_read_only() { - test_generate_rust_code(CodegenMode::ForceReadOnly, false); + test_generate_rust_code(CodegenMode::ForceReadOnly, false, FORCE_READ_ONLY_EXPECTED); } } diff --git a/tools/aconfig/aconfig/templates/rust.template b/tools/aconfig/aconfig/templates/rust.template index ea9831eba7..cfd9d6aec8 100644 --- a/tools/aconfig/aconfig/templates/rust.template +++ b/tools/aconfig/aconfig/templates/rust.template @@ -1,6 +1,5 @@ //! codegenerated rust flag lib - -use aconfig_storage_read_api::\{StorageFileType, get_mapped_storage_file, get_boolean_flag_value, get_package_read_context}; +use aconfig_storage_read_api::\{Mmap, AconfigStorageError, StorageFileType, PackageReadContext, get_mapped_storage_file, get_boolean_flag_value, get_package_read_context}; use std::path::Path; use std::io::Write; use log::\{log, LevelFilter, Level}; @@ -14,13 +13,74 @@ pub struct FlagProvider; {{ if has_readwrite- }} lazy_static::lazy_static! \{ + {{ if allow_instrumentation }} + static ref PACKAGE_OFFSET: Result, AconfigStorageError> = unsafe \{ + get_mapped_storage_file("{container}", StorageFileType::PackageMap) + .and_then(|package_map| get_package_read_context(&package_map, "{package}")) + .map(|context| context.map(|c| c.boolean_start_index)) + }; + + static ref FLAG_VAL_MAP: Result = unsafe \{ + get_mapped_storage_file("{container}", StorageFileType::FlagVal) + }; + {{ -endif }} + {{ -for flag in template_flags }} {{ -if flag.readwrite }} /// flag value cache for {flag.name} + {{ if allow_instrumentation }} + static ref CACHED_{flag.name}: bool = \{ + let result = flags_rust::GetServerConfigurableFlag( + "aconfig_flags.{flag.device_config_namespace}", + "{flag.device_config_flag}", + "{flag.default_value}") == "true"; + + if Path::new(STORAGE_MIGRATION_MARKER_FILE).exists() \{ + // This will be called multiple times. Subsequent calls after the first are noops. + logger::init( + logger::Config::default() + .with_tag_on_device(MIGRATION_LOG_TAG) + .with_max_level(LevelFilter::Info)); + + let aconfig_storage_result = FLAG_VAL_MAP + .as_ref() + .map_err(|err| format!("failed to get flag val map: \{err}")) + .and_then(|flag_val_map| \{ + PACKAGE_OFFSET + .as_ref() + .map_err(|err| format!("failed to get package read offset: \{err}")) + .and_then(|package_offset| \{ + match package_offset \{ + Some(offset) => \{ + get_boolean_flag_value(&flag_val_map, offset + {flag.flag_offset}) + .map_err(|err| format!("failed to get flag: \{err}")) + }, + None => Err("no context found for package '{package}'".to_string()) + } + }) + }); + + match aconfig_storage_result \{ + Ok(storage_result) if storage_result == result => \{ + log!(Level::Info, "AconfigTestMission1: success! flag '{flag.name}' contained correct value. Legacy storage was \{result}, new storage was \{storage_result}"); + }, + Ok(storage_result) => \{ + log!(Level::Error, "AconfigTestMission1: error: mismatch for flag '{flag.name}'. Legacy storage was \{result}, new storage was \{storage_result}"); + }, + Err(err) => \{ + log!(Level::Error, "AconfigTestMission1: error: \{err}") + } + } + } + + result + }; + {{ else }} static ref CACHED_{flag.name}: bool = flags_rust::GetServerConfigurableFlag( "aconfig_flags.{flag.device_config_namespace}", "{flag.device_config_flag}", "{flag.default_value}") == "true"; + {{ endif }} {{ -endif }} {{ -endfor }} } diff --git a/tools/aconfig/aconfig_storage_read_api/src/lib.rs b/tools/aconfig/aconfig_storage_read_api/src/lib.rs index 61f9e96f84..d76cf3fe4e 100644 --- a/tools/aconfig/aconfig_storage_read_api/src/lib.rs +++ b/tools/aconfig/aconfig_storage_read_api/src/lib.rs @@ -53,7 +53,7 @@ use flag_value_query::find_boolean_flag_value; use package_table_query::find_package_read_context; use anyhow::anyhow; -use memmap2::Mmap; +pub use memmap2::Mmap; use std::fs::File; use std::io::Read;