From e693333507fa1e8fd803bb6af10dbc5c9cd21ea9 Mon Sep 17 00:00:00 2001 From: Lev Proleev Date: Tue, 15 Dec 2020 19:47:42 +0000 Subject: [PATCH 001/148] Add NNAPI AIDL interface to allowed deps Bug: 172922059 Test: build Change-Id: I5e0dce33d1090e548a7d9901ffe747439c11df29 --- apex/allowed_deps.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apex/allowed_deps.txt b/apex/allowed_deps.txt index 5ed41e643..7c8678512 100644 --- a/apex/allowed_deps.txt +++ b/apex/allowed_deps.txt @@ -38,6 +38,7 @@ android.hardware.media.c2@1.0(minSdkVersion:29) android.hardware.media.c2@1.1(minSdkVersion:29) android.hardware.media.omx@1.0(minSdkVersion:29) android.hardware.media@1.0(minSdkVersion:29) +android.hardware.neuralnetworks-V1-ndk_platform(minSdkVersion:30) android.hardware.neuralnetworks@1.0(minSdkVersion:30) android.hardware.neuralnetworks@1.1(minSdkVersion:30) android.hardware.neuralnetworks@1.2(minSdkVersion:30) @@ -537,6 +538,7 @@ neuralnetworks_utils_hal_1_0(minSdkVersion:30) neuralnetworks_utils_hal_1_1(minSdkVersion:30) neuralnetworks_utils_hal_1_2(minSdkVersion:30) neuralnetworks_utils_hal_1_3(minSdkVersion:30) +neuralnetworks_utils_hal_aidl(minSdkVersion:30) neuralnetworks_utils_hal_common(minSdkVersion:30) neuralnetworks_utils_hal_service(minSdkVersion:30) note_memtag_heap_async(minSdkVersion:16) From 2315330064cb3c134ddfe9dd7d063b23c1e7fb4d Mon Sep 17 00:00:00 2001 From: Linus Nilsson Date: Mon, 1 Mar 2021 16:15:21 -0800 Subject: [PATCH 002/148] Add statslog_media dependency to media module. To support logging transcoding metrics to westworld a small auto generated wrapper lib is needed to send structured data to statsd. Bug: 179274112 Test: Will verify build with presubmit Change-Id: I9b3a0b1825b7acb9859b92b9a52b3550e31ef1f1 --- apex/allowed_deps.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/apex/allowed_deps.txt b/apex/allowed_deps.txt index 9680d3c50..b4e44719f 100644 --- a/apex/allowed_deps.txt +++ b/apex/allowed_deps.txt @@ -495,6 +495,7 @@ libstagefright_mpeg2extractor(minSdkVersion:29) libstagefright_mpeg2support_nocrypto(minSdkVersion:29) libstats_jni(minSdkVersion:(no version)) libstats_jni(minSdkVersion:30) +libstatslog_media(minSdkVersion:29) libstatslog_resolv(minSdkVersion:29) libstatslog_statsd(minSdkVersion:(no version)) libstatslog_statsd(minSdkVersion:30) From e05d4cca6c2133a7f7f2db6d0e5b67c97fe9da1c Mon Sep 17 00:00:00 2001 From: Chang Li Date: Mon, 22 Feb 2021 20:53:54 +0000 Subject: [PATCH 003/148] Allow WorkManager, android_downloader_lib and common concurrency libs. This is for a mainline feature. (b/178099790) Bug: 180441353 Change-Id: I5f017fcc7829a67f8fd99a28b9096fa8123b4297 --- apex/allowed_deps.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apex/allowed_deps.txt b/apex/allowed_deps.txt index 1ec4b0c26..fe28b7930 100644 --- a/apex/allowed_deps.txt +++ b/apex/allowed_deps.txt @@ -75,6 +75,7 @@ android.hidl.token@1.0-utils(minSdkVersion:29) android.net.ipsec.ike(minSdkVersion:30) android.net.ipsec.ike(minSdkVersion:current) android.net.ipsec.ike.xml(minSdkVersion:(no version)) +android_downloader_lib(minSdkVersion:30) androidx-constraintlayout_constraintlayout(minSdkVersion:14) androidx-constraintlayout_constraintlayout-solver(minSdkVersion:24) androidx.activity_activity(minSdkVersion:14) @@ -90,6 +91,7 @@ androidx.autofill_autofill(minSdkVersion:14) androidx.cardview_cardview(minSdkVersion:14) androidx.collection_collection(minSdkVersion:24) androidx.collection_collection-ktx(minSdkVersion:24) +androidx.concurrent_concurrent-futures(minSdkVersion:24) androidx.coordinatorlayout_coordinatorlayout(minSdkVersion:14) androidx.core_core(minSdkVersion:14) androidx.core_core-ktx(minSdkVersion:14) @@ -136,9 +138,13 @@ androidx.preference_preference(minSdkVersion:14) androidx.print_print(minSdkVersion:14) androidx.recyclerview_recyclerview(minSdkVersion:14) androidx.recyclerview_recyclerview-selection(minSdkVersion:14) +androidx.room_room-common(minSdkVersion:24) +androidx.room_room-runtime(minSdkVersion:14) androidx.savedstate_savedstate(minSdkVersion:14) androidx.savedstate_savedstate-ktx(minSdkVersion:14) androidx.slidingpanelayout_slidingpanelayout(minSdkVersion:14) +androidx.sqlite_sqlite(minSdkVersion:14) +androidx.sqlite_sqlite-framework(minSdkVersion:14) androidx.swiperefreshlayout_swiperefreshlayout(minSdkVersion:14) androidx.tracing_tracing(minSdkVersion:14) androidx.transition_transition(minSdkVersion:14) @@ -147,6 +153,7 @@ androidx.vectordrawable_vectordrawable-animated(minSdkVersion:14) androidx.versionedparcelable_versionedparcelable(minSdkVersion:14) androidx.viewpager2_viewpager2(minSdkVersion:14) androidx.viewpager_viewpager(minSdkVersion:14) +androidx.work_work-runtime(minSdkVersion:14) apache-commons-compress(minSdkVersion:current) art.module.public.api.stubs(minSdkVersion:(no version)) audio_common-aidl-unstable-cpp(minSdkVersion:29) @@ -626,6 +633,7 @@ prebuilt_androidx.autofill_autofill-nodeps(minSdkVersion:(no version)) prebuilt_androidx.cardview_cardview-nodeps(minSdkVersion:(no version)) prebuilt_androidx.collection_collection-ktx-nodeps(minSdkVersion:current) prebuilt_androidx.collection_collection-nodeps(minSdkVersion:current) +prebuilt_androidx.concurrent_concurrent-futures-nodeps(minSdkVersion:current) prebuilt_androidx.coordinatorlayout_coordinatorlayout-nodeps(minSdkVersion:(no version)) prebuilt_androidx.core_core-ktx-nodeps(minSdkVersion:(no version)) prebuilt_androidx.core_core-nodeps(minSdkVersion:(no version)) @@ -670,9 +678,13 @@ prebuilt_androidx.preference_preference-nodeps(minSdkVersion:(no version)) prebuilt_androidx.print_print-nodeps(minSdkVersion:(no version)) prebuilt_androidx.recyclerview_recyclerview-nodeps(minSdkVersion:(no version)) prebuilt_androidx.recyclerview_recyclerview-selection-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.room_room-common-nodeps(minSdkVersion:current) +prebuilt_androidx.room_room-runtime-nodeps(minSdkVersion:(no version)) prebuilt_androidx.savedstate_savedstate-ktx-nodeps(minSdkVersion:(no version)) prebuilt_androidx.savedstate_savedstate-nodeps(minSdkVersion:(no version)) prebuilt_androidx.slidingpanelayout_slidingpanelayout-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.sqlite_sqlite-framework-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.sqlite_sqlite-nodeps(minSdkVersion:(no version)) prebuilt_androidx.swiperefreshlayout_swiperefreshlayout-nodeps(minSdkVersion:(no version)) prebuilt_androidx.tracing_tracing-nodeps(minSdkVersion:(no version)) prebuilt_androidx.transition_transition-nodeps(minSdkVersion:(no version)) @@ -681,8 +693,10 @@ prebuilt_androidx.vectordrawable_vectordrawable-nodeps(minSdkVersion:(no version prebuilt_androidx.versionedparcelable_versionedparcelable-nodeps(minSdkVersion:(no version)) prebuilt_androidx.viewpager2_viewpager2-nodeps(minSdkVersion:(no version)) prebuilt_androidx.viewpager_viewpager-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.work_work-runtime-nodeps(minSdkVersion:(no version)) prebuilt_com.google.android.material_material-nodeps(minSdkVersion:(no version)) prebuilt_error_prone_annotations(minSdkVersion:(no version)) +prebuilt_guava-listenablefuture-prebuilt-jar(minSdkVersion:current) prebuilt_kotlin-stdlib(minSdkVersion:current) prebuilt_kotlinx-coroutines-android-nodeps(minSdkVersion:(no version)) prebuilt_kotlinx-coroutines-core-nodeps(minSdkVersion:(no version)) @@ -731,6 +745,7 @@ TetheringApiCurrentLib(minSdkVersion:30) TetheringApiCurrentLib(minSdkVersion:current) TetheringGoogle(minSdkVersion:30) TetheringGoogle(minSdkVersion:current) +textclassifier-java-proto-lite(minSdkVersion:30) textclassifier-statsd(minSdkVersion:30) textclassifier-statsd(minSdkVersion:current) TextClassifierNotificationLibNoManifest(minSdkVersion:29) From 993a1398e07f91e2417c8cf73705470b1c2785d7 Mon Sep 17 00:00:00 2001 From: Chris Wailes Date: Wed, 27 Jan 2021 15:03:28 -0800 Subject: [PATCH 004/148] Add test suite to legacy core platform allowlist. Test: atest DexManagerTests Bug: 174783329 Change-Id: Ife2be3cbc15f06ae382c08c2d6a5c5962feb0caf --- java/legacy_core_platform_api_usage.go | 1 + 1 file changed, 1 insertion(+) diff --git a/java/legacy_core_platform_api_usage.go b/java/legacy_core_platform_api_usage.go index 2de11bfb7..a0c3e7e85 100644 --- a/java/legacy_core_platform_api_usage.go +++ b/java/legacy_core_platform_api_usage.go @@ -96,6 +96,7 @@ var legacyCorePlatformApiModules = []string{ "FrameworksNetTests", "FrameworksServicesRoboTests", "FrameworksServicesTests", + "FrameworksMockingServicesTests", "FrameworksUtilTests", "GtsIncrementalInstallTestCases", "GtsIncrementalInstallTriggerApp", From 732d6264210513b971205b5c9f1b2f49b9cafdf3 Mon Sep 17 00:00:00 2001 From: Artur Satayev Date: Thu, 11 Mar 2021 16:45:04 +0000 Subject: [PATCH 005/148] Move allowed_deps.txt to packages/modules/common. Bug: 179234385 Test: run update-apex-allowed-deps.sh locally Change-Id: I8e8864468b87342c688d001bc5f6e6f8416863ed --- apex/OWNERS | 3 - apex/allowed_deps.txt | 753 ---------------------------- apex/apex_singleton.go | 6 +- scripts/update-apex-allowed-deps.sh | 39 -- 4 files changed, 3 insertions(+), 798 deletions(-) delete mode 100644 apex/allowed_deps.txt delete mode 100755 scripts/update-apex-allowed-deps.sh diff --git a/apex/OWNERS b/apex/OWNERS index fee739b56..8e4ba5cd5 100644 --- a/apex/OWNERS +++ b/apex/OWNERS @@ -1,4 +1 @@ per-file * = jiyong@google.com - -per-file allowed_deps.txt = set noparent -per-file allowed_deps.txt = dariofreni@google.com,hansson@google.com,harpin@google.com,jiyong@google.com,narayan@google.com,jham@google.com diff --git a/apex/allowed_deps.txt b/apex/allowed_deps.txt deleted file mode 100644 index ffbf6e4c1..000000000 --- a/apex/allowed_deps.txt +++ /dev/null @@ -1,753 +0,0 @@ -# A list of allowed dependencies for all updatable modules. -# -# The list tracks all direct and transitive dependencies that end up within any -# of the updatable binaries; specifically excluding external dependencies -# required to compile those binaries. This prevents potential regressions in -# case a new dependency is not aware of the different functional and -# non-functional requirements being part of an updatable module, for example -# setting correct min_sdk_version. -# -# To update the list, run: -# repo-root$ build/soong/scripts/update-apex-allowed-deps.sh -# -# See go/apex-allowed-deps-error for more details. -# TODO(b/157465465): introduce automated quality signals and remove this list. - -adbd(minSdkVersion:(no version)) -android.hardware.cas.native@1.0(minSdkVersion:29) -android.hardware.cas@1.0(minSdkVersion:29) -android.hardware.common-ndk_platform(minSdkVersion:29) -android.hardware.common-unstable-ndk_platform(minSdkVersion:29) -android.hardware.common-V2-ndk_platform(minSdkVersion:29) -android.hardware.graphics.allocator@2.0(minSdkVersion:29) -android.hardware.graphics.allocator@3.0(minSdkVersion:29) -android.hardware.graphics.allocator@4.0(minSdkVersion:29) -android.hardware.graphics.bufferqueue@1.0(minSdkVersion:29) -android.hardware.graphics.bufferqueue@2.0(minSdkVersion:29) -android.hardware.graphics.common-ndk_platform(minSdkVersion:29) -android.hardware.graphics.common-unstable-ndk_platform(minSdkVersion:29) -android.hardware.graphics.common-V2-ndk_platform(minSdkVersion:29) -android.hardware.graphics.common@1.0(minSdkVersion:29) -android.hardware.graphics.common@1.1(minSdkVersion:29) -android.hardware.graphics.common@1.2(minSdkVersion:29) -android.hardware.graphics.mapper@2.0(minSdkVersion:29) -android.hardware.graphics.mapper@2.1(minSdkVersion:29) -android.hardware.graphics.mapper@3.0(minSdkVersion:29) -android.hardware.graphics.mapper@4.0(minSdkVersion:29) -android.hardware.media.bufferpool@2.0(minSdkVersion:29) -android.hardware.media.c2@1.0(minSdkVersion:29) -android.hardware.media.c2@1.1(minSdkVersion:29) -android.hardware.media.omx@1.0(minSdkVersion:29) -android.hardware.media@1.0(minSdkVersion:29) -android.hardware.neuralnetworks-V1-ndk_platform(minSdkVersion:30) -android.hardware.neuralnetworks@1.0(minSdkVersion:30) -android.hardware.neuralnetworks@1.1(minSdkVersion:30) -android.hardware.neuralnetworks@1.2(minSdkVersion:30) -android.hardware.neuralnetworks@1.3(minSdkVersion:30) -android.hardware.tetheroffload.config-V1.0-java(minSdkVersion:current) -android.hardware.tetheroffload.control-V1.0-java(minSdkVersion:current) -android.hardware.wifi-V1.0-java(minSdkVersion:30) -android.hardware.wifi-V1.0-java-constants(minSdkVersion:30) -android.hardware.wifi-V1.1-java(minSdkVersion:30) -android.hardware.wifi-V1.2-java(minSdkVersion:30) -android.hardware.wifi-V1.3-java(minSdkVersion:30) -android.hardware.wifi-V1.4-java(minSdkVersion:30) -android.hardware.wifi-V1.5-java(minSdkVersion:30) -android.hardware.wifi.hostapd-V1.0-java(minSdkVersion:30) -android.hardware.wifi.hostapd-V1.1-java(minSdkVersion:30) -android.hardware.wifi.hostapd-V1.2-java(minSdkVersion:30) -android.hardware.wifi.hostapd-V1.3-java(minSdkVersion:30) -android.hardware.wifi.supplicant-V1.0-java(minSdkVersion:30) -android.hardware.wifi.supplicant-V1.1-java(minSdkVersion:30) -android.hardware.wifi.supplicant-V1.2-java(minSdkVersion:30) -android.hardware.wifi.supplicant-V1.3-java(minSdkVersion:30) -android.hardware.wifi.supplicant-V1.4-java(minSdkVersion:30) -android.hidl.allocator@1.0(minSdkVersion:29) -android.hidl.base-V1.0-java(minSdkVersion:current) -android.hidl.manager-V1.0-java(minSdkVersion:30) -android.hidl.manager-V1.1-java(minSdkVersion:30) -android.hidl.manager-V1.2-java(minSdkVersion:30) -android.hidl.memory.token@1.0(minSdkVersion:29) -android.hidl.memory@1.0(minSdkVersion:29) -android.hidl.safe_union@1.0(minSdkVersion:29) -android.hidl.token@1.0(minSdkVersion:29) -android.hidl.token@1.0-utils(minSdkVersion:29) -android.net.ipsec.ike(minSdkVersion:30) -android.net.ipsec.ike(minSdkVersion:current) -android.net.ipsec.ike.xml(minSdkVersion:(no version)) -androidx-constraintlayout_constraintlayout(minSdkVersion:14) -androidx-constraintlayout_constraintlayout-solver(minSdkVersion:24) -androidx.activity_activity(minSdkVersion:14) -androidx.activity_activity-ktx(minSdkVersion:14) -androidx.annotation_annotation(minSdkVersion:24) -androidx.annotation_annotation-experimental(minSdkVersion:14) -androidx.appcompat_appcompat(minSdkVersion:14) -androidx.appcompat_appcompat-resources(minSdkVersion:14) -androidx.arch.core_core-common(minSdkVersion:24) -androidx.arch.core_core-runtime(minSdkVersion:14) -androidx.asynclayoutinflater_asynclayoutinflater(minSdkVersion:14) -androidx.autofill_autofill(minSdkVersion:14) -androidx.cardview_cardview(minSdkVersion:14) -androidx.collection_collection(minSdkVersion:24) -androidx.collection_collection-ktx(minSdkVersion:24) -androidx.coordinatorlayout_coordinatorlayout(minSdkVersion:14) -androidx.core_core(minSdkVersion:14) -androidx.core_core-ktx(minSdkVersion:14) -androidx.cursoradapter_cursoradapter(minSdkVersion:14) -androidx.customview_customview(minSdkVersion:14) -androidx.documentfile_documentfile(minSdkVersion:14) -androidx.drawerlayout_drawerlayout(minSdkVersion:14) -androidx.dynamicanimation_dynamicanimation(minSdkVersion:14) -androidx.fragment_fragment(minSdkVersion:14) -androidx.fragment_fragment-ktx(minSdkVersion:14) -androidx.interpolator_interpolator(minSdkVersion:14) -androidx.leanback_leanback(minSdkVersion:17) -androidx.leanback_leanback-preference(minSdkVersion:21) -androidx.legacy_legacy-preference-v14(minSdkVersion:14) -androidx.legacy_legacy-support-core-ui(minSdkVersion:14) -androidx.legacy_legacy-support-core-utils(minSdkVersion:14) -androidx.legacy_legacy-support-v13(minSdkVersion:14) -androidx.legacy_legacy-support-v4(minSdkVersion:14) -androidx.lifecycle_lifecycle-common(minSdkVersion:24) -androidx.lifecycle_lifecycle-common-java8(minSdkVersion:24) -androidx.lifecycle_lifecycle-extensions(minSdkVersion:14) -androidx.lifecycle_lifecycle-livedata(minSdkVersion:14) -androidx.lifecycle_lifecycle-livedata-core(minSdkVersion:14) -androidx.lifecycle_lifecycle-livedata-core-ktx(minSdkVersion:14) -androidx.lifecycle_lifecycle-process(minSdkVersion:14) -androidx.lifecycle_lifecycle-runtime(minSdkVersion:14) -androidx.lifecycle_lifecycle-runtime-ktx(minSdkVersion:14) -androidx.lifecycle_lifecycle-service(minSdkVersion:14) -androidx.lifecycle_lifecycle-viewmodel(minSdkVersion:14) -androidx.lifecycle_lifecycle-viewmodel-ktx(minSdkVersion:14) -androidx.lifecycle_lifecycle-viewmodel-savedstate(minSdkVersion:14) -androidx.loader_loader(minSdkVersion:14) -androidx.localbroadcastmanager_localbroadcastmanager(minSdkVersion:14) -androidx.media_media(minSdkVersion:14) -androidx.navigation_navigation-common(minSdkVersion:14) -androidx.navigation_navigation-common-ktx(minSdkVersion:14) -androidx.navigation_navigation-fragment(minSdkVersion:14) -androidx.navigation_navigation-fragment-ktx(minSdkVersion:14) -androidx.navigation_navigation-runtime(minSdkVersion:14) -androidx.navigation_navigation-runtime-ktx(minSdkVersion:14) -androidx.navigation_navigation-ui(minSdkVersion:14) -androidx.navigation_navigation-ui-ktx(minSdkVersion:14) -androidx.preference_preference(minSdkVersion:14) -androidx.print_print(minSdkVersion:14) -androidx.recyclerview_recyclerview(minSdkVersion:14) -androidx.recyclerview_recyclerview-selection(minSdkVersion:14) -androidx.savedstate_savedstate(minSdkVersion:14) -androidx.savedstate_savedstate-ktx(minSdkVersion:14) -androidx.slidingpanelayout_slidingpanelayout(minSdkVersion:14) -androidx.swiperefreshlayout_swiperefreshlayout(minSdkVersion:14) -androidx.tracing_tracing(minSdkVersion:14) -androidx.transition_transition(minSdkVersion:14) -androidx.vectordrawable_vectordrawable(minSdkVersion:14) -androidx.vectordrawable_vectordrawable-animated(minSdkVersion:14) -androidx.versionedparcelable_versionedparcelable(minSdkVersion:14) -androidx.viewpager2_viewpager2(minSdkVersion:14) -androidx.viewpager_viewpager(minSdkVersion:14) -apache-commons-compress(minSdkVersion:current) -art.module.public.api.stubs(minSdkVersion:(no version)) -audio_common-aidl-unstable-cpp(minSdkVersion:29) -audioclient-types-aidl-cpp(minSdkVersion:29) -audioclient-types-aidl-unstable-cpp(minSdkVersion:29) -audioflinger-aidl-cpp(minSdkVersion:29) -audioflinger-aidl-unstable-cpp(minSdkVersion:29) -audiopolicy-aidl-cpp(minSdkVersion:29) -audiopolicy-aidl-unstable-cpp(minSdkVersion:29) -av-headers(minSdkVersion:29) -av-types-aidl-cpp(minSdkVersion:29) -av-types-aidl-unstable-cpp(minSdkVersion:29) -bcm_object(minSdkVersion:29) -bionic_libc_platform_headers(minSdkVersion:29) -boringssl_self_test(minSdkVersion:29) -bouncycastle-unbundled(minSdkVersion:30) -bouncycastle_ike_digests(minSdkVersion:current) -bpf_syscall_wrappers(minSdkVersion:30) -brotli-java(minSdkVersion:current) -captiveportal-lib(minSdkVersion:29) -car-ui-lib(minSdkVersion:28) -car-ui-lib-overlayable(minSdkVersion:28) -CellBroadcastApp(minSdkVersion:29) -CellBroadcastServiceModule(minSdkVersion:29) -codecs_g711dec(minSdkVersion:29) -com.google.android.material_material(minSdkVersion:14) -conscrypt(minSdkVersion:29) -conscrypt.module.platform.api.stubs(minSdkVersion:(no version)) -conscrypt.module.public.api.stubs(minSdkVersion:(no version)) -core-lambda-stubs(minSdkVersion:(no version)) -core.current.stubs(minSdkVersion:(no version)) -crtbegin_dynamic(minSdkVersion:16) -crtbegin_dynamic(minSdkVersion:apex_inherit) -crtbegin_dynamic1(minSdkVersion:16) -crtbegin_dynamic1(minSdkVersion:apex_inherit) -crtbegin_so(minSdkVersion:16) -crtbegin_so(minSdkVersion:apex_inherit) -crtbegin_so1(minSdkVersion:16) -crtbegin_so1(minSdkVersion:apex_inherit) -crtbrand(minSdkVersion:16) -crtbrand(minSdkVersion:apex_inherit) -crtend_android(minSdkVersion:16) -crtend_android(minSdkVersion:apex_inherit) -crtend_so(minSdkVersion:16) -crtend_so(minSdkVersion:apex_inherit) -datastallprotosnano(minSdkVersion:29) -derive_classpath(minSdkVersion:30) -derive_sdk(minSdkVersion:30) -derive_sdk(minSdkVersion:current) -derive_sdk_prefer32(minSdkVersion:30) -derive_sdk_prefer32(minSdkVersion:current) -dnsresolver_aidl_interface-lateststable-ndk_platform(minSdkVersion:29) -dnsresolver_aidl_interface-unstable-ndk_platform(minSdkVersion:29) -dnsresolver_aidl_interface-V7-ndk_platform(minSdkVersion:29) -dnsresolver_aidl_interface-V8-ndk_platform(minSdkVersion:29) -DocumentsUI-res-lib(minSdkVersion:29) -exoplayer2-extractor(minSdkVersion:16) -exoplayer2-extractor-annotation-stubs(minSdkVersion:16) -ExtServices(minSdkVersion:30) -ExtServices(minSdkVersion:current) -ExtServices-core(minSdkVersion:30) -ExtServices-core(minSdkVersion:current) -flatbuffer_headers(minSdkVersion:(no version)) -fmtlib(minSdkVersion:29) -fmtlib_ndk(minSdkVersion:29) -framework-mediaprovider(minSdkVersion:30) -framework-permission(minSdkVersion:30) -framework-permission(minSdkVersion:current) -framework-permission-s(minSdkVersion:30) -framework-permission-s-shared(minSdkVersion:30) -framework-scheduling(minSdkVersion:current) -framework-sdkextensions(minSdkVersion:30) -framework-sdkextensions(minSdkVersion:current) -framework-statsd(minSdkVersion:30) -framework-statsd(minSdkVersion:current) -framework-tethering(minSdkVersion:30) -framework-tethering(minSdkVersion:current) -framework-wifi(minSdkVersion:30) -framework-wifi-util-lib(minSdkVersion:30) -gemmlowp_headers(minSdkVersion:(no version)) -geotz(minSdkVersion:current) -geotz_lookup(minSdkVersion:current) -geotz_s2storage_ro(minSdkVersion:current) -GoogleCellBroadcastApp(minSdkVersion:29) -GoogleCellBroadcastServiceModule(minSdkVersion:29) -GoogleExtServices(minSdkVersion:30) -GoogleExtServices(minSdkVersion:current) -GooglePermissionController(minSdkVersion:30) -guava(minSdkVersion:current) -gwp_asan_headers(minSdkVersion:(no version)) -i18n.module.public.api.stubs(minSdkVersion:(no version)) -iconloader(minSdkVersion:21) -ike-internals(minSdkVersion:current) -InProcessTethering(minSdkVersion:30) -InProcessTethering(minSdkVersion:current) -ipmemorystore-aidl-interfaces-java(minSdkVersion:29) -ipmemorystore-aidl-interfaces-unstable-java(minSdkVersion:29) -ipmemorystore-aidl-interfaces-V10-java(minSdkVersion:29) -ipmemorystore-aidl-interfaces-V11-java(minSdkVersion:29) -jni_headers(minSdkVersion:29) -jsr305(minSdkVersion:14) -kotlinx-coroutines-android(minSdkVersion:current) -kotlinx-coroutines-core(minSdkVersion:current) -ksoap2(minSdkVersion:30) -legacy.art.module.platform.api.stubs(minSdkVersion:(no version)) -legacy.core.platform.api.stubs(minSdkVersion:(no version)) -legacy.i18n.module.platform.api.stubs(minSdkVersion:(no version)) -libaacextractor(minSdkVersion:29) -libadb_crypto(minSdkVersion:(no version)) -libadb_pairing_auth(minSdkVersion:(no version)) -libadb_pairing_connection(minSdkVersion:(no version)) -libadb_pairing_server(minSdkVersion:(no version)) -libadb_protos(minSdkVersion:(no version)) -libadb_sysdeps(minSdkVersion:apex_inherit) -libadb_tls_connection(minSdkVersion:(no version)) -libadbconnection_client(minSdkVersion:(no version)) -libadbconnection_server(minSdkVersion:(no version)) -libadbd(minSdkVersion:(no version)) -libadbd_core(minSdkVersion:(no version)) -libadbd_services(minSdkVersion:(no version)) -liballoc.rust_sysroot(minSdkVersion:(no version)) -libamrextractor(minSdkVersion:29) -libapp_processes_protos_lite(minSdkVersion:(no version)) -libarect(minSdkVersion:29) -libasyncio(minSdkVersion:(no version)) -libatomic(minSdkVersion:(no version)) -libaudio_system_headers(minSdkVersion:29) -libaudioclient_aidl_conversion(minSdkVersion:29) -libaudioclient_aidl_conversion_util(minSdkVersion:29) -libaudioclient_headers(minSdkVersion:29) -libaudiofoundation_headers(minSdkVersion:29) -libaudioutils(minSdkVersion:29) -libaudioutils_fixedfft(minSdkVersion:29) -libavcdec(minSdkVersion:29) -libavcenc(minSdkVersion:29) -libavservices_minijail(minSdkVersion:29) -libbacktrace_headers(minSdkVersion:apex_inherit) -libbacktrace_rs.rust_sysroot(minSdkVersion:(no version)) -libbacktrace_sys.rust_sysroot(minSdkVersion:(no version)) -libbase(minSdkVersion:29) -libbase_headers(minSdkVersion:29) -libbase_ndk(minSdkVersion:29) -libbinder(minSdkVersion:29) -libbinder_headers(minSdkVersion:29) -libbinder_headers_platform_shared(minSdkVersion:29) -libbinderthreadstateutils(minSdkVersion:29) -libbluetooth-types-header(minSdkVersion:29) -libbrotli(minSdkVersion:(no version)) -libbuildversion(minSdkVersion:(no version)) -libc(minSdkVersion:(no version)) -libc++(minSdkVersion:apex_inherit) -libc++_static(minSdkVersion:apex_inherit) -libc++abi(minSdkVersion:apex_inherit) -libc++demangle(minSdkVersion:apex_inherit) -libc_headers(minSdkVersion:apex_inherit) -libc_headers_arch(minSdkVersion:apex_inherit) -libcap(minSdkVersion:29) -libcfg_if(minSdkVersion:(no version)) -libcfg_if.rust_sysroot(minSdkVersion:(no version)) -libclang_rt.hwasan-aarch64-android.llndk(minSdkVersion:(no version)) -libcodec2(minSdkVersion:29) -libcodec2_headers(minSdkVersion:29) -libcodec2_hidl@1.0(minSdkVersion:29) -libcodec2_hidl@1.1(minSdkVersion:29) -libcodec2_internal(minSdkVersion:29) -libcodec2_soft_aacdec(minSdkVersion:29) -libcodec2_soft_aacenc(minSdkVersion:29) -libcodec2_soft_amrnbdec(minSdkVersion:29) -libcodec2_soft_amrnbenc(minSdkVersion:29) -libcodec2_soft_amrwbdec(minSdkVersion:29) -libcodec2_soft_amrwbenc(minSdkVersion:29) -libcodec2_soft_av1dec_gav1(minSdkVersion:29) -libcodec2_soft_avcdec(minSdkVersion:29) -libcodec2_soft_avcenc(minSdkVersion:29) -libcodec2_soft_common(minSdkVersion:29) -libcodec2_soft_flacdec(minSdkVersion:29) -libcodec2_soft_flacenc(minSdkVersion:29) -libcodec2_soft_g711alawdec(minSdkVersion:29) -libcodec2_soft_g711mlawdec(minSdkVersion:29) -libcodec2_soft_gsmdec(minSdkVersion:29) -libcodec2_soft_h263dec(minSdkVersion:29) -libcodec2_soft_h263enc(minSdkVersion:29) -libcodec2_soft_hevcdec(minSdkVersion:29) -libcodec2_soft_hevcenc(minSdkVersion:29) -libcodec2_soft_mp3dec(minSdkVersion:29) -libcodec2_soft_mpeg2dec(minSdkVersion:29) -libcodec2_soft_mpeg4dec(minSdkVersion:29) -libcodec2_soft_mpeg4enc(minSdkVersion:29) -libcodec2_soft_opusdec(minSdkVersion:29) -libcodec2_soft_opusenc(minSdkVersion:29) -libcodec2_soft_rawdec(minSdkVersion:29) -libcodec2_soft_vorbisdec(minSdkVersion:29) -libcodec2_soft_vp8dec(minSdkVersion:29) -libcodec2_soft_vp8enc(minSdkVersion:29) -libcodec2_soft_vp9dec(minSdkVersion:29) -libcodec2_soft_vp9enc(minSdkVersion:29) -libcodec2_vndk(minSdkVersion:29) -libcompiler_builtins.rust_sysroot(minSdkVersion:(no version)) -libcore.rust_sysroot(minSdkVersion:(no version)) -libcrypto(minSdkVersion:29) -libcrypto_static(minSdkVersion:(no version)) -libcrypto_utils(minSdkVersion:(no version)) -libcutils(minSdkVersion:29) -libcutils_headers(minSdkVersion:29) -libcutils_sockets(minSdkVersion:29) -libderive_classpath(minSdkVersion:30) -libderive_sdk(minSdkVersion:30) -libdiagnose_usb(minSdkVersion:(no version)) -libdl(minSdkVersion:(no version)) -libdmabufheap(minSdkVersion:29) -libeigen(minSdkVersion:(no version)) -libextservices(minSdkVersion:30) -libextservices_jni(minSdkVersion:30) -libfft2d(minSdkVersion:30) -libfifo(minSdkVersion:29) -libFLAC(minSdkVersion:29) -libFLAC-config(minSdkVersion:29) -libFLAC-headers(minSdkVersion:29) -libflacextractor(minSdkVersion:29) -libfmq(minSdkVersion:29) -libfmq-base(minSdkVersion:29) -libFraunhoferAAC(minSdkVersion:29) -libfuse(minSdkVersion:30) -libfuse_jni(minSdkVersion:30) -libgav1(minSdkVersion:29) -libgcc(minSdkVersion:(no version)) -libgcc_stripped(minSdkVersion:(no version)) -libgetopts(minSdkVersion:(no version)) -libgralloctypes(minSdkVersion:29) -libgrallocusage(minSdkVersion:29) -libgsm(minSdkVersion:apex_inherit) -libgtest_prod(minSdkVersion:apex_inherit) -libgui_bufferqueue_static(minSdkVersion:29) -libgui_headers(minSdkVersion:29) -libhardware(minSdkVersion:29) -libhardware_headers(minSdkVersion:29) -libhashbrown.rust_sysroot(minSdkVersion:(no version)) -libhevcdec(minSdkVersion:29) -libhevcenc(minSdkVersion:29) -libhidlbase(minSdkVersion:29) -libhidlmemory(minSdkVersion:29) -libhwbinder-impl-internal(minSdkVersion:29) -libhwbinder_headers(minSdkVersion:29) -libion(minSdkVersion:29) -libjavacrypto(minSdkVersion:29) -libjsoncpp(minSdkVersion:29) -liblazy_static(minSdkVersion:(no version)) -liblibc(minSdkVersion:(no version)) -liblibc.rust_sysroot(minSdkVersion:(no version)) -libLibGuiProperties(minSdkVersion:29) -liblibm(minSdkVersion:(no version)) -liblog(minSdkVersion:(no version)) -liblog_headers(minSdkVersion:29) -liblog_rust(minSdkVersion:(no version)) -liblua(minSdkVersion:(no version)) -liblua(minSdkVersion:30) -liblz4(minSdkVersion:(no version)) -libm(minSdkVersion:(no version)) -libmath(minSdkVersion:29) -libmath_headers(minSdkVersion:apex_inherit) -libmdnssd(minSdkVersion:(no version)) -libmedia_codecserviceregistrant(minSdkVersion:29) -libmedia_datasource_headers(minSdkVersion:29) -libmedia_headers(minSdkVersion:29) -libmedia_helper_headers(minSdkVersion:29) -libmedia_midiiowrapper(minSdkVersion:29) -libmediaparser-jni(minSdkVersion:29) -libmediatranscoder(minSdkVersion:29) -libmediatranscoding(minSdkVersion:29) -libmediatranscodingservice(minSdkVersion:29) -libmidiextractor(minSdkVersion:29) -libminijail(minSdkVersion:29) -libminijail_gen_constants(minSdkVersion:(no version)) -libminijail_gen_constants_obj(minSdkVersion:29) -libminijail_gen_syscall(minSdkVersion:(no version)) -libminijail_gen_syscall_obj(minSdkVersion:29) -libminijail_generated(minSdkVersion:29) -libmkvextractor(minSdkVersion:29) -libmodules-utils-build(minSdkVersion:29) -libmp3extractor(minSdkVersion:29) -libmp4extractor(minSdkVersion:29) -libmpeg2dec(minSdkVersion:29) -libmpeg2extractor(minSdkVersion:29) -libnanohttpd(minSdkVersion:30) -libnativebase_headers(minSdkVersion:29) -libnativehelper_compat_libc++(minSdkVersion:(no version)) -libnativehelper_header_only(minSdkVersion:29) -libnativewindow_headers(minSdkVersion:29) -libnetd_resolv(minSdkVersion:29) -libnetdbinder_utils_headers(minSdkVersion:29) -libnetdutils(minSdkVersion:29) -libnetjniutils(minSdkVersion:29) -libnetworkstackutilsjni(minSdkVersion:29) -libneuralnetworks(minSdkVersion:(no version)) -libneuralnetworks_common(minSdkVersion:(no version)) -libneuralnetworks_headers(minSdkVersion:(no version)) -liboggextractor(minSdkVersion:29) -libonce_cell(minSdkVersion:(no version)) -libopus(minSdkVersion:29) -libpanic_unwind.rust_sysroot(minSdkVersion:(no version)) -libprocessgroup(minSdkVersion:29) -libprocessgroup_headers(minSdkVersion:29) -libprocpartition(minSdkVersion:(no version)) -libprofile-clang-extras(minSdkVersion:(no version)) -libprofile-clang-extras_cfi_support(minSdkVersion:(no version)) -libprofile-clang-extras_ndk(minSdkVersion:(no version)) -libprofile-extras(minSdkVersion:(no version)) -libprofile-extras_ndk(minSdkVersion:(no version)) -libprofiler_builtins.rust_sysroot(minSdkVersion:(no version)) -libprotobuf-cpp-lite(minSdkVersion:29) -libprotobuf-java-lite(minSdkVersion:current) -libprotobuf-java-nano(minSdkVersion:9) -libprotoutil(minSdkVersion:(no version)) -libqemu_pipe(minSdkVersion:(no version)) -libquiche_ffi(minSdkVersion:(no version)) -libquiche_ffi_headers(minSdkVersion:29) -libring(minSdkVersion:(no version)) -libring-core(minSdkVersion:29) -librustc_demangle.rust_sysroot(minSdkVersion:(no version)) -libruy_static(minSdkVersion:30) -libsdk_proto(minSdkVersion:30) -libsfplugin_ccodec_utils(minSdkVersion:29) -libshmemcompat(minSdkVersion:29) -libshmemutil(minSdkVersion:29) -libsonivoxwithoutjet(minSdkVersion:29) -libspeexresampler(minSdkVersion:29) -libspin(minSdkVersion:(no version)) -libssl(minSdkVersion:29) -libstagefright_amrnb_common(minSdkVersion:29) -libstagefright_amrnbdec(minSdkVersion:29) -libstagefright_amrnbenc(minSdkVersion:29) -libstagefright_amrwbdec(minSdkVersion:29) -libstagefright_amrwbenc(minSdkVersion:29) -libstagefright_bufferpool@2.0.1(minSdkVersion:29) -libstagefright_bufferqueue_helper(minSdkVersion:29) -libstagefright_bufferqueue_helper_novndk(minSdkVersion:29) -libstagefright_enc_common(minSdkVersion:29) -libstagefright_esds(minSdkVersion:29) -libstagefright_flacdec(minSdkVersion:29) -libstagefright_foundation(minSdkVersion:29) -libstagefright_foundation_headers(minSdkVersion:29) -libstagefright_foundation_without_imemory(minSdkVersion:29) -libstagefright_headers(minSdkVersion:29) -libstagefright_id3(minSdkVersion:29) -libstagefright_m4vh263dec(minSdkVersion:29) -libstagefright_m4vh263enc(minSdkVersion:29) -libstagefright_metadatautils(minSdkVersion:29) -libstagefright_mp3dec(minSdkVersion:29) -libstagefright_mp3dec_headers(minSdkVersion:29) -libstagefright_mpeg2extractor(minSdkVersion:29) -libstagefright_mpeg2support_nocrypto(minSdkVersion:29) -libstats_jni(minSdkVersion:(no version)) -libstats_jni(minSdkVersion:30) -libstatslog_media(minSdkVersion:29) -libstatslog_resolv(minSdkVersion:29) -libstatslog_statsd(minSdkVersion:(no version)) -libstatslog_statsd(minSdkVersion:30) -libstatspull(minSdkVersion:(no version)) -libstatspull(minSdkVersion:30) -libstatspush_compat(minSdkVersion:29) -libstatssocket(minSdkVersion:(no version)) -libstatssocket(minSdkVersion:30) -libstatssocket_headers(minSdkVersion:29) -libstd(minSdkVersion:(no version)) -libsystem_headers(minSdkVersion:apex_inherit) -libsysutils(minSdkVersion:apex_inherit) -libterm(minSdkVersion:(no version)) -libtest(minSdkVersion:(no version)) -libtetherutilsjni(minSdkVersion:30) -libtetherutilsjni(minSdkVersion:current) -libtextclassifier(minSdkVersion:(no version)) -libtextclassifier(minSdkVersion:30) -libtextclassifier-java(minSdkVersion:28) -libtextclassifier_abseil(minSdkVersion:30) -libtextclassifier_flatbuffer_headers(minSdkVersion:(no version)) -libtextclassifier_flatbuffer_headers(minSdkVersion:30) -libtextclassifier_hash_headers(minSdkVersion:(no version)) -libtextclassifier_hash_static(minSdkVersion:(no version)) -libtflite_kernel_utils(minSdkVersion:(no version)) -libtflite_static(minSdkVersion:(no version)) -libtflite_static(minSdkVersion:30) -libui(minSdkVersion:29) -libui-types(minSdkVersion:apex_inherit) -libui_headers(minSdkVersion:29) -libunicode_width.rust_sysroot(minSdkVersion:(no version)) -libuntrusted(minSdkVersion:(no version)) -libunwind.rust_sysroot(minSdkVersion:(no version)) -libunwind_llvm(minSdkVersion:apex_inherit) -libutf(minSdkVersion:(no version)) -libutils(minSdkVersion:apex_inherit) -libutils_headers(minSdkVersion:apex_inherit) -libvorbisidec(minSdkVersion:29) -libvpx(minSdkVersion:29) -libwatchdog(minSdkVersion:29) -libwavextractor(minSdkVersion:29) -libwebm(minSdkVersion:29) -libyuv(minSdkVersion:29) -libyuv_static(minSdkVersion:29) -libzstd(minSdkVersion:(no version)) -marisa-trie(minSdkVersion:(no version)) -marisa-trie(minSdkVersion:30) -media_ndk_headers(minSdkVersion:29) -media_plugin_headers(minSdkVersion:29) -MediaProvider(minSdkVersion:30) -MediaProviderGoogle(minSdkVersion:30) -mediaswcodec(minSdkVersion:29) -mediatranscoding(minSdkVersion:29) -mediatranscoding_aidl_interface-java(minSdkVersion:29) -mediatranscoding_aidl_interface-ndk_platform(minSdkVersion:29) -metrics-constants-protos(minSdkVersion:29) -modules-annotation-minsdk(minSdkVersion:29) -modules-utils-build(minSdkVersion:29) -modules-utils-build_system(minSdkVersion:29) -modules-utils-os(minSdkVersion:30) -ndk_crtbegin_so.19(minSdkVersion:(no version)) -ndk_crtbegin_so.21(minSdkVersion:(no version)) -ndk_crtbegin_so.27(minSdkVersion:(no version)) -ndk_crtend_so.19(minSdkVersion:(no version)) -ndk_crtend_so.21(minSdkVersion:(no version)) -ndk_crtend_so.27(minSdkVersion:(no version)) -ndk_libandroid_support(minSdkVersion:(no version)) -ndk_libc++_static(minSdkVersion:(no version)) -ndk_libc++_static(minSdkVersion:16) -ndk_libc++abi(minSdkVersion:(no version)) -ndk_libc++abi(minSdkVersion:16) -ndk_libunwind(minSdkVersion:16) -net-utils-device-common(minSdkVersion:29) -net-utils-framework-common(minSdkVersion:current) -netd-client(minSdkVersion:29) -netd_aidl_interface-java(minSdkVersion:29) -netd_aidl_interface-lateststable-java(minSdkVersion:29) -netd_aidl_interface-unstable-java(minSdkVersion:29) -netd_aidl_interface-V3-java(minSdkVersion:29) -netd_aidl_interface-V5-java(minSdkVersion:29) -netd_aidl_interface-V6-java(minSdkVersion:29) -netd_event_listener_interface-java(minSdkVersion:29) -netd_event_listener_interface-lateststable-ndk_platform(minSdkVersion:29) -netd_event_listener_interface-ndk_platform(minSdkVersion:29) -netd_event_listener_interface-unstable-ndk_platform(minSdkVersion:29) -netd_event_listener_interface-V1-ndk_platform(minSdkVersion:29) -netd_event_listener_interface-V2-ndk_platform(minSdkVersion:29) -netlink-client(minSdkVersion:29) -networkstack-aidl-interfaces-java(minSdkVersion:29) -networkstack-aidl-interfaces-unstable-java(minSdkVersion:29) -networkstack-aidl-interfaces-V10-java(minSdkVersion:29) -networkstack-aidl-interfaces-V9-java(minSdkVersion:29) -networkstack-client(minSdkVersion:29) -NetworkStackApi29Shims(minSdkVersion:29) -NetworkStackApi30Shims(minSdkVersion:29) -NetworkStackApiStableDependencies(minSdkVersion:29) -NetworkStackApiStableLib(minSdkVersion:29) -NetworkStackApiStableShims(minSdkVersion:29) -networkstackprotos(minSdkVersion:29) -NetworkStackShimsCommon(minSdkVersion:29) -neuralnetworks_types(minSdkVersion:30) -neuralnetworks_utils_hal_1_0(minSdkVersion:30) -neuralnetworks_utils_hal_1_1(minSdkVersion:30) -neuralnetworks_utils_hal_1_2(minSdkVersion:30) -neuralnetworks_utils_hal_1_3(minSdkVersion:30) -neuralnetworks_utils_hal_aidl(minSdkVersion:30) -neuralnetworks_utils_hal_common(minSdkVersion:30) -neuralnetworks_utils_hal_service(minSdkVersion:30) -no_op(minSdkVersion:current) -note_memtag_heap_async(minSdkVersion:16) -note_memtag_heap_sync(minSdkVersion:16) -offlinelocationtimezoneprovider(minSdkVersion:current) -OsuLogin(minSdkVersion:30) -OsuLoginGoogle(minSdkVersion:30) -PermissionController(minSdkVersion:30) -permissioncontroller-statsd(minSdkVersion:current) -philox_random(minSdkVersion:(no version)) -philox_random_headers(minSdkVersion:(no version)) -prebuilt_androidx-constraintlayout_constraintlayout-nodeps(minSdkVersion:(no version)) -prebuilt_androidx-constraintlayout_constraintlayout-solver-nodeps(minSdkVersion:current) -prebuilt_androidx.activity_activity-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.activity_activity-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.annotation_annotation-experimental-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.annotation_annotation-nodeps(minSdkVersion:current) -prebuilt_androidx.appcompat_appcompat-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.appcompat_appcompat-resources-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.arch.core_core-common-nodeps(minSdkVersion:current) -prebuilt_androidx.arch.core_core-runtime-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.asynclayoutinflater_asynclayoutinflater-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.autofill_autofill-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.cardview_cardview-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.collection_collection-ktx-nodeps(minSdkVersion:current) -prebuilt_androidx.collection_collection-nodeps(minSdkVersion:current) -prebuilt_androidx.coordinatorlayout_coordinatorlayout-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.core_core-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.core_core-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.cursoradapter_cursoradapter-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.customview_customview-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.documentfile_documentfile-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.drawerlayout_drawerlayout-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.dynamicanimation_dynamicanimation-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.fragment_fragment-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.fragment_fragment-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.interpolator_interpolator-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.leanback_leanback-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.leanback_leanback-preference-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.legacy_legacy-support-core-ui-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.legacy_legacy-support-core-utils-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.legacy_legacy-support-v13-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-common-java8-nodeps(minSdkVersion:current) -prebuilt_androidx.lifecycle_lifecycle-common-nodeps(minSdkVersion:current) -prebuilt_androidx.lifecycle_lifecycle-extensions-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-livedata-core-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-livedata-core-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-livedata-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-process-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-runtime-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-runtime-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-service-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-viewmodel-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-viewmodel-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-viewmodel-savedstate-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.loader_loader-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.localbroadcastmanager_localbroadcastmanager-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.media_media-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-common-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-common-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-fragment-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-fragment-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-runtime-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-runtime-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-ui-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-ui-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.preference_preference-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.print_print-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.recyclerview_recyclerview-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.recyclerview_recyclerview-selection-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.savedstate_savedstate-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.savedstate_savedstate-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.slidingpanelayout_slidingpanelayout-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.swiperefreshlayout_swiperefreshlayout-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.tracing_tracing-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.transition_transition-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.vectordrawable_vectordrawable-animated-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.vectordrawable_vectordrawable-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.versionedparcelable_versionedparcelable-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.viewpager2_viewpager2-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.viewpager_viewpager-nodeps(minSdkVersion:(no version)) -prebuilt_com.google.android.material_material-nodeps(minSdkVersion:(no version)) -prebuilt_error_prone_annotations(minSdkVersion:(no version)) -prebuilt_kotlin-stdlib(minSdkVersion:current) -prebuilt_kotlinx-coroutines-android-nodeps(minSdkVersion:(no version)) -prebuilt_kotlinx-coroutines-core-nodeps(minSdkVersion:(no version)) -prebuilt_libclang_rt.builtins-aarch64-android(minSdkVersion:(no version)) -prebuilt_libclang_rt.builtins-arm-android(minSdkVersion:(no version)) -prebuilt_libclang_rt.builtins-i686-android(minSdkVersion:(no version)) -prebuilt_libclang_rt.builtins-x86_64-android(minSdkVersion:(no version)) -prebuilt_libunwind(minSdkVersion:(no version)) -prebuilt_test_framework-sdkextensions(minSdkVersion:(no version)) -resourceobserver_aidl_interface-ndk_platform(minSdkVersion:29) -resourceobserver_aidl_interface-V1-ndk_platform(minSdkVersion:29) -s2-geometry-library-java(minSdkVersion:30) -server_configurable_flags(minSdkVersion:29) -service-media-s(minSdkVersion:29) -service-permission(minSdkVersion:30) -service-permission(minSdkVersion:current) -service-permission-shared(minSdkVersion:30) -service-scheduling(minSdkVersion:current) -service-statsd(minSdkVersion:30) -service-statsd(minSdkVersion:current) -service-wifi(minSdkVersion:30) -services.net-module-wifi(minSdkVersion:30) -ServiceWifiResources(minSdkVersion:30) -ServiceWifiResourcesGoogle(minSdkVersion:30) -SettingsLibActionBarShadow(minSdkVersion:21) -SettingsLibAppPreference(minSdkVersion:21) -SettingsLibBarChartPreference(minSdkVersion:21) -SettingsLibCollapsingToolbarBaseActivity(minSdkVersion:21) -SettingsLibHelpUtils(minSdkVersion:21) -SettingsLibLayoutPreference(minSdkVersion:21) -SettingsLibProgressBar(minSdkVersion:21) -SettingsLibRestrictedLockUtils(minSdkVersion:21) -SettingsLibSearchWidget(minSdkVersion:21) -SettingsLibSettingsTheme(minSdkVersion:21) -SettingsLibUtils(minSdkVersion:21) -shared-file-region-aidl-unstable-cpp(minSdkVersion:29) -stats_proto(minSdkVersion:29) -statsd(minSdkVersion:(no version)) -statsd(minSdkVersion:30) -statsd-aidl-ndk_platform(minSdkVersion:(no version)) -statsd-aidl-ndk_platform(minSdkVersion:30) -statsprotos(minSdkVersion:29) -tensorflow_headers(minSdkVersion:(no version)) -Tethering(minSdkVersion:30) -Tethering(minSdkVersion:current) -TetheringApiCurrentLib(minSdkVersion:30) -TetheringApiCurrentLib(minSdkVersion:current) -TetheringGoogle(minSdkVersion:30) -TetheringGoogle(minSdkVersion:current) -textclassifier-statsd(minSdkVersion:30) -textclassifier-statsd(minSdkVersion:current) -TextClassifierNotificationLibNoManifest(minSdkVersion:29) -TextClassifierServiceLibNoManifest(minSdkVersion:28) -TextClassifierServiceLibNoManifest(minSdkVersion:30) -tflite_support(minSdkVersion:30) -updatable-media(minSdkVersion:29) -wifi-lite-protos(minSdkVersion:30) -wifi-nano-protos(minSdkVersion:30) -wifi-service-pre-jarjar(minSdkVersion:30) -xz-java(minSdkVersion:current) diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go index c1aca957e..f587c90d5 100644 --- a/apex/apex_singleton.go +++ b/apex/apex_singleton.go @@ -58,8 +58,8 @@ var ( echo "ERROR: go/apex-allowed-deps-error"; echo "******************************"; echo "Detected changes to allowed dependencies in updatable modules."; - echo "To fix and update build/soong/apex/allowed_deps.txt, please run:"; - echo "$$ (croot && build/soong/scripts/update-apex-allowed-deps.sh)"; + echo "To fix and update packages/modules/common/build/allowed_deps.txt, please run:"; + echo "$$ (croot && packages/modules/common/build/update-apex-allowed-deps.sh)"; echo "Members of mainline-modularization@google.com will review the changes."; echo -e "******************************\n"; exit 1; @@ -81,7 +81,7 @@ func (s *apexDepsInfoSingleton) GenerateBuildActions(ctx android.SingletonContex } }) - allowedDeps := android.ExistentPathForSource(ctx, "build/soong/apex/allowed_deps.txt").Path() + allowedDeps := android.ExistentPathForSource(ctx, "packages/modules/common/build/allowed_deps.txt").Path() newAllowedDeps := android.PathForOutput(ctx, "apex", "depsinfo", "new-allowed-deps.txt") ctx.Build(pctx, android.BuildParams{ diff --git a/scripts/update-apex-allowed-deps.sh b/scripts/update-apex-allowed-deps.sh deleted file mode 100755 index 872d74670..000000000 --- a/scripts/update-apex-allowed-deps.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -e -# -# The script to run locally to re-generate global allowed list of dependencies -# for updatable modules. - -if [ ! -e "build/envsetup.sh" ]; then - echo "ERROR: $0 must be run from the top of the tree" - exit 1 -fi - -source build/envsetup.sh > /dev/null || exit 1 - -readonly OUT_DIR=$(get_build_var OUT_DIR) - -readonly ALLOWED_DEPS_FILE="build/soong/apex/allowed_deps.txt" -readonly NEW_ALLOWED_DEPS_FILE="${OUT_DIR}/soong/apex/depsinfo/new-allowed-deps.txt" - -# If the script is run after droidcore failure, ${NEW_ALLOWED_DEPS_FILE} -# should already be built. If running the script manually, make sure it exists. -m "${NEW_ALLOWED_DEPS_FILE}" -j - -cat > "${ALLOWED_DEPS_FILE}" << EndOfFileComment -# A list of allowed dependencies for all updatable modules. -# -# The list tracks all direct and transitive dependencies that end up within any -# of the updatable binaries; specifically excluding external dependencies -# required to compile those binaries. This prevents potential regressions in -# case a new dependency is not aware of the different functional and -# non-functional requirements being part of an updatable module, for example -# setting correct min_sdk_version. -# -# To update the list, run: -# repo-root$ build/soong/scripts/update-apex-allowed-deps.sh -# -# See go/apex-allowed-deps-error for more details. -# TODO(b/157465465): introduce automated quality signals and remove this list. -EndOfFileComment - -cat "${NEW_ALLOWED_DEPS_FILE}" >> "${ALLOWED_DEPS_FILE}" From 52411447aa7d02b7ea652f3fb3bf3191b6984afd Mon Sep 17 00:00:00 2001 From: Artur Satayev Date: Thu, 11 Mar 2021 16:45:04 +0000 Subject: [PATCH 006/148] Move allowed_deps.txt to packages/modules/common. Bug: 179234385 Test: run update-apex-allowed-deps.sh locally Change-Id: I8e8864468b87342c688d001bc5f6e6f8416863ed Merged-In: I8e8864468b87342c688d001bc5f6e6f8416863ed (cherry picked from commit 732d6264210513b971205b5c9f1b2f49b9cafdf3) (cherry picked from commit 8dfcbe466c9cab92c868f8fcfd67ba2bd2d80f8a) --- apex/OWNERS | 3 - apex/allowed_deps.txt | 768 ---------------------------- apex/apex_singleton.go | 6 +- scripts/update-apex-allowed-deps.sh | 39 -- 4 files changed, 3 insertions(+), 813 deletions(-) delete mode 100644 apex/allowed_deps.txt delete mode 100755 scripts/update-apex-allowed-deps.sh diff --git a/apex/OWNERS b/apex/OWNERS index fee739b56..8e4ba5cd5 100644 --- a/apex/OWNERS +++ b/apex/OWNERS @@ -1,4 +1 @@ per-file * = jiyong@google.com - -per-file allowed_deps.txt = set noparent -per-file allowed_deps.txt = dariofreni@google.com,hansson@google.com,harpin@google.com,jiyong@google.com,narayan@google.com,jham@google.com diff --git a/apex/allowed_deps.txt b/apex/allowed_deps.txt deleted file mode 100644 index 58940c863..000000000 --- a/apex/allowed_deps.txt +++ /dev/null @@ -1,768 +0,0 @@ -# A list of allowed dependencies for all updatable modules. -# -# The list tracks all direct and transitive dependencies that end up within any -# of the updatable binaries; specifically excluding external dependencies -# required to compile those binaries. This prevents potential regressions in -# case a new dependency is not aware of the different functional and -# non-functional requirements being part of an updatable module, for example -# setting correct min_sdk_version. -# -# To update the list, run: -# repo-root$ build/soong/scripts/update-apex-allowed-deps.sh -# -# See go/apex-allowed-deps-error for more details. -# TODO(b/157465465): introduce automated quality signals and remove this list. - -adbd(minSdkVersion:(no version)) -android.hardware.cas.native@1.0(minSdkVersion:29) -android.hardware.cas@1.0(minSdkVersion:29) -android.hardware.common-ndk_platform(minSdkVersion:29) -android.hardware.common-unstable-ndk_platform(minSdkVersion:29) -android.hardware.common-V2-ndk_platform(minSdkVersion:29) -android.hardware.graphics.allocator@2.0(minSdkVersion:29) -android.hardware.graphics.allocator@3.0(minSdkVersion:29) -android.hardware.graphics.allocator@4.0(minSdkVersion:29) -android.hardware.graphics.bufferqueue@1.0(minSdkVersion:29) -android.hardware.graphics.bufferqueue@2.0(minSdkVersion:29) -android.hardware.graphics.common-ndk_platform(minSdkVersion:29) -android.hardware.graphics.common-unstable-ndk_platform(minSdkVersion:29) -android.hardware.graphics.common-V2-ndk_platform(minSdkVersion:29) -android.hardware.graphics.common@1.0(minSdkVersion:29) -android.hardware.graphics.common@1.1(minSdkVersion:29) -android.hardware.graphics.common@1.2(minSdkVersion:29) -android.hardware.graphics.mapper@2.0(minSdkVersion:29) -android.hardware.graphics.mapper@2.1(minSdkVersion:29) -android.hardware.graphics.mapper@3.0(minSdkVersion:29) -android.hardware.graphics.mapper@4.0(minSdkVersion:29) -android.hardware.media.bufferpool@2.0(minSdkVersion:29) -android.hardware.media.c2@1.0(minSdkVersion:29) -android.hardware.media.c2@1.1(minSdkVersion:29) -android.hardware.media.omx@1.0(minSdkVersion:29) -android.hardware.media@1.0(minSdkVersion:29) -android.hardware.neuralnetworks-V1-ndk_platform(minSdkVersion:30) -android.hardware.neuralnetworks@1.0(minSdkVersion:30) -android.hardware.neuralnetworks@1.1(minSdkVersion:30) -android.hardware.neuralnetworks@1.2(minSdkVersion:30) -android.hardware.neuralnetworks@1.3(minSdkVersion:30) -android.hardware.tetheroffload.config-V1.0-java(minSdkVersion:current) -android.hardware.tetheroffload.control-V1.0-java(minSdkVersion:current) -android.hardware.wifi-V1.0-java(minSdkVersion:30) -android.hardware.wifi-V1.0-java-constants(minSdkVersion:30) -android.hardware.wifi-V1.1-java(minSdkVersion:30) -android.hardware.wifi-V1.2-java(minSdkVersion:30) -android.hardware.wifi-V1.3-java(minSdkVersion:30) -android.hardware.wifi-V1.4-java(minSdkVersion:30) -android.hardware.wifi-V1.5-java(minSdkVersion:30) -android.hardware.wifi.hostapd-V1.0-java(minSdkVersion:30) -android.hardware.wifi.hostapd-V1.1-java(minSdkVersion:30) -android.hardware.wifi.hostapd-V1.2-java(minSdkVersion:30) -android.hardware.wifi.hostapd-V1.3-java(minSdkVersion:30) -android.hardware.wifi.supplicant-V1.0-java(minSdkVersion:30) -android.hardware.wifi.supplicant-V1.1-java(minSdkVersion:30) -android.hardware.wifi.supplicant-V1.2-java(minSdkVersion:30) -android.hardware.wifi.supplicant-V1.3-java(minSdkVersion:30) -android.hardware.wifi.supplicant-V1.4-java(minSdkVersion:30) -android.hidl.allocator@1.0(minSdkVersion:29) -android.hidl.base-V1.0-java(minSdkVersion:current) -android.hidl.manager-V1.0-java(minSdkVersion:30) -android.hidl.manager-V1.1-java(minSdkVersion:30) -android.hidl.manager-V1.2-java(minSdkVersion:30) -android.hidl.memory.token@1.0(minSdkVersion:29) -android.hidl.memory@1.0(minSdkVersion:29) -android.hidl.safe_union@1.0(minSdkVersion:29) -android.hidl.token@1.0(minSdkVersion:29) -android.hidl.token@1.0-utils(minSdkVersion:29) -android.net.ipsec.ike(minSdkVersion:30) -android.net.ipsec.ike(minSdkVersion:current) -android.net.ipsec.ike.xml(minSdkVersion:(no version)) -android_downloader_lib(minSdkVersion:30) -androidx-constraintlayout_constraintlayout(minSdkVersion:14) -androidx-constraintlayout_constraintlayout-solver(minSdkVersion:24) -androidx.activity_activity(minSdkVersion:14) -androidx.activity_activity-ktx(minSdkVersion:14) -androidx.annotation_annotation(minSdkVersion:24) -androidx.annotation_annotation-experimental(minSdkVersion:14) -androidx.appcompat_appcompat(minSdkVersion:14) -androidx.appcompat_appcompat-resources(minSdkVersion:14) -androidx.arch.core_core-common(minSdkVersion:24) -androidx.arch.core_core-runtime(minSdkVersion:14) -androidx.asynclayoutinflater_asynclayoutinflater(minSdkVersion:14) -androidx.autofill_autofill(minSdkVersion:14) -androidx.cardview_cardview(minSdkVersion:14) -androidx.collection_collection(minSdkVersion:24) -androidx.collection_collection-ktx(minSdkVersion:24) -androidx.concurrent_concurrent-futures(minSdkVersion:24) -androidx.coordinatorlayout_coordinatorlayout(minSdkVersion:14) -androidx.core_core(minSdkVersion:14) -androidx.core_core-ktx(minSdkVersion:14) -androidx.cursoradapter_cursoradapter(minSdkVersion:14) -androidx.customview_customview(minSdkVersion:14) -androidx.documentfile_documentfile(minSdkVersion:14) -androidx.drawerlayout_drawerlayout(minSdkVersion:14) -androidx.dynamicanimation_dynamicanimation(minSdkVersion:14) -androidx.fragment_fragment(minSdkVersion:14) -androidx.fragment_fragment-ktx(minSdkVersion:14) -androidx.interpolator_interpolator(minSdkVersion:14) -androidx.leanback_leanback(minSdkVersion:17) -androidx.leanback_leanback-preference(minSdkVersion:21) -androidx.legacy_legacy-preference-v14(minSdkVersion:14) -androidx.legacy_legacy-support-core-ui(minSdkVersion:14) -androidx.legacy_legacy-support-core-utils(minSdkVersion:14) -androidx.legacy_legacy-support-v13(minSdkVersion:14) -androidx.legacy_legacy-support-v4(minSdkVersion:14) -androidx.lifecycle_lifecycle-common(minSdkVersion:24) -androidx.lifecycle_lifecycle-common-java8(minSdkVersion:24) -androidx.lifecycle_lifecycle-extensions(minSdkVersion:14) -androidx.lifecycle_lifecycle-livedata(minSdkVersion:14) -androidx.lifecycle_lifecycle-livedata-core(minSdkVersion:14) -androidx.lifecycle_lifecycle-livedata-core-ktx(minSdkVersion:14) -androidx.lifecycle_lifecycle-process(minSdkVersion:14) -androidx.lifecycle_lifecycle-runtime(minSdkVersion:14) -androidx.lifecycle_lifecycle-runtime-ktx(minSdkVersion:14) -androidx.lifecycle_lifecycle-service(minSdkVersion:14) -androidx.lifecycle_lifecycle-viewmodel(minSdkVersion:14) -androidx.lifecycle_lifecycle-viewmodel-ktx(minSdkVersion:14) -androidx.lifecycle_lifecycle-viewmodel-savedstate(minSdkVersion:14) -androidx.loader_loader(minSdkVersion:14) -androidx.localbroadcastmanager_localbroadcastmanager(minSdkVersion:14) -androidx.media_media(minSdkVersion:14) -androidx.navigation_navigation-common(minSdkVersion:14) -androidx.navigation_navigation-common-ktx(minSdkVersion:14) -androidx.navigation_navigation-fragment(minSdkVersion:14) -androidx.navigation_navigation-fragment-ktx(minSdkVersion:14) -androidx.navigation_navigation-runtime(minSdkVersion:14) -androidx.navigation_navigation-runtime-ktx(minSdkVersion:14) -androidx.navigation_navigation-ui(minSdkVersion:14) -androidx.navigation_navigation-ui-ktx(minSdkVersion:14) -androidx.preference_preference(minSdkVersion:14) -androidx.print_print(minSdkVersion:14) -androidx.recyclerview_recyclerview(minSdkVersion:14) -androidx.recyclerview_recyclerview-selection(minSdkVersion:14) -androidx.room_room-common(minSdkVersion:24) -androidx.room_room-runtime(minSdkVersion:14) -androidx.savedstate_savedstate(minSdkVersion:14) -androidx.savedstate_savedstate-ktx(minSdkVersion:14) -androidx.slidingpanelayout_slidingpanelayout(minSdkVersion:14) -androidx.sqlite_sqlite(minSdkVersion:14) -androidx.sqlite_sqlite-framework(minSdkVersion:14) -androidx.swiperefreshlayout_swiperefreshlayout(minSdkVersion:14) -androidx.tracing_tracing(minSdkVersion:14) -androidx.transition_transition(minSdkVersion:14) -androidx.vectordrawable_vectordrawable(minSdkVersion:14) -androidx.vectordrawable_vectordrawable-animated(minSdkVersion:14) -androidx.versionedparcelable_versionedparcelable(minSdkVersion:14) -androidx.viewpager2_viewpager2(minSdkVersion:14) -androidx.viewpager_viewpager(minSdkVersion:14) -androidx.work_work-runtime(minSdkVersion:14) -apache-commons-compress(minSdkVersion:current) -art.module.public.api.stubs(minSdkVersion:(no version)) -audio_common-aidl-unstable-cpp(minSdkVersion:29) -audioclient-types-aidl-cpp(minSdkVersion:29) -audioclient-types-aidl-unstable-cpp(minSdkVersion:29) -audioflinger-aidl-cpp(minSdkVersion:29) -audioflinger-aidl-unstable-cpp(minSdkVersion:29) -audiopolicy-aidl-cpp(minSdkVersion:29) -audiopolicy-aidl-unstable-cpp(minSdkVersion:29) -av-headers(minSdkVersion:29) -av-types-aidl-cpp(minSdkVersion:29) -av-types-aidl-unstable-cpp(minSdkVersion:29) -bcm_object(minSdkVersion:29) -bionic_libc_platform_headers(minSdkVersion:29) -boringssl_self_test(minSdkVersion:29) -bouncycastle-unbundled(minSdkVersion:30) -bouncycastle_ike_digests(minSdkVersion:current) -bpf_syscall_wrappers(minSdkVersion:30) -brotli-java(minSdkVersion:current) -captiveportal-lib(minSdkVersion:29) -car-ui-lib(minSdkVersion:28) -car-ui-lib-overlayable(minSdkVersion:28) -CellBroadcastApp(minSdkVersion:29) -CellBroadcastServiceModule(minSdkVersion:29) -codecs_g711dec(minSdkVersion:29) -com.google.android.material_material(minSdkVersion:14) -conscrypt(minSdkVersion:29) -conscrypt.module.platform.api.stubs(minSdkVersion:(no version)) -conscrypt.module.public.api.stubs(minSdkVersion:(no version)) -core-lambda-stubs(minSdkVersion:(no version)) -core.current.stubs(minSdkVersion:(no version)) -crtbegin_dynamic(minSdkVersion:16) -crtbegin_dynamic(minSdkVersion:apex_inherit) -crtbegin_dynamic1(minSdkVersion:16) -crtbegin_dynamic1(minSdkVersion:apex_inherit) -crtbegin_so(minSdkVersion:16) -crtbegin_so(minSdkVersion:apex_inherit) -crtbegin_so1(minSdkVersion:16) -crtbegin_so1(minSdkVersion:apex_inherit) -crtbrand(minSdkVersion:16) -crtbrand(minSdkVersion:apex_inherit) -crtend_android(minSdkVersion:16) -crtend_android(minSdkVersion:apex_inherit) -crtend_so(minSdkVersion:16) -crtend_so(minSdkVersion:apex_inherit) -datastallprotosnano(minSdkVersion:29) -derive_classpath(minSdkVersion:30) -derive_sdk(minSdkVersion:30) -derive_sdk(minSdkVersion:current) -derive_sdk_prefer32(minSdkVersion:30) -derive_sdk_prefer32(minSdkVersion:current) -dnsresolver_aidl_interface-lateststable-ndk_platform(minSdkVersion:29) -dnsresolver_aidl_interface-unstable-ndk_platform(minSdkVersion:29) -dnsresolver_aidl_interface-V7-ndk_platform(minSdkVersion:29) -dnsresolver_aidl_interface-V8-ndk_platform(minSdkVersion:29) -DocumentsUI-res-lib(minSdkVersion:29) -exoplayer2-extractor(minSdkVersion:16) -exoplayer2-extractor-annotation-stubs(minSdkVersion:16) -ExtServices(minSdkVersion:30) -ExtServices(minSdkVersion:current) -ExtServices-core(minSdkVersion:30) -ExtServices-core(minSdkVersion:current) -flatbuffer_headers(minSdkVersion:(no version)) -fmtlib(minSdkVersion:29) -fmtlib_ndk(minSdkVersion:29) -framework-mediaprovider(minSdkVersion:30) -framework-permission(minSdkVersion:30) -framework-permission(minSdkVersion:current) -framework-permission-s(minSdkVersion:30) -framework-permission-s-shared(minSdkVersion:30) -framework-scheduling(minSdkVersion:current) -framework-sdkextensions(minSdkVersion:30) -framework-sdkextensions(minSdkVersion:current) -framework-statsd(minSdkVersion:30) -framework-statsd(minSdkVersion:current) -framework-tethering(minSdkVersion:30) -framework-tethering(minSdkVersion:current) -framework-wifi(minSdkVersion:30) -framework-wifi-util-lib(minSdkVersion:30) -gemmlowp_headers(minSdkVersion:(no version)) -geotz(minSdkVersion:current) -geotz_lookup(minSdkVersion:current) -geotz_s2storage_ro(minSdkVersion:current) -GoogleCellBroadcastApp(minSdkVersion:29) -GoogleCellBroadcastServiceModule(minSdkVersion:29) -GoogleExtServices(minSdkVersion:30) -GoogleExtServices(minSdkVersion:current) -GooglePermissionController(minSdkVersion:30) -guava(minSdkVersion:current) -gwp_asan_headers(minSdkVersion:(no version)) -i18n.module.public.api.stubs(minSdkVersion:(no version)) -iconloader(minSdkVersion:21) -ike-internals(minSdkVersion:current) -InProcessTethering(minSdkVersion:30) -InProcessTethering(minSdkVersion:current) -ipmemorystore-aidl-interfaces-java(minSdkVersion:29) -ipmemorystore-aidl-interfaces-unstable-java(minSdkVersion:29) -ipmemorystore-aidl-interfaces-V10-java(minSdkVersion:29) -ipmemorystore-aidl-interfaces-V11-java(minSdkVersion:29) -jni_headers(minSdkVersion:29) -jsr305(minSdkVersion:14) -kotlinx-coroutines-android(minSdkVersion:current) -kotlinx-coroutines-core(minSdkVersion:current) -ksoap2(minSdkVersion:30) -legacy.art.module.platform.api.stubs(minSdkVersion:(no version)) -legacy.core.platform.api.stubs(minSdkVersion:(no version)) -legacy.i18n.module.platform.api.stubs(minSdkVersion:(no version)) -libaacextractor(minSdkVersion:29) -libadb_crypto(minSdkVersion:(no version)) -libadb_pairing_auth(minSdkVersion:(no version)) -libadb_pairing_connection(minSdkVersion:(no version)) -libadb_pairing_server(minSdkVersion:(no version)) -libadb_protos(minSdkVersion:(no version)) -libadb_sysdeps(minSdkVersion:apex_inherit) -libadb_tls_connection(minSdkVersion:(no version)) -libadbconnection_client(minSdkVersion:(no version)) -libadbconnection_server(minSdkVersion:(no version)) -libadbd(minSdkVersion:(no version)) -libadbd_core(minSdkVersion:(no version)) -libadbd_services(minSdkVersion:(no version)) -liballoc.rust_sysroot(minSdkVersion:(no version)) -libamrextractor(minSdkVersion:29) -libapp_processes_protos_lite(minSdkVersion:(no version)) -libarect(minSdkVersion:29) -libasyncio(minSdkVersion:(no version)) -libatomic(minSdkVersion:(no version)) -libaudio_system_headers(minSdkVersion:29) -libaudioclient_aidl_conversion(minSdkVersion:29) -libaudioclient_aidl_conversion_util(minSdkVersion:29) -libaudioclient_headers(minSdkVersion:29) -libaudiofoundation_headers(minSdkVersion:29) -libaudioutils(minSdkVersion:29) -libaudioutils_fixedfft(minSdkVersion:29) -libavcdec(minSdkVersion:29) -libavcenc(minSdkVersion:29) -libavservices_minijail(minSdkVersion:29) -libbacktrace_headers(minSdkVersion:apex_inherit) -libbacktrace_rs.rust_sysroot(minSdkVersion:(no version)) -libbacktrace_sys.rust_sysroot(minSdkVersion:(no version)) -libbase(minSdkVersion:29) -libbase_headers(minSdkVersion:29) -libbase_ndk(minSdkVersion:29) -libbinder(minSdkVersion:29) -libbinder_headers(minSdkVersion:29) -libbinder_headers_platform_shared(minSdkVersion:29) -libbinderthreadstateutils(minSdkVersion:29) -libbluetooth-types-header(minSdkVersion:29) -libbrotli(minSdkVersion:(no version)) -libbuildversion(minSdkVersion:(no version)) -libc(minSdkVersion:(no version)) -libc++(minSdkVersion:apex_inherit) -libc++_static(minSdkVersion:apex_inherit) -libc++abi(minSdkVersion:apex_inherit) -libc++demangle(minSdkVersion:apex_inherit) -libc_headers(minSdkVersion:apex_inherit) -libc_headers_arch(minSdkVersion:apex_inherit) -libcap(minSdkVersion:29) -libcfg_if(minSdkVersion:(no version)) -libcfg_if.rust_sysroot(minSdkVersion:(no version)) -libclang_rt.hwasan-aarch64-android.llndk(minSdkVersion:(no version)) -libcodec2(minSdkVersion:29) -libcodec2_headers(minSdkVersion:29) -libcodec2_hidl@1.0(minSdkVersion:29) -libcodec2_hidl@1.1(minSdkVersion:29) -libcodec2_internal(minSdkVersion:29) -libcodec2_soft_aacdec(minSdkVersion:29) -libcodec2_soft_aacenc(minSdkVersion:29) -libcodec2_soft_amrnbdec(minSdkVersion:29) -libcodec2_soft_amrnbenc(minSdkVersion:29) -libcodec2_soft_amrwbdec(minSdkVersion:29) -libcodec2_soft_amrwbenc(minSdkVersion:29) -libcodec2_soft_av1dec_gav1(minSdkVersion:29) -libcodec2_soft_avcdec(minSdkVersion:29) -libcodec2_soft_avcenc(minSdkVersion:29) -libcodec2_soft_common(minSdkVersion:29) -libcodec2_soft_flacdec(minSdkVersion:29) -libcodec2_soft_flacenc(minSdkVersion:29) -libcodec2_soft_g711alawdec(minSdkVersion:29) -libcodec2_soft_g711mlawdec(minSdkVersion:29) -libcodec2_soft_gsmdec(minSdkVersion:29) -libcodec2_soft_h263dec(minSdkVersion:29) -libcodec2_soft_h263enc(minSdkVersion:29) -libcodec2_soft_hevcdec(minSdkVersion:29) -libcodec2_soft_hevcenc(minSdkVersion:29) -libcodec2_soft_mp3dec(minSdkVersion:29) -libcodec2_soft_mpeg2dec(minSdkVersion:29) -libcodec2_soft_mpeg4dec(minSdkVersion:29) -libcodec2_soft_mpeg4enc(minSdkVersion:29) -libcodec2_soft_opusdec(minSdkVersion:29) -libcodec2_soft_opusenc(minSdkVersion:29) -libcodec2_soft_rawdec(minSdkVersion:29) -libcodec2_soft_vorbisdec(minSdkVersion:29) -libcodec2_soft_vp8dec(minSdkVersion:29) -libcodec2_soft_vp8enc(minSdkVersion:29) -libcodec2_soft_vp9dec(minSdkVersion:29) -libcodec2_soft_vp9enc(minSdkVersion:29) -libcodec2_vndk(minSdkVersion:29) -libcompiler_builtins.rust_sysroot(minSdkVersion:(no version)) -libcore.rust_sysroot(minSdkVersion:(no version)) -libcrypto(minSdkVersion:29) -libcrypto_static(minSdkVersion:(no version)) -libcrypto_utils(minSdkVersion:(no version)) -libcutils(minSdkVersion:29) -libcutils_headers(minSdkVersion:29) -libcutils_sockets(minSdkVersion:29) -libderive_classpath(minSdkVersion:30) -libderive_sdk(minSdkVersion:30) -libdiagnose_usb(minSdkVersion:(no version)) -libdl(minSdkVersion:(no version)) -libdmabufheap(minSdkVersion:29) -libeigen(minSdkVersion:(no version)) -libextservices(minSdkVersion:30) -libextservices_jni(minSdkVersion:30) -libfft2d(minSdkVersion:30) -libfifo(minSdkVersion:29) -libFLAC(minSdkVersion:29) -libFLAC-config(minSdkVersion:29) -libFLAC-headers(minSdkVersion:29) -libflacextractor(minSdkVersion:29) -libfmq(minSdkVersion:29) -libfmq-base(minSdkVersion:29) -libFraunhoferAAC(minSdkVersion:29) -libfuse(minSdkVersion:30) -libfuse_jni(minSdkVersion:30) -libgav1(minSdkVersion:29) -libgcc(minSdkVersion:(no version)) -libgcc_stripped(minSdkVersion:(no version)) -libgetopts(minSdkVersion:(no version)) -libgralloctypes(minSdkVersion:29) -libgrallocusage(minSdkVersion:29) -libgsm(minSdkVersion:apex_inherit) -libgtest_prod(minSdkVersion:apex_inherit) -libgui_bufferqueue_static(minSdkVersion:29) -libgui_headers(minSdkVersion:29) -libhardware(minSdkVersion:29) -libhardware_headers(minSdkVersion:29) -libhashbrown.rust_sysroot(minSdkVersion:(no version)) -libhevcdec(minSdkVersion:29) -libhevcenc(minSdkVersion:29) -libhidlbase(minSdkVersion:29) -libhidlmemory(minSdkVersion:29) -libhwbinder-impl-internal(minSdkVersion:29) -libhwbinder_headers(minSdkVersion:29) -libion(minSdkVersion:29) -libjavacrypto(minSdkVersion:29) -libjsoncpp(minSdkVersion:29) -liblazy_static(minSdkVersion:(no version)) -liblibc(minSdkVersion:(no version)) -liblibc.rust_sysroot(minSdkVersion:(no version)) -libLibGuiProperties(minSdkVersion:29) -liblibm(minSdkVersion:(no version)) -liblog(minSdkVersion:(no version)) -liblog_headers(minSdkVersion:29) -liblog_rust(minSdkVersion:(no version)) -liblua(minSdkVersion:(no version)) -liblua(minSdkVersion:30) -liblz4(minSdkVersion:(no version)) -libm(minSdkVersion:(no version)) -libmath(minSdkVersion:29) -libmath_headers(minSdkVersion:apex_inherit) -libmdnssd(minSdkVersion:(no version)) -libmedia_codecserviceregistrant(minSdkVersion:29) -libmedia_datasource_headers(minSdkVersion:29) -libmedia_headers(minSdkVersion:29) -libmedia_helper_headers(minSdkVersion:29) -libmedia_midiiowrapper(minSdkVersion:29) -libmediaparser-jni(minSdkVersion:29) -libmediatranscoder(minSdkVersion:29) -libmediatranscoding(minSdkVersion:29) -libmediatranscodingservice(minSdkVersion:29) -libmidiextractor(minSdkVersion:29) -libminijail(minSdkVersion:29) -libminijail_gen_constants(minSdkVersion:(no version)) -libminijail_gen_constants_obj(minSdkVersion:29) -libminijail_gen_syscall(minSdkVersion:(no version)) -libminijail_gen_syscall_obj(minSdkVersion:29) -libminijail_generated(minSdkVersion:29) -libmkvextractor(minSdkVersion:29) -libmodules-utils-build(minSdkVersion:29) -libmp3extractor(minSdkVersion:29) -libmp4extractor(minSdkVersion:29) -libmpeg2dec(minSdkVersion:29) -libmpeg2extractor(minSdkVersion:29) -libnanohttpd(minSdkVersion:30) -libnativebase_headers(minSdkVersion:29) -libnativehelper_compat_libc++(minSdkVersion:(no version)) -libnativehelper_header_only(minSdkVersion:29) -libnativewindow_headers(minSdkVersion:29) -libnetd_resolv(minSdkVersion:29) -libnetdbinder_utils_headers(minSdkVersion:29) -libnetdutils(minSdkVersion:29) -libnetjniutils(minSdkVersion:29) -libnetworkstackutilsjni(minSdkVersion:29) -libneuralnetworks(minSdkVersion:(no version)) -libneuralnetworks_common(minSdkVersion:(no version)) -libneuralnetworks_headers(minSdkVersion:(no version)) -liboggextractor(minSdkVersion:29) -libonce_cell(minSdkVersion:(no version)) -libopus(minSdkVersion:29) -libpanic_unwind.rust_sysroot(minSdkVersion:(no version)) -libprocessgroup(minSdkVersion:29) -libprocessgroup_headers(minSdkVersion:29) -libprocpartition(minSdkVersion:(no version)) -libprofile-clang-extras(minSdkVersion:(no version)) -libprofile-clang-extras_cfi_support(minSdkVersion:(no version)) -libprofile-clang-extras_ndk(minSdkVersion:(no version)) -libprofile-extras(minSdkVersion:(no version)) -libprofile-extras_ndk(minSdkVersion:(no version)) -libprofiler_builtins.rust_sysroot(minSdkVersion:(no version)) -libprotobuf-cpp-lite(minSdkVersion:29) -libprotobuf-java-lite(minSdkVersion:current) -libprotobuf-java-nano(minSdkVersion:9) -libprotoutil(minSdkVersion:(no version)) -libqemu_pipe(minSdkVersion:(no version)) -libquiche_ffi(minSdkVersion:(no version)) -libquiche_ffi_headers(minSdkVersion:29) -libring(minSdkVersion:(no version)) -libring-core(minSdkVersion:29) -librustc_demangle.rust_sysroot(minSdkVersion:(no version)) -libruy_static(minSdkVersion:30) -libsdk_proto(minSdkVersion:30) -libsfplugin_ccodec_utils(minSdkVersion:29) -libshmemcompat(minSdkVersion:29) -libshmemutil(minSdkVersion:29) -libsonivoxwithoutjet(minSdkVersion:29) -libspeexresampler(minSdkVersion:29) -libspin(minSdkVersion:(no version)) -libssl(minSdkVersion:29) -libstagefright_amrnb_common(minSdkVersion:29) -libstagefright_amrnbdec(minSdkVersion:29) -libstagefright_amrnbenc(minSdkVersion:29) -libstagefright_amrwbdec(minSdkVersion:29) -libstagefright_amrwbenc(minSdkVersion:29) -libstagefright_bufferpool@2.0.1(minSdkVersion:29) -libstagefright_bufferqueue_helper(minSdkVersion:29) -libstagefright_bufferqueue_helper_novndk(minSdkVersion:29) -libstagefright_enc_common(minSdkVersion:29) -libstagefright_esds(minSdkVersion:29) -libstagefright_flacdec(minSdkVersion:29) -libstagefright_foundation(minSdkVersion:29) -libstagefright_foundation_headers(minSdkVersion:29) -libstagefright_foundation_without_imemory(minSdkVersion:29) -libstagefright_headers(minSdkVersion:29) -libstagefright_id3(minSdkVersion:29) -libstagefright_m4vh263dec(minSdkVersion:29) -libstagefright_m4vh263enc(minSdkVersion:29) -libstagefright_metadatautils(minSdkVersion:29) -libstagefright_mp3dec(minSdkVersion:29) -libstagefright_mp3dec_headers(minSdkVersion:29) -libstagefright_mpeg2extractor(minSdkVersion:29) -libstagefright_mpeg2support_nocrypto(minSdkVersion:29) -libstats_jni(minSdkVersion:(no version)) -libstats_jni(minSdkVersion:30) -libstatslog_media(minSdkVersion:29) -libstatslog_resolv(minSdkVersion:29) -libstatslog_statsd(minSdkVersion:(no version)) -libstatslog_statsd(minSdkVersion:30) -libstatspull(minSdkVersion:(no version)) -libstatspull(minSdkVersion:30) -libstatspush_compat(minSdkVersion:29) -libstatssocket(minSdkVersion:(no version)) -libstatssocket(minSdkVersion:30) -libstatssocket_headers(minSdkVersion:29) -libstd(minSdkVersion:(no version)) -libsystem_headers(minSdkVersion:apex_inherit) -libsysutils(minSdkVersion:apex_inherit) -libterm(minSdkVersion:(no version)) -libtest(minSdkVersion:(no version)) -libtetherutilsjni(minSdkVersion:30) -libtetherutilsjni(minSdkVersion:current) -libtextclassifier(minSdkVersion:(no version)) -libtextclassifier(minSdkVersion:30) -libtextclassifier-java(minSdkVersion:28) -libtextclassifier_abseil(minSdkVersion:30) -libtextclassifier_flatbuffer_headers(minSdkVersion:(no version)) -libtextclassifier_flatbuffer_headers(minSdkVersion:30) -libtextclassifier_hash_headers(minSdkVersion:(no version)) -libtextclassifier_hash_static(minSdkVersion:(no version)) -libtflite_kernel_utils(minSdkVersion:(no version)) -libtflite_static(minSdkVersion:(no version)) -libtflite_static(minSdkVersion:30) -libui(minSdkVersion:29) -libui-types(minSdkVersion:apex_inherit) -libui_headers(minSdkVersion:29) -libunicode_width.rust_sysroot(minSdkVersion:(no version)) -libuntrusted(minSdkVersion:(no version)) -libunwind.rust_sysroot(minSdkVersion:(no version)) -libunwind_llvm(minSdkVersion:apex_inherit) -libutf(minSdkVersion:(no version)) -libutils(minSdkVersion:apex_inherit) -libutils_headers(minSdkVersion:apex_inherit) -libvorbisidec(minSdkVersion:29) -libvpx(minSdkVersion:29) -libwatchdog(minSdkVersion:29) -libwavextractor(minSdkVersion:29) -libwebm(minSdkVersion:29) -libyuv(minSdkVersion:29) -libyuv_static(minSdkVersion:29) -libzstd(minSdkVersion:(no version)) -marisa-trie(minSdkVersion:(no version)) -marisa-trie(minSdkVersion:30) -media_ndk_headers(minSdkVersion:29) -media_plugin_headers(minSdkVersion:29) -MediaProvider(minSdkVersion:30) -MediaProviderGoogle(minSdkVersion:30) -mediaswcodec(minSdkVersion:29) -mediatranscoding(minSdkVersion:29) -mediatranscoding_aidl_interface-java(minSdkVersion:29) -mediatranscoding_aidl_interface-ndk_platform(minSdkVersion:29) -metrics-constants-protos(minSdkVersion:29) -modules-annotation-minsdk(minSdkVersion:29) -modules-utils-build(minSdkVersion:29) -modules-utils-build_system(minSdkVersion:29) -modules-utils-os(minSdkVersion:30) -ndk_crtbegin_so.19(minSdkVersion:(no version)) -ndk_crtbegin_so.21(minSdkVersion:(no version)) -ndk_crtbegin_so.27(minSdkVersion:(no version)) -ndk_crtend_so.19(minSdkVersion:(no version)) -ndk_crtend_so.21(minSdkVersion:(no version)) -ndk_crtend_so.27(minSdkVersion:(no version)) -ndk_libandroid_support(minSdkVersion:(no version)) -ndk_libc++_static(minSdkVersion:(no version)) -ndk_libc++_static(minSdkVersion:16) -ndk_libc++abi(minSdkVersion:(no version)) -ndk_libc++abi(minSdkVersion:16) -ndk_libunwind(minSdkVersion:16) -net-utils-device-common(minSdkVersion:29) -net-utils-framework-common(minSdkVersion:current) -netd-client(minSdkVersion:29) -netd_aidl_interface-java(minSdkVersion:29) -netd_aidl_interface-lateststable-java(minSdkVersion:29) -netd_aidl_interface-unstable-java(minSdkVersion:29) -netd_aidl_interface-V3-java(minSdkVersion:29) -netd_aidl_interface-V5-java(minSdkVersion:29) -netd_aidl_interface-V6-java(minSdkVersion:29) -netd_event_listener_interface-java(minSdkVersion:29) -netd_event_listener_interface-lateststable-ndk_platform(minSdkVersion:29) -netd_event_listener_interface-ndk_platform(minSdkVersion:29) -netd_event_listener_interface-unstable-ndk_platform(minSdkVersion:29) -netd_event_listener_interface-V1-ndk_platform(minSdkVersion:29) -netd_event_listener_interface-V2-ndk_platform(minSdkVersion:29) -netlink-client(minSdkVersion:29) -networkstack-aidl-interfaces-java(minSdkVersion:29) -networkstack-aidl-interfaces-unstable-java(minSdkVersion:29) -networkstack-aidl-interfaces-V10-java(minSdkVersion:29) -networkstack-aidl-interfaces-V9-java(minSdkVersion:29) -networkstack-client(minSdkVersion:29) -NetworkStackApi29Shims(minSdkVersion:29) -NetworkStackApi30Shims(minSdkVersion:29) -NetworkStackApiStableDependencies(minSdkVersion:29) -NetworkStackApiStableLib(minSdkVersion:29) -NetworkStackApiStableShims(minSdkVersion:29) -networkstackprotos(minSdkVersion:29) -NetworkStackShimsCommon(minSdkVersion:29) -neuralnetworks_types(minSdkVersion:30) -neuralnetworks_utils_hal_1_0(minSdkVersion:30) -neuralnetworks_utils_hal_1_1(minSdkVersion:30) -neuralnetworks_utils_hal_1_2(minSdkVersion:30) -neuralnetworks_utils_hal_1_3(minSdkVersion:30) -neuralnetworks_utils_hal_aidl(minSdkVersion:30) -neuralnetworks_utils_hal_common(minSdkVersion:30) -neuralnetworks_utils_hal_service(minSdkVersion:30) -no_op(minSdkVersion:current) -note_memtag_heap_async(minSdkVersion:16) -note_memtag_heap_sync(minSdkVersion:16) -offlinelocationtimezoneprovider(minSdkVersion:current) -OsuLogin(minSdkVersion:30) -OsuLoginGoogle(minSdkVersion:30) -PermissionController(minSdkVersion:30) -permissioncontroller-statsd(minSdkVersion:current) -philox_random(minSdkVersion:(no version)) -philox_random_headers(minSdkVersion:(no version)) -prebuilt_androidx-constraintlayout_constraintlayout-nodeps(minSdkVersion:(no version)) -prebuilt_androidx-constraintlayout_constraintlayout-solver-nodeps(minSdkVersion:current) -prebuilt_androidx.activity_activity-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.activity_activity-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.annotation_annotation-experimental-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.annotation_annotation-nodeps(minSdkVersion:current) -prebuilt_androidx.appcompat_appcompat-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.appcompat_appcompat-resources-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.arch.core_core-common-nodeps(minSdkVersion:current) -prebuilt_androidx.arch.core_core-runtime-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.asynclayoutinflater_asynclayoutinflater-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.autofill_autofill-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.cardview_cardview-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.collection_collection-ktx-nodeps(minSdkVersion:current) -prebuilt_androidx.collection_collection-nodeps(minSdkVersion:current) -prebuilt_androidx.concurrent_concurrent-futures-nodeps(minSdkVersion:current) -prebuilt_androidx.coordinatorlayout_coordinatorlayout-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.core_core-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.core_core-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.cursoradapter_cursoradapter-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.customview_customview-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.documentfile_documentfile-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.drawerlayout_drawerlayout-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.dynamicanimation_dynamicanimation-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.fragment_fragment-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.fragment_fragment-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.interpolator_interpolator-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.leanback_leanback-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.leanback_leanback-preference-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.legacy_legacy-support-core-ui-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.legacy_legacy-support-core-utils-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.legacy_legacy-support-v13-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-common-java8-nodeps(minSdkVersion:current) -prebuilt_androidx.lifecycle_lifecycle-common-nodeps(minSdkVersion:current) -prebuilt_androidx.lifecycle_lifecycle-extensions-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-livedata-core-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-livedata-core-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-livedata-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-process-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-runtime-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-runtime-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-service-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-viewmodel-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-viewmodel-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.lifecycle_lifecycle-viewmodel-savedstate-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.loader_loader-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.localbroadcastmanager_localbroadcastmanager-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.media_media-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-common-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-common-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-fragment-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-fragment-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-runtime-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-runtime-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-ui-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.navigation_navigation-ui-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.preference_preference-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.print_print-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.recyclerview_recyclerview-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.recyclerview_recyclerview-selection-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.room_room-common-nodeps(minSdkVersion:current) -prebuilt_androidx.room_room-runtime-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.savedstate_savedstate-ktx-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.savedstate_savedstate-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.slidingpanelayout_slidingpanelayout-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.sqlite_sqlite-framework-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.sqlite_sqlite-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.swiperefreshlayout_swiperefreshlayout-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.tracing_tracing-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.transition_transition-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.vectordrawable_vectordrawable-animated-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.vectordrawable_vectordrawable-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.versionedparcelable_versionedparcelable-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.viewpager2_viewpager2-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.viewpager_viewpager-nodeps(minSdkVersion:(no version)) -prebuilt_androidx.work_work-runtime-nodeps(minSdkVersion:(no version)) -prebuilt_com.google.android.material_material-nodeps(minSdkVersion:(no version)) -prebuilt_error_prone_annotations(minSdkVersion:(no version)) -prebuilt_guava-listenablefuture-prebuilt-jar(minSdkVersion:current) -prebuilt_kotlin-stdlib(minSdkVersion:current) -prebuilt_kotlinx-coroutines-android-nodeps(minSdkVersion:(no version)) -prebuilt_kotlinx-coroutines-core-nodeps(minSdkVersion:(no version)) -prebuilt_libclang_rt.builtins-aarch64-android(minSdkVersion:(no version)) -prebuilt_libclang_rt.builtins-arm-android(minSdkVersion:(no version)) -prebuilt_libclang_rt.builtins-i686-android(minSdkVersion:(no version)) -prebuilt_libclang_rt.builtins-x86_64-android(minSdkVersion:(no version)) -prebuilt_libunwind(minSdkVersion:(no version)) -prebuilt_test_framework-sdkextensions(minSdkVersion:(no version)) -resourceobserver_aidl_interface-ndk_platform(minSdkVersion:29) -resourceobserver_aidl_interface-V1-ndk_platform(minSdkVersion:29) -s2-geometry-library-java(minSdkVersion:30) -server_configurable_flags(minSdkVersion:29) -service-media-s(minSdkVersion:29) -service-permission(minSdkVersion:30) -service-permission(minSdkVersion:current) -service-permission-shared(minSdkVersion:30) -service-scheduling(minSdkVersion:current) -service-statsd(minSdkVersion:30) -service-statsd(minSdkVersion:current) -service-wifi(minSdkVersion:30) -services.net-module-wifi(minSdkVersion:30) -ServiceWifiResources(minSdkVersion:30) -ServiceWifiResourcesGoogle(minSdkVersion:30) -SettingsLibActionBarShadow(minSdkVersion:21) -SettingsLibAppPreference(minSdkVersion:21) -SettingsLibBarChartPreference(minSdkVersion:21) -SettingsLibCollapsingToolbarBaseActivity(minSdkVersion:21) -SettingsLibHelpUtils(minSdkVersion:21) -SettingsLibLayoutPreference(minSdkVersion:21) -SettingsLibProgressBar(minSdkVersion:21) -SettingsLibRestrictedLockUtils(minSdkVersion:21) -SettingsLibSearchWidget(minSdkVersion:21) -SettingsLibSettingsTheme(minSdkVersion:21) -SettingsLibUtils(minSdkVersion:21) -shared-file-region-aidl-unstable-cpp(minSdkVersion:29) -stats_proto(minSdkVersion:29) -statsd(minSdkVersion:(no version)) -statsd(minSdkVersion:30) -statsd-aidl-ndk_platform(minSdkVersion:(no version)) -statsd-aidl-ndk_platform(minSdkVersion:30) -statsprotos(minSdkVersion:29) -tensorflow_headers(minSdkVersion:(no version)) -Tethering(minSdkVersion:30) -Tethering(minSdkVersion:current) -TetheringApiCurrentLib(minSdkVersion:30) -TetheringApiCurrentLib(minSdkVersion:current) -TetheringGoogle(minSdkVersion:30) -TetheringGoogle(minSdkVersion:current) -textclassifier-java-proto-lite(minSdkVersion:30) -textclassifier-statsd(minSdkVersion:30) -textclassifier-statsd(minSdkVersion:current) -TextClassifierNotificationLibNoManifest(minSdkVersion:29) -TextClassifierServiceLibNoManifest(minSdkVersion:28) -TextClassifierServiceLibNoManifest(minSdkVersion:30) -tflite_support(minSdkVersion:30) -updatable-media(minSdkVersion:29) -wifi-lite-protos(minSdkVersion:30) -wifi-nano-protos(minSdkVersion:30) -wifi-service-pre-jarjar(minSdkVersion:30) -xz-java(minSdkVersion:current) diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go index c1aca957e..f587c90d5 100644 --- a/apex/apex_singleton.go +++ b/apex/apex_singleton.go @@ -58,8 +58,8 @@ var ( echo "ERROR: go/apex-allowed-deps-error"; echo "******************************"; echo "Detected changes to allowed dependencies in updatable modules."; - echo "To fix and update build/soong/apex/allowed_deps.txt, please run:"; - echo "$$ (croot && build/soong/scripts/update-apex-allowed-deps.sh)"; + echo "To fix and update packages/modules/common/build/allowed_deps.txt, please run:"; + echo "$$ (croot && packages/modules/common/build/update-apex-allowed-deps.sh)"; echo "Members of mainline-modularization@google.com will review the changes."; echo -e "******************************\n"; exit 1; @@ -81,7 +81,7 @@ func (s *apexDepsInfoSingleton) GenerateBuildActions(ctx android.SingletonContex } }) - allowedDeps := android.ExistentPathForSource(ctx, "build/soong/apex/allowed_deps.txt").Path() + allowedDeps := android.ExistentPathForSource(ctx, "packages/modules/common/build/allowed_deps.txt").Path() newAllowedDeps := android.PathForOutput(ctx, "apex", "depsinfo", "new-allowed-deps.txt") ctx.Build(pctx, android.BuildParams{ diff --git a/scripts/update-apex-allowed-deps.sh b/scripts/update-apex-allowed-deps.sh deleted file mode 100755 index 872d74670..000000000 --- a/scripts/update-apex-allowed-deps.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -e -# -# The script to run locally to re-generate global allowed list of dependencies -# for updatable modules. - -if [ ! -e "build/envsetup.sh" ]; then - echo "ERROR: $0 must be run from the top of the tree" - exit 1 -fi - -source build/envsetup.sh > /dev/null || exit 1 - -readonly OUT_DIR=$(get_build_var OUT_DIR) - -readonly ALLOWED_DEPS_FILE="build/soong/apex/allowed_deps.txt" -readonly NEW_ALLOWED_DEPS_FILE="${OUT_DIR}/soong/apex/depsinfo/new-allowed-deps.txt" - -# If the script is run after droidcore failure, ${NEW_ALLOWED_DEPS_FILE} -# should already be built. If running the script manually, make sure it exists. -m "${NEW_ALLOWED_DEPS_FILE}" -j - -cat > "${ALLOWED_DEPS_FILE}" << EndOfFileComment -# A list of allowed dependencies for all updatable modules. -# -# The list tracks all direct and transitive dependencies that end up within any -# of the updatable binaries; specifically excluding external dependencies -# required to compile those binaries. This prevents potential regressions in -# case a new dependency is not aware of the different functional and -# non-functional requirements being part of an updatable module, for example -# setting correct min_sdk_version. -# -# To update the list, run: -# repo-root$ build/soong/scripts/update-apex-allowed-deps.sh -# -# See go/apex-allowed-deps-error for more details. -# TODO(b/157465465): introduce automated quality signals and remove this list. -EndOfFileComment - -cat "${NEW_ALLOWED_DEPS_FILE}" >> "${ALLOWED_DEPS_FILE}" From 10d7e3695db236aefc4a8dfc8653e254069049fc Mon Sep 17 00:00:00 2001 From: Ytai Ben-Tsvi Date: Mon, 22 Mar 2021 12:44:18 -0700 Subject: [PATCH 007/148] Add soundtrigger HAL to VndkMustUseVendorVariantList Test: presubmit Change-Id: I3c4938bfde2b4a2b484fd57f2073c81aafd351f7 --- cc/config/vndk.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cc/config/vndk.go b/cc/config/vndk.go index d58c7a508..044dc27c9 100644 --- a/cc/config/vndk.go +++ b/cc/config/vndk.go @@ -57,6 +57,7 @@ var VndkMustUseVendorVariantList = []string{ "android.hardware.security.sharedsecret-V1-ndk_platform", "android.hardware.security.sharedsecret-ndk_platform", "android.hardware.security.sharedsecret-unstable-ndk_platform", + "android.hardware.soundtrigger3-V1-ndk_platform", "android.hardware.vibrator-V1-ndk_platform", "android.hardware.vibrator-ndk_platform", "android.hardware.weaver-V1-ndk_platform", From d82bdae7ba95a00e111409e6242dc918a1ef71c1 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 25 May 2021 16:22:55 +0000 Subject: [PATCH 008/148] Revert "Merge "Split asm and c flags and srcs in bp2build output..." Revert submission 14719675-am-79ada378cca6401fae8e5f162d3262d3 Reason for revert: breaks builds Reverted Changes: I8678b50b5:Merge "Split asm and c flags and srcs in bp2build ... Ia8a7d9bf2:Split libraries by language in cc_library_static a... Change-Id: I75e5a4e17d792c0b2bdd21eac3a0f2df5e6103b6 --- android/bazel.go | 10 ++- bazel/properties.go | 48 -------------- bp2build/cc_library_conversion_test.go | 10 ++- bp2build/cc_library_static_conversion_test.go | 40 ++++++------ cc/bp2build.go | 65 +++---------------- cc/library.go | 43 +++--------- cc/object.go | 8 +-- 7 files changed, 52 insertions(+), 172 deletions(-) diff --git a/android/bazel.go b/android/bazel.go index 7abd28d3d..ef770bf9c 100644 --- a/android/bazel.go +++ b/android/bazel.go @@ -220,7 +220,15 @@ var ( // Per-module denylist to opt modules out of mixed builds. Such modules will // still be generated via bp2build. mixedBuildsDisabledList = []string{ - "libc_common_shared", // cparsons@ cc_library_static, version script assignment of 'LIBC' to symbol '__cxa_atexit' failed: symbol not defined + "libc_common", // cparsons@ cc_library_static, depends on //bionic/libc:libc_nopthread + "libc_common_static", // cparsons@ cc_library_static, depends on //bionic/libc:libc_common + "libc_common_shared", // cparsons@ cc_library_static, depends on //bionic/libc:libc_common + "libc_netbsd", // lberki@, cc_library_static, version script assignment of 'LIBC_PRIVATE' to symbol 'SHA1Final' failed: symbol not defined + "libc_nopthread", // cparsons@ cc_library_static, version script assignment of 'LIBC' to symbol 'memcmp' failed: symbol not defined + "libc_openbsd", // ruperts@, cc_library_static, OK for bp2build but error: duplicate symbol: strcpy for mixed builds + "libarm-optimized-routines-string", // jingwen@, cc_library_static, OK for bp2build but b/186615213 (asflags not handled in bp2build), version script assignment of 'LIBC' to symbol 'memcmp' failed: symbol not defined (also for memrchr, strnlen) + "fmtlib_ndk", // http://b/187040371, cc_library_static, OK for bp2build but format-inl.h:11:10: fatal error: 'cassert' file not found for mixed builds + "libc_nomalloc", // cc_library_static, OK for bp2build but ld.lld: error: undefined symbol: pthread_mutex_lock (and others) } // Used for quicker lookups diff --git a/bazel/properties.go b/bazel/properties.go index 6ecf6caa6..84dca7e26 100644 --- a/bazel/properties.go +++ b/bazel/properties.go @@ -137,54 +137,6 @@ func SubtractStrings(haystack []string, needle []string) []string { return strings } -// Return all needles in a given haystack, where needleFn is true for needles. -func FilterLabelList(haystack LabelList, needleFn func(string) bool) LabelList { - var includes []Label - - for _, inc := range haystack.Includes { - if needleFn(inc.Label) { - includes = append(includes, inc) - } - } - return LabelList{Includes: includes, Excludes: haystack.Excludes} -} - -// Return all needles in a given haystack, where needleFn is true for needles. -func FilterLabelListAttribute(haystack LabelListAttribute, needleFn func(string) bool) LabelListAttribute { - var result LabelListAttribute - - result.Value = FilterLabelList(haystack.Value, needleFn) - - for arch := range PlatformArchMap { - result.SetValueForArch(arch, FilterLabelList(haystack.GetValueForArch(arch), needleFn)) - } - - for os := range PlatformOsMap { - result.SetValueForOS(os, FilterLabelList(haystack.GetValueForOS(os), needleFn)) - } - - return result -} - -// Subtract needle from haystack -func SubtractBazelLabelListAttribute(haystack LabelListAttribute, needle LabelListAttribute) LabelListAttribute { - var result LabelListAttribute - - for arch := range PlatformArchMap { - result.SetValueForArch(arch, - SubtractBazelLabelList(haystack.GetValueForArch(arch), needle.GetValueForArch(arch))) - } - - for os := range PlatformOsMap { - result.SetValueForOS(os, - SubtractBazelLabelList(haystack.GetValueForOS(os), needle.GetValueForOS(os))) - } - - result.Value = SubtractBazelLabelList(haystack.Value, needle.Value) - - return result -} - // Subtract needle from haystack func SubtractBazelLabels(haystack []Label, needle []Label) []Label { // This is really a set diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go index 454b15320..0a729374e 100644 --- a/bp2build/cc_library_conversion_test.go +++ b/bp2build/cc_library_conversion_test.go @@ -311,7 +311,7 @@ cc_library { "//build/bazel/platforms/arch:arm64": ["-DHAVE_FAST_FMA=1"], "//conditions:default": [], }), - srcs_c = ["math/cosf.c"], + srcs = ["math/cosf.c"], )`}, }) } @@ -618,7 +618,7 @@ cc_library { func TestCcLibraryCppFlagsGoesIntoCopts(t *testing.T) { runCcLibraryTestCase(t, bp2buildTestCase{ - description: "cc_library cppflags usage", + description: "cc_library cppflags goes into copts", moduleTypeUnderTest: "cc_library", moduleTypeUnderTestFactory: cc.LibraryFactory, moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build, @@ -654,12 +654,10 @@ func TestCcLibraryCppFlagsGoesIntoCopts(t *testing.T) { name = "a", copts = [ "-Wall", - "-Ifoo/bar", - "-I$(BINDIR)/foo/bar", - ], - cppflags = [ "-fsigned-char", "-pedantic", + "-Ifoo/bar", + "-I$(BINDIR)/foo/bar", ] + select({ "//build/bazel/platforms/arch:arm64": ["-DARM64=1"], "//conditions:default": [], diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go index 77758856c..229b1c25e 100644 --- a/bp2build/cc_library_static_conversion_test.go +++ b/bp2build/cc_library_static_conversion_test.go @@ -650,7 +650,7 @@ cc_library_static { "-I$(BINDIR)/.", ], linkstatic = True, - srcs_c = [ + srcs = [ "common.c", "foo-a.c", ], @@ -682,7 +682,7 @@ cc_library_static { "-I$(BINDIR)/.", ], linkstatic = True, - srcs_c = ["common.c"] + select({ + srcs = ["common.c"] + select({ "//build/bazel/platforms/arch:arm": ["foo-arm.c"], "//conditions:default": [], }), @@ -719,7 +719,7 @@ cc_library_static { "-I$(BINDIR)/.", ], linkstatic = True, - srcs_c = ["common.c"] + select({ + srcs = ["common.c"] + select({ "//build/bazel/platforms/arch:arm": ["for-arm.c"], "//conditions:default": ["not-for-arm.c"], }), @@ -758,7 +758,7 @@ cc_library_static { "-I$(BINDIR)/.", ], linkstatic = True, - srcs_c = ["common.c"] + select({ + srcs = ["common.c"] + select({ "//build/bazel/platforms/arch:arm": [ "for-arm.c", "not-for-x86.c", @@ -813,7 +813,7 @@ cc_library_static { "-I$(BINDIR)/.", ], linkstatic = True, - srcs_c = ["common.c"] + select({ + srcs = ["common.c"] + select({ "//build/bazel/platforms/arch:arm": [ "for-arm.c", "not-for-arm64.c", @@ -909,7 +909,7 @@ cc_library_static { "-I$(BINDIR)/.", ], linkstatic = True, - srcs_c = ["common.c"] + select({ + srcs = ["common.c"] + select({ "//build/bazel/platforms/arch:arm": ["for-lib32.c"], "//build/bazel/platforms/arch:x86": ["for-lib32.c"], "//conditions:default": ["not-for-lib32.c"], @@ -948,7 +948,7 @@ cc_library_static { "-I$(BINDIR)/.", ], linkstatic = True, - srcs_c = ["common.c"] + select({ + srcs = ["common.c"] + select({ "//build/bazel/platforms/arch:arm": [ "for-lib32.c", "not-for-lib64.c", @@ -1020,7 +1020,7 @@ cc_library_static { "-I$(BINDIR)/.", ], linkstatic = True, - srcs_c = ["common.c"] + select({ + srcs = ["common.c"] + select({ "//build/bazel/platforms/arch:arm": [ "for-arm.c", "for-lib32.c", @@ -1074,10 +1074,10 @@ func TestCcLibraryStaticArchSrcsExcludeSrcsGeneratedFiles(t *testing.T) { moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build, depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build}, filesystem: map[string]string{ - "common.cpp": "", - "for-x86.cpp": "", - "not-for-x86.cpp": "", - "not-for-everything.cpp": "", + "common.c": "", + "for-x86.c": "", + "not-for-x86.c": "", + "not-for-everything.c": "", "dep/Android.bp": ` genrule { name: "generated_src_other_pkg", @@ -1118,14 +1118,14 @@ genrule { cc_library_static { name: "foo_static3", - srcs: ["common.cpp", "not-for-*.cpp"], - exclude_srcs: ["not-for-everything.cpp"], + srcs: ["common.c", "not-for-*.c"], + exclude_srcs: ["not-for-everything.c"], generated_sources: ["generated_src", "generated_src_other_pkg"], generated_headers: ["generated_hdr", "generated_hdr_other_pkg"], arch: { x86: { - srcs: ["for-x86.cpp"], - exclude_srcs: ["not-for-x86.cpp"], + srcs: ["for-x86.c"], + exclude_srcs: ["not-for-x86.c"], generated_sources: ["generated_src_x86"], generated_headers: ["generated_hdr_other_pkg_x86"], }, @@ -1144,14 +1144,14 @@ cc_library_static { "//dep:generated_src_other_pkg", ":generated_hdr", ":generated_src", - "common.cpp", + "common.c", ] + select({ "//build/bazel/platforms/arch:x86": [ "//dep:generated_hdr_other_pkg_x86", ":generated_src_x86", - "for-x86.cpp", + "for-x86.c", ], - "//conditions:default": ["not-for-x86.cpp"], + "//conditions:default": ["not-for-x86.c"], }), )`}, }) @@ -1269,7 +1269,7 @@ cc_library_static { "//conditions:default": [], }), linkstatic = True, - srcs_c = ["common.c"], + srcs = ["common.c"], )`}, }) } diff --git a/cc/bp2build.go b/cc/bp2build.go index e417c6907..0c827c5ed 100644 --- a/cc/bp2build.go +++ b/cc/bp2build.go @@ -183,26 +183,15 @@ func bp2BuildParseStaticProps(ctx android.TopDownMutatorContext, module *Module) // Convenience struct to hold all attributes parsed from compiler properties. type compilerAttributes struct { - // Options for all languages - copts bazel.StringListAttribute - // Assembly options and sources - asFlags bazel.StringListAttribute - asSrcs bazel.LabelListAttribute - // C options and sources - conlyFlags bazel.StringListAttribute - cSrcs bazel.LabelListAttribute - // C++ options and sources - cppFlags bazel.StringListAttribute + copts bazel.StringListAttribute srcs bazel.LabelListAttribute + includes bazel.StringListAttribute } // bp2BuildParseCompilerProps returns copts, srcs and hdrs and other attributes. func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Module) compilerAttributes { var srcs bazel.LabelListAttribute var copts bazel.StringListAttribute - var asFlags bazel.StringListAttribute - var conlyFlags bazel.StringListAttribute - var cppFlags bazel.StringListAttribute // Creates the -I flags for a directory, while making the directory relative // to the exec root for Bazel to work. @@ -226,21 +215,15 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul return append(includeDirs, baseCompilerProps.Local_include_dirs...) } - parseCommandLineFlags := func(soongFlags []string) []string { - var result []string - for _, flag := range soongFlags { - // Soong's cflags can contain spaces, like `-include header.h`. For - // Bazel's copts, split them up to be compatible with the - // no_copts_tokenization feature. - result = append(result, strings.Split(flag, " ")...) - } - return result - } - // Parse the list of copts. parseCopts := func(baseCompilerProps *BaseCompilerProperties) []string { var copts []string - copts = append(copts, parseCommandLineFlags(baseCompilerProps.Cflags)...) + for _, flag := range append(baseCompilerProps.Cflags, baseCompilerProps.Cppflags...) { + // Soong's cflags can contain spaces, like `-include header.h`. For + // Bazel's copts, split them up to be compatible with the + // no_copts_tokenization feature. + copts = append(copts, strings.Split(flag, " ")...) + } for _, dir := range parseLocalIncludeDirs(baseCompilerProps) { copts = append(copts, includeFlags(dir)...) } @@ -277,9 +260,6 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul if baseCompilerProps, ok := props.(*BaseCompilerProperties); ok { srcs.Value = parseSrcs(baseCompilerProps) copts.Value = parseCopts(baseCompilerProps) - asFlags.Value = parseCommandLineFlags(baseCompilerProps.Asflags) - conlyFlags.Value = parseCommandLineFlags(baseCompilerProps.Conlyflags) - cppFlags.Value = parseCommandLineFlags(baseCompilerProps.Cppflags) // Used for arch-specific srcs later. baseSrcs = baseCompilerProps.Srcs @@ -310,9 +290,6 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul } copts.SetValueForArch(arch.Name, parseCopts(baseCompilerProps)) - asFlags.SetValueForArch(arch.Name, parseCommandLineFlags(baseCompilerProps.Asflags)) - conlyFlags.SetValueForArch(arch.Name, parseCommandLineFlags(baseCompilerProps.Conlyflags)) - cppFlags.SetValueForArch(arch.Name, parseCommandLineFlags(baseCompilerProps.Cppflags)) } } @@ -338,9 +315,6 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul // TODO(b/186153868): add support for os-specific srcs and exclude_srcs srcs.SetValueForOS(os.Name, bazel.SubtractBazelLabelList(srcsList, baseSrcsLabelList)) copts.SetValueForOS(os.Name, parseCopts(baseCompilerProps)) - asFlags.SetValueForOS(os.Name, parseCommandLineFlags(baseCompilerProps.Asflags)) - conlyFlags.SetValueForOS(os.Name, parseCommandLineFlags(baseCompilerProps.Conlyflags)) - cppFlags.SetValueForOS(os.Name, parseCommandLineFlags(baseCompilerProps.Cppflags)) } } @@ -359,28 +333,9 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul } } - // Branch srcs into three language-specific groups. - // C++ is the "catch-all" group, and comprises generated sources because we don't - // know the language of these sources until the genrule is executed. - // TODO(b/): Handle language detection of sources in a Bazel rule. - isCSrc := func(s string) bool { - return strings.HasSuffix(s, ".c") - } - isAsmSrc := func(s string) bool { - return strings.HasSuffix(s, ".S") || strings.HasSuffix(s, ".s") - } - cSrcs := bazel.FilterLabelListAttribute(srcs, isCSrc) - asSrcs := bazel.FilterLabelListAttribute(srcs, isAsmSrc) - srcs = bazel.SubtractBazelLabelListAttribute(srcs, cSrcs) - srcs = bazel.SubtractBazelLabelListAttribute(srcs, asSrcs) return compilerAttributes{ - copts: copts, - srcs: srcs, - asFlags: asFlags, - asSrcs: asSrcs, - cSrcs: cSrcs, - conlyFlags: conlyFlags, - cppFlags: cppFlags, + srcs: srcs, + copts: copts, } } diff --git a/cc/library.go b/cc/library.go index 9fb7a2451..c918b96ba 100644 --- a/cc/library.go +++ b/cc/library.go @@ -230,13 +230,6 @@ type bazelCcLibraryAttributes struct { Copts bazel.StringListAttribute Includes bazel.StringListAttribute Linkopts bazel.StringListAttribute - - Cppflags bazel.StringListAttribute - Srcs_c bazel.LabelListAttribute - Conlyflags bazel.StringListAttribute - Srcs_as bazel.LabelListAttribute - Asflags bazel.StringListAttribute - // Attributes pertaining to shared variant. Shared_copts bazel.StringListAttribute Shared_srcs bazel.LabelListAttribute @@ -246,7 +239,6 @@ type bazelCcLibraryAttributes struct { Whole_archive_deps_for_shared bazel.LabelListAttribute User_link_flags bazel.StringListAttribute Version_script bazel.LabelAttribute - // Attributes pertaining to static variant. Static_copts bazel.StringListAttribute Static_srcs bazel.LabelListAttribute @@ -302,27 +294,20 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) { srcs.Append(compilerAttrs.srcs) attrs := &bazelCcLibraryAttributes{ - Srcs: srcs, - Implementation_deps: linkerAttrs.deps, - Deps: linkerAttrs.exportedDeps, - Dynamic_deps: linkerAttrs.dynamicDeps, - Whole_archive_deps: linkerAttrs.wholeArchiveDeps, - Copts: compilerAttrs.copts, - Includes: exportedIncludes, - Linkopts: linkerAttrs.linkopts, - Cppflags: compilerAttrs.cppFlags, - Srcs_c: compilerAttrs.cSrcs, - Conlyflags: compilerAttrs.conlyFlags, - Srcs_as: compilerAttrs.asSrcs, - Asflags: compilerAttrs.asFlags, - + Srcs: srcs, + Implementation_deps: linkerAttrs.deps, + Deps: linkerAttrs.exportedDeps, + Dynamic_deps: linkerAttrs.dynamicDeps, + Whole_archive_deps: linkerAttrs.wholeArchiveDeps, + Copts: compilerAttrs.copts, + Includes: exportedIncludes, + Linkopts: linkerAttrs.linkopts, Shared_copts: sharedAttrs.copts, Shared_srcs: sharedAttrs.srcs, Static_deps_for_shared: sharedAttrs.staticDeps, Whole_archive_deps_for_shared: sharedAttrs.wholeArchiveDeps, Dynamic_deps_for_shared: sharedAttrs.dynamicDeps, Version_script: linkerAttrs.versionScript, - Static_copts: staticAttrs.copts, Static_srcs: staticAttrs.srcs, Static_deps_for_static: staticAttrs.staticDeps, @@ -2245,12 +2230,6 @@ type bazelCcLibraryStaticAttributes struct { Linkstatic bool Includes bazel.StringListAttribute Hdrs bazel.LabelListAttribute - - Cppflags bazel.StringListAttribute - Srcs_c bazel.LabelListAttribute - Conlyflags bazel.StringListAttribute - Srcs_as bazel.LabelListAttribute - Asflags bazel.StringListAttribute } type bazelCcLibraryStatic struct { @@ -2280,12 +2259,6 @@ func ccLibraryStaticBp2BuildInternal(ctx android.TopDownMutatorContext, module * Linkopts: linkerAttrs.linkopts, Linkstatic: true, Includes: exportedIncludes, - - Cppflags: compilerAttrs.cppFlags, - Srcs_c: compilerAttrs.cSrcs, - Conlyflags: compilerAttrs.conlyFlags, - Srcs_as: compilerAttrs.asSrcs, - Asflags: compilerAttrs.asFlags, } props := bazel.BazelTargetModuleProperties{ diff --git a/cc/object.go b/cc/object.go index cd711617b..704cb697d 100644 --- a/cc/object.go +++ b/cc/object.go @@ -185,14 +185,8 @@ func ObjectBp2Build(ctx android.TopDownMutatorContext) { } // TODO(b/183595872) warn/error if we're not handling product variables - // Don't split cc_object srcs across languages. Doing so would add complexity, - // and this isn't typically done for cc_object. - srcs := compilerAttrs.srcs - srcs.Append(compilerAttrs.cSrcs) - srcs.Append(compilerAttrs.asSrcs) - attrs := &bazelObjectAttributes{ - Srcs: srcs, + Srcs: compilerAttrs.srcs, Deps: deps, Copts: compilerAttrs.copts, Asflags: asFlags, From 9a7158bbddbb72e17399e1ea509039cb3f8ad968 Mon Sep 17 00:00:00 2001 From: Chang Li Date: Fri, 18 Jun 2021 14:04:50 +0000 Subject: [PATCH 009/148] Allowlist external/libtextclassifier for sdk_variant_only. Bug: 166040889 Change-Id: If8a9d916dada116f52fd84194fa42e9179526b2c --- android/neverallow.go | 1 + 1 file changed, 1 insertion(+) diff --git a/android/neverallow.go b/android/neverallow.go index 41b399a70..af072cdbb 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -174,6 +174,7 @@ func createCcSdkVariantRules() []Rule { "tools/test/graphicsbenchmark/apps/sample_app", "tools/test/graphicsbenchmark/functional_tests/java", "vendor/xts/gts-tests/hostsidetests/gamedevicecert/apps/javatests", + "external/libtextclassifier/native", } platformVariantPropertiesAllowedList := []string{ From 3b5f88e0913f3df579f4dc0c87daac88665b1073 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 11 Jun 2021 17:22:09 +0900 Subject: [PATCH 010/148] Rust module in APEX uses stub libraries across APEX boundaries This change fixes a bug that rust module in APEX has access to private symbols of a native library even when the native library is outside of the APEX. To fix this, the stub selection logic in the cc package is exctacted as a function ChooseStubOrImpl and is used also in the rust package. Bug: 190767845 Test: m Change-Id: I5c4cbdd5d27f257ab329d9dadbcd87d41a87f46a --- apex/apex_test.go | 30 +++++++++ cc/cc.go | 158 ++++++++++++++++++++++++++++------------------ cc/linkable.go | 3 + rust/rust.go | 27 ++++++-- 4 files changed, 151 insertions(+), 67 deletions(-) diff --git a/apex/apex_test.go b/apex/apex_test.go index 2e131a6fa..932438c93 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -839,6 +839,7 @@ func TestApexWithStubs(t *testing.T) { name: "myapex", key: "myapex.key", native_shared_libs: ["mylib", "mylib3"], + binaries: ["foo.rust"], updatable: false, } @@ -887,6 +888,25 @@ func TestApexWithStubs(t *testing.T) { stl: "none", apex_available: [ "myapex" ], } + + rust_binary { + name: "foo.rust", + srcs: ["foo.rs"], + shared_libs: ["libfoo.shared_from_rust"], + prefer_rlib: true, + apex_available: ["myapex"], + } + + cc_library_shared { + name: "libfoo.shared_from_rust", + srcs: ["mylib.cpp"], + system_shared_libs: [], + stl: "none", + stubs: { + versions: ["10", "11", "12"], + }, + } + `) apexRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexRule") @@ -924,7 +944,17 @@ func TestApexWithStubs(t *testing.T) { "lib64/mylib.so", "lib64/mylib3.so", "lib64/mylib4.so", + "bin/foo.rust", + "lib64/libc++.so", // by the implicit dependency from foo.rust + "lib64/liblog.so", // by the implicit dependency from foo.rust }) + + // Ensure that stub dependency from a rust module is not included + ensureNotContains(t, copyCmds, "image.apex/lib64/libfoo.shared_from_rust.so") + // The rust module is linked to the stub cc library + rustDeps := ctx.ModuleForTests("foo.rust", "android_arm64_armv8-a_apex10000").Rule("rustc").Args["linkFlags"] + ensureContains(t, rustDeps, "libfoo.shared_from_rust/android_arm64_armv8-a_shared_current/libfoo.shared_from_rust.so") + ensureNotContains(t, rustDeps, "libfoo.shared_from_rust/android_arm64_armv8-a_shared/libfoo.shared_from_rust.so") } func TestApexWithStubsWithMinSdkVersion(t *testing.T) { diff --git a/cc/cc.go b/cc/cc.go index 9685d3a04..e909347e6 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -1259,7 +1259,7 @@ func (c *Module) ImplementationModuleNameForMake(ctx android.BaseModuleContext) return name } -func (c *Module) bootstrap() bool { +func (c *Module) Bootstrap() bool { return Bool(c.Properties.Bootstrap) } @@ -1504,7 +1504,7 @@ func (ctx *moduleContextImpl) apexSdkVersion() android.ApiLevel { } func (ctx *moduleContextImpl) bootstrap() bool { - return ctx.mod.bootstrap() + return ctx.mod.Bootstrap() } func (ctx *moduleContextImpl) nativeCoverage() bool { @@ -2646,64 +2646,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { return } - sharedLibraryInfo := ctx.OtherModuleProvider(dep, SharedLibraryInfoProvider).(SharedLibraryInfo) - sharedLibraryStubsInfo := ctx.OtherModuleProvider(dep, SharedLibraryStubsProvider).(SharedLibraryStubsInfo) - - if !libDepTag.explicitlyVersioned && len(sharedLibraryStubsInfo.SharedStubLibraries) > 0 { - useStubs := false - - if lib := moduleLibraryInterface(dep); lib.buildStubs() && c.UseVndk() { // LLNDK - if !apexInfo.IsForPlatform() { - // For platform libraries, use current version of LLNDK - useStubs = true - } - } else if apexInfo.IsForPlatform() { - // If not building for APEX, use stubs only when it is from - // an APEX (and not from platform) - // However, for host, ramdisk, vendor_ramdisk, recovery or bootstrap modules, - // always link to non-stub variant - useStubs = dep.(android.ApexModule).NotInPlatform() && !c.bootstrap() - if useStubs { - // Another exception: if this module is a test for an APEX, then - // it is linked with the non-stub variant of a module in the APEX - // as if this is part of the APEX. - testFor := ctx.Provider(android.ApexTestForInfoProvider).(android.ApexTestForInfo) - for _, apexContents := range testFor.ApexContents { - if apexContents.DirectlyInApex(depName) { - useStubs = false - break - } - } - } - if useStubs { - // Yet another exception: If this module and the dependency are - // available to the same APEXes then skip stubs between their - // platform variants. This complements the test_for case above, - // which avoids the stubs on a direct APEX library dependency, by - // avoiding stubs for indirect test dependencies as well. - // - // TODO(b/183882457): This doesn't work if the two libraries have - // only partially overlapping apex_available. For that test_for - // modules would need to be split into APEX variants and resolved - // separately for each APEX they have access to. - if android.AvailableToSameApexes(c, dep.(android.ApexModule)) { - useStubs = false - } - } - } else { - // If building for APEX, use stubs when the parent is in any APEX that - // the child is not in. - useStubs = !android.DirectlyInAllApexes(apexInfo, depName) - } - - // when to use (unspecified) stubs, use the latest one. - if useStubs { - stubs := sharedLibraryStubsInfo.SharedStubLibraries - toUse := stubs[len(stubs)-1] - sharedLibraryInfo = toUse.SharedLibraryInfo - depExporterInfo = toUse.FlagExporterInfo - } - } + sharedLibraryInfo, returnedDepExporterInfo := ChooseStubOrImpl(ctx, dep) + depExporterInfo = returnedDepExporterInfo // Stubs lib doesn't link to the shared lib dependencies. Don't set // linkFile, depFile, and ptr. @@ -2916,6 +2860,100 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { return depPaths } +// ChooseStubOrImpl determines whether a given dependency should be redirected to the stub variant +// of the dependency or not, and returns the SharedLibraryInfo and FlagExporterInfo for the right +// dependency. The stub variant is selected when the dependency crosses a boundary where each side +// has different level of updatability. For example, if a library foo in an APEX depends on a +// library bar which provides stable interface and exists in the platform, foo uses the stub variant +// of bar. If bar doesn't provide a stable interface (i.e. buildStubs() == false) or is in the +// same APEX as foo, the non-stub variant of bar is used. +func ChooseStubOrImpl(ctx android.ModuleContext, dep android.Module) (SharedLibraryInfo, FlagExporterInfo) { + depName := ctx.OtherModuleName(dep) + depTag := ctx.OtherModuleDependencyTag(dep) + libDepTag, ok := depTag.(libraryDependencyTag) + if !ok || !libDepTag.shared() { + panic(fmt.Errorf("Unexpected dependency tag: %T", depTag)) + } + + thisModule, ok := ctx.Module().(android.ApexModule) + if !ok { + panic(fmt.Errorf("Not an APEX module: %q", ctx.ModuleName())) + } + + useVndk := false + bootstrap := false + if linkable, ok := ctx.Module().(LinkableInterface); !ok { + panic(fmt.Errorf("Not a Linkable module: %q", ctx.ModuleName())) + } else { + useVndk = linkable.UseVndk() + bootstrap = linkable.Bootstrap() + } + + sharedLibraryInfo := ctx.OtherModuleProvider(dep, SharedLibraryInfoProvider).(SharedLibraryInfo) + depExporterInfo := ctx.OtherModuleProvider(dep, FlagExporterInfoProvider).(FlagExporterInfo) + sharedLibraryStubsInfo := ctx.OtherModuleProvider(dep, SharedLibraryStubsProvider).(SharedLibraryStubsInfo) + apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo) + + if !libDepTag.explicitlyVersioned && len(sharedLibraryStubsInfo.SharedStubLibraries) > 0 { + useStubs := false + + if lib := moduleLibraryInterface(dep); lib.buildStubs() && useVndk { // LLNDK + if !apexInfo.IsForPlatform() { + // For platform libraries, use current version of LLNDK + // If this is for use_vendor apex we will apply the same rules + // of apex sdk enforcement below to choose right version. + useStubs = true + } + } else if apexInfo.IsForPlatform() { + // If not building for APEX, use stubs only when it is from + // an APEX (and not from platform) + // However, for host, ramdisk, vendor_ramdisk, recovery or bootstrap modules, + // always link to non-stub variant + useStubs = dep.(android.ApexModule).NotInPlatform() && !bootstrap + if useStubs { + // Another exception: if this module is a test for an APEX, then + // it is linked with the non-stub variant of a module in the APEX + // as if this is part of the APEX. + testFor := ctx.Provider(android.ApexTestForInfoProvider).(android.ApexTestForInfo) + for _, apexContents := range testFor.ApexContents { + if apexContents.DirectlyInApex(depName) { + useStubs = false + break + } + } + } + if useStubs { + // Yet another exception: If this module and the dependency are + // available to the same APEXes then skip stubs between their + // platform variants. This complements the test_for case above, + // which avoids the stubs on a direct APEX library dependency, by + // avoiding stubs for indirect test dependencies as well. + // + // TODO(b/183882457): This doesn't work if the two libraries have + // only partially overlapping apex_available. For that test_for + // modules would need to be split into APEX variants and resolved + // separately for each APEX they have access to. + if android.AvailableToSameApexes(thisModule, dep.(android.ApexModule)) { + useStubs = false + } + } + } else { + // If building for APEX, use stubs when the parent is in any APEX that + // the child is not in. + useStubs = !android.DirectlyInAllApexes(apexInfo, depName) + } + + // when to use (unspecified) stubs, use the latest one. + if useStubs { + stubs := sharedLibraryStubsInfo.SharedStubLibraries + toUse := stubs[len(stubs)-1] + sharedLibraryInfo = toUse.SharedLibraryInfo + depExporterInfo = toUse.FlagExporterInfo + } + } + return sharedLibraryInfo, depExporterInfo +} + // orderStaticModuleDeps rearranges the order of the static library dependencies of the module // to match the topological order of the dependency tree, including any static analogues of // direct shared libraries. It returns the ordered static dependencies, and an android.DepSet diff --git a/cc/linkable.go b/cc/linkable.go index 0a5d16c16..231626ecc 100644 --- a/cc/linkable.go +++ b/cc/linkable.go @@ -165,6 +165,9 @@ type LinkableInterface interface { // "product_specific: true" modules are included here. UseVndk() bool + // Bootstrap tests if this module is allowed to use non-APEX version of libraries. + Bootstrap() bool + // IsVndkSp returns true if this is a VNDK-SP module. IsVndkSp() bool diff --git a/rust/rust.go b/rust/rust.go index b8c8be5a2..4dd06710d 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -288,6 +288,10 @@ func (mod *Module) UseVndk() bool { return mod.Properties.VndkVersion != "" } +func (mod *Module) Bootstrap() bool { + return false +} + func (mod *Module) MustUseVendorVariant() bool { return true } @@ -952,7 +956,7 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { directRlibDeps := []*Module{} directDylibDeps := []*Module{} directProcMacroDeps := []*Module{} - directSharedLibDeps := [](cc.LinkableInterface){} + directSharedLibDeps := []cc.SharedLibraryInfo{} directStaticLibDeps := [](cc.LinkableInterface){} directSrcProvidersDeps := []*Module{} directSrcDeps := [](android.SourceFileProducer){} @@ -1073,14 +1077,23 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { directStaticLibDeps = append(directStaticLibDeps, ccDep) mod.Properties.AndroidMkStaticLibs = append(mod.Properties.AndroidMkStaticLibs, makeLibName) case cc.IsSharedDepTag(depTag): + // For the shared lib dependencies, we may link to the stub variant + // of the dependency depending on the context (e.g. if this + // dependency crosses the APEX boundaries). + sharedLibraryInfo, exportedInfo := cc.ChooseStubOrImpl(ctx, dep) + + // Re-get linkObject as ChooseStubOrImpl actually tells us which + // object (either from stub or non-stub) to use. + linkObject = android.OptionalPathForPath(sharedLibraryInfo.SharedLibrary) + linkPath = linkPathFromFilePath(linkObject.Path()) + depPaths.linkDirs = append(depPaths.linkDirs, linkPath) depPaths.linkObjects = append(depPaths.linkObjects, linkObject.String()) - exportedInfo := ctx.OtherModuleProvider(dep, cc.FlagExporterInfoProvider).(cc.FlagExporterInfo) depPaths.depIncludePaths = append(depPaths.depIncludePaths, exportedInfo.IncludeDirs...) depPaths.depSystemIncludePaths = append(depPaths.depSystemIncludePaths, exportedInfo.SystemIncludeDirs...) depPaths.depClangFlags = append(depPaths.depClangFlags, exportedInfo.Flags...) depPaths.depGeneratedHeaders = append(depPaths.depGeneratedHeaders, exportedInfo.GeneratedHeaders...) - directSharedLibDeps = append(directSharedLibDeps, ccDep) + directSharedLibDeps = append(directSharedLibDeps, sharedLibraryInfo) // Record baseLibName for snapshots. mod.Properties.SnapshotSharedLibs = append(mod.Properties.SnapshotSharedLibs, cc.BaseLibName(depName)) @@ -1135,11 +1148,11 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps { var sharedLibFiles android.Paths var sharedLibDepFiles android.Paths for _, dep := range directSharedLibDeps { - sharedLibFiles = append(sharedLibFiles, dep.OutputFile().Path()) - if dep.Toc().Valid() { - sharedLibDepFiles = append(sharedLibDepFiles, dep.Toc().Path()) + sharedLibFiles = append(sharedLibFiles, dep.SharedLibrary) + if dep.TableOfContents.Valid() { + sharedLibDepFiles = append(sharedLibDepFiles, dep.TableOfContents.Path()) } else { - sharedLibDepFiles = append(sharedLibDepFiles, dep.OutputFile().Path()) + sharedLibDepFiles = append(sharedLibDepFiles, dep.SharedLibrary) } } From fb63625a7f147735f97d5cc9eaabf3f93cf0d0a2 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 22 Jun 2021 20:23:05 +0900 Subject: [PATCH 011/148] Add platform_apis property to APEX module type The property is used to allow non-updatable APEXes to use platform APIs (e.g. symbols marked as "# platform-only"). Bug: 191637950 Test: m com.android.virt com.android.compos Change-Id: Id2410b4e38a78ec2146a42298840954381a7c472 --- android/apex.go | 15 ++++++++- android/apex_test.go | 57 +++++++++++++++++++++------------- apex/apex.go | 12 ++++++++ apex/apex_test.go | 73 ++++++++++++++++++++++++++++++++++++++++++++ cc/cc.go | 10 +++--- 5 files changed, 140 insertions(+), 27 deletions(-) diff --git a/android/apex.go b/android/apex.go index 4618fe97e..be9adc494 100644 --- a/android/apex.go +++ b/android/apex.go @@ -54,6 +54,10 @@ type ApexInfo struct { // True if this module comes from an updatable apexBundle. Updatable bool + // True if this module can use private platform APIs. Only non-updatable APEX can set this + // to true. + UsePlatformApis bool + // The list of SDK modules that the containing apexBundle depends on. RequiredSdks SdkRefs @@ -91,12 +95,17 @@ var ApexInfoProvider = blueprint.NewMutatorProvider(ApexInfo{}, "apex") // of a module can be deduped into one variation. For example, if libfoo is included in both apex.a // and apex.b, and if the two APEXes have the same min_sdk_version (say 29), then libfoo doesn't // have to be built twice, but only once. In that case, the two apex variations apex.a and apex.b -// are configured to have the same alias variation named apex29. +// are configured to have the same alias variation named apex29. Whether platform APIs is allowed +// or not also matters; if two APEXes don't have the same allowance, they get different names and +// thus wouldn't be merged. func (i ApexInfo) mergedName(ctx PathContext) string { name := "apex" + strconv.Itoa(i.MinSdkVersion.FinalOrFutureInt()) for _, sdk := range i.RequiredSdks { name += "_" + sdk.Name + "_" + sdk.Version } + if i.UsePlatformApis { + name += "_private" + } return name } @@ -527,6 +536,10 @@ func mergeApexVariations(ctx PathContext, apexInfos []ApexInfo) (merged []ApexIn merged[index].InApexModules = append(merged[index].InApexModules, apexInfo.InApexModules...) merged[index].ApexContents = append(merged[index].ApexContents, apexInfo.ApexContents...) merged[index].Updatable = merged[index].Updatable || apexInfo.Updatable + if merged[index].UsePlatformApis != apexInfo.UsePlatformApis { + panic(fmt.Errorf("variants having different UsePlatformApis can't be merged")) + } + merged[index].UsePlatformApis = apexInfo.UsePlatformApis } else { seen[mergedName] = len(merged) apexInfo.ApexVariationName = mergedName diff --git a/android/apex_test.go b/android/apex_test.go index e1123692d..60a639b4b 100644 --- a/android/apex_test.go +++ b/android/apex_test.go @@ -33,10 +33,10 @@ func Test_mergeApexVariations(t *testing.T) { { name: "single", in: []ApexInfo{ - {"foo", FutureApiLevel, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"foo", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, }, wantMerged: []ApexInfo{ - {"apex10000", FutureApiLevel, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"apex10000", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, }, wantAliases: [][2]string{ {"foo", "apex10000"}, @@ -45,11 +45,11 @@ func Test_mergeApexVariations(t *testing.T) { { name: "merge", in: []ApexInfo{ - {"foo", FutureApiLevel, false, SdkRefs{{"baz", "1"}}, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, - {"bar", FutureApiLevel, false, SdkRefs{{"baz", "1"}}, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"foo", FutureApiLevel, false, false, SdkRefs{{"baz", "1"}}, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"bar", FutureApiLevel, false, false, SdkRefs{{"baz", "1"}}, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, }, wantMerged: []ApexInfo{ - {"apex10000_baz_1", FutureApiLevel, false, SdkRefs{{"baz", "1"}}, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, false}}, + {"apex10000_baz_1", FutureApiLevel, false, false, SdkRefs{{"baz", "1"}}, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, false}}, wantAliases: [][2]string{ {"bar", "apex10000_baz_1"}, {"foo", "apex10000_baz_1"}, @@ -58,12 +58,12 @@ func Test_mergeApexVariations(t *testing.T) { { name: "don't merge version", in: []ApexInfo{ - {"foo", FutureApiLevel, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, - {"bar", uncheckedFinalApiLevel(30), false, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"foo", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"bar", uncheckedFinalApiLevel(30), false, false, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, }, wantMerged: []ApexInfo{ - {"apex30", uncheckedFinalApiLevel(30), false, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, - {"apex10000", FutureApiLevel, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"apex30", uncheckedFinalApiLevel(30), false, false, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"apex10000", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, }, wantAliases: [][2]string{ {"bar", "apex30"}, @@ -73,11 +73,11 @@ func Test_mergeApexVariations(t *testing.T) { { name: "merge updatable", in: []ApexInfo{ - {"foo", FutureApiLevel, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, - {"bar", FutureApiLevel, true, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"foo", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"bar", FutureApiLevel, true, false, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, }, wantMerged: []ApexInfo{ - {"apex10000", FutureApiLevel, true, nil, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, NotForPrebuiltApex}, + {"apex10000", FutureApiLevel, true, false, nil, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, NotForPrebuiltApex}, }, wantAliases: [][2]string{ {"bar", "apex10000"}, @@ -87,12 +87,12 @@ func Test_mergeApexVariations(t *testing.T) { { name: "don't merge sdks", in: []ApexInfo{ - {"foo", FutureApiLevel, false, SdkRefs{{"baz", "1"}}, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, - {"bar", FutureApiLevel, false, SdkRefs{{"baz", "2"}}, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"foo", FutureApiLevel, false, false, SdkRefs{{"baz", "1"}}, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"bar", FutureApiLevel, false, false, SdkRefs{{"baz", "2"}}, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, }, wantMerged: []ApexInfo{ - {"apex10000_baz_2", FutureApiLevel, false, SdkRefs{{"baz", "2"}}, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, - {"apex10000_baz_1", FutureApiLevel, false, SdkRefs{{"baz", "1"}}, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"apex10000_baz_2", FutureApiLevel, false, false, SdkRefs{{"baz", "2"}}, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"apex10000_baz_1", FutureApiLevel, false, false, SdkRefs{{"baz", "1"}}, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, }, wantAliases: [][2]string{ {"bar", "apex10000_baz_2"}, @@ -102,21 +102,36 @@ func Test_mergeApexVariations(t *testing.T) { { name: "don't merge when for prebuilt_apex", in: []ApexInfo{ - {"foo", FutureApiLevel, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, - {"bar", FutureApiLevel, true, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"foo", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"bar", FutureApiLevel, true, false, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, // This one should not be merged in with the others because it is for // a prebuilt_apex. - {"baz", FutureApiLevel, true, nil, []string{"baz"}, []string{"baz"}, nil, ForPrebuiltApex}, + {"baz", FutureApiLevel, true, false, nil, []string{"baz"}, []string{"baz"}, nil, ForPrebuiltApex}, }, wantMerged: []ApexInfo{ - {"apex10000", FutureApiLevel, true, nil, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, NotForPrebuiltApex}, - {"baz", FutureApiLevel, true, nil, []string{"baz"}, []string{"baz"}, nil, ForPrebuiltApex}, + {"apex10000", FutureApiLevel, true, false, nil, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, NotForPrebuiltApex}, + {"baz", FutureApiLevel, true, false, nil, []string{"baz"}, []string{"baz"}, nil, ForPrebuiltApex}, }, wantAliases: [][2]string{ {"bar", "apex10000"}, {"foo", "apex10000"}, }, }, + { + name: "don't merge different UsePlatformApis", + in: []ApexInfo{ + {"foo", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"bar", FutureApiLevel, false, true, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + }, + wantMerged: []ApexInfo{ + {"apex10000_private", FutureApiLevel, false, true, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"apex10000", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + }, + wantAliases: [][2]string{ + {"bar", "apex10000_private"}, + {"foo", "apex10000"}, + }, + }, } for _, tt := range tests { diff --git a/apex/apex.go b/apex/apex.go index ecc72b9b5..b3a0d3dfe 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -130,6 +130,10 @@ type apexBundleProperties struct { // symlinking to the system libs. Default is true. Updatable *bool + // Whether this APEX can use platform APIs or not. Can be set to true only when `updatable: + // false`. Default is false. + Platform_apis *bool + // Whether this APEX is installable to one of the partitions like system, vendor, etc. // Default: true. Installable *bool @@ -905,6 +909,7 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) { MinSdkVersion: minSdkVersion, RequiredSdks: a.RequiredSdks(), Updatable: a.Updatable(), + UsePlatformApis: a.UsePlatformApis(), InApexVariants: []string{mctx.ModuleName()}, // could be com.android.foo InApexModules: []string{a.Name()}, // could be com.mycompany.android.foo ApexContents: []*android.ApexContents{apexContents}, @@ -1271,6 +1276,10 @@ func (a *apexBundle) Updatable() bool { return proptools.BoolDefault(a.properties.Updatable, true) } +func (a *apexBundle) UsePlatformApis() bool { + return proptools.BoolDefault(a.properties.Platform_apis, false) +} + // getCertString returns the name of the cert that should be used to sign this APEX. This is // basically from the "certificate" property, but could be overridden by the device config. func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string { @@ -2311,6 +2320,9 @@ func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) { if String(a.properties.Min_sdk_version) == "" { ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well") } + if a.UsePlatformApis() { + ctx.PropertyErrorf("updatable", "updatable APEXes can't use platform APIs") + } a.checkJavaStableSdkVersion(ctx) a.checkClasspathFragments(ctx) } diff --git a/apex/apex_test.go b/apex/apex_test.go index 932438c93..c911dccd9 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -957,6 +957,79 @@ func TestApexWithStubs(t *testing.T) { ensureNotContains(t, rustDeps, "libfoo.shared_from_rust/android_arm64_armv8-a_shared/libfoo.shared_from_rust.so") } +func TestApexCanUsePrivateApis(t *testing.T) { + ctx := testApex(t, ` + apex { + name: "myapex", + key: "myapex.key", + native_shared_libs: ["mylib"], + binaries: ["foo.rust"], + updatable: false, + platform_apis: true, + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + cc_library { + name: "mylib", + srcs: ["mylib.cpp"], + shared_libs: ["mylib2"], + system_shared_libs: [], + stl: "none", + apex_available: [ "myapex" ], + } + + cc_library { + name: "mylib2", + srcs: ["mylib.cpp"], + cflags: ["-include mylib.h"], + system_shared_libs: [], + stl: "none", + stubs: { + versions: ["1", "2", "3"], + }, + } + + rust_binary { + name: "foo.rust", + srcs: ["foo.rs"], + shared_libs: ["libfoo.shared_from_rust"], + prefer_rlib: true, + apex_available: ["myapex"], + } + + cc_library_shared { + name: "libfoo.shared_from_rust", + srcs: ["mylib.cpp"], + system_shared_libs: [], + stl: "none", + stubs: { + versions: ["10", "11", "12"], + }, + } + `) + + apexRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexRule") + copyCmds := apexRule.Args["copy_commands"] + + // Ensure that indirect stubs dep is not included + ensureNotContains(t, copyCmds, "image.apex/lib64/mylib2.so") + ensureNotContains(t, copyCmds, "image.apex/lib64/libfoo.shared_from_rust.so") + + // Ensure that we are using non-stub variants of mylib2 and libfoo.shared_from_rust (because + // of the platform_apis: true) + mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_apex10000_private").Rule("ld").Args["libFlags"] + ensureNotContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared_current/mylib2.so") + ensureContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared/mylib2.so") + rustDeps := ctx.ModuleForTests("foo.rust", "android_arm64_armv8-a_apex10000_private").Rule("rustc").Args["linkFlags"] + ensureNotContains(t, rustDeps, "libfoo.shared_from_rust/android_arm64_armv8-a_shared_current/libfoo.shared_from_rust.so") + ensureContains(t, rustDeps, "libfoo.shared_from_rust/android_arm64_armv8-a_shared/libfoo.shared_from_rust.so") +} + func TestApexWithStubsWithMinSdkVersion(t *testing.T) { t.Parallel() ctx := testApex(t, ` diff --git a/cc/cc.go b/cc/cc.go index e909347e6..fd4d89f08 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -2904,11 +2904,11 @@ func ChooseStubOrImpl(ctx android.ModuleContext, dep android.Module) (SharedLibr // of apex sdk enforcement below to choose right version. useStubs = true } - } else if apexInfo.IsForPlatform() { - // If not building for APEX, use stubs only when it is from - // an APEX (and not from platform) - // However, for host, ramdisk, vendor_ramdisk, recovery or bootstrap modules, - // always link to non-stub variant + } else if apexInfo.IsForPlatform() || apexInfo.UsePlatformApis { + // If not building for APEX or the containing APEX allows the use of + // platform APIs, use stubs only when it is from an APEX (and not from + // platform) However, for host, ramdisk, vendor_ramdisk, recovery or + // bootstrap modules, always link to non-stub variant useStubs = dep.(android.ApexModule).NotInPlatform() && !bootstrap if useStubs { // Another exception: if this module is a test for an APEX, then From 43284a03c8cfa40dfd2c8c7ccb6fda86efff7fc5 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 16 Jul 2021 16:05:50 +0900 Subject: [PATCH 012/148] Add more target-specific properties Following properties are added: * vendor.header_libs * platform.cflags * platform.header_libs * platform.exclude_shared_libs These are used in the *-ndk libraries generated from the aidl_interface modules, so that we can build the platform variants of the libraries just like the *-ndk_platform libraries. Eventually, we will remove the *-ndk_platform libraries. Bug: 161456198 Test: m Change-Id: Ie54b512a6769b3c4c60815b5eeabb4f52263498e --- cc/compiler.go | 9 +++++++++ cc/linker.go | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/cc/compiler.go b/cc/compiler.go index 69ead3089..c4e967fbf 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -189,6 +189,11 @@ type BaseCompilerProperties struct { // variant of the C/C++ module. Cflags []string } + Platform struct { + // List of additional cflags that should be used to build the platform + // variant of the C/C++ module. + Cflags []string + } } Proto struct { @@ -310,6 +315,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps CheckBadCompilerFlags(ctx, "product.cflags", compiler.Properties.Target.Product.Cflags) CheckBadCompilerFlags(ctx, "recovery.cflags", compiler.Properties.Target.Recovery.Cflags) CheckBadCompilerFlags(ctx, "vendor_ramdisk.cflags", compiler.Properties.Target.Vendor_ramdisk.Cflags) + CheckBadCompilerFlags(ctx, "platform.cflags", compiler.Properties.Target.Platform.Cflags) esc := proptools.NinjaAndShellEscapeList @@ -502,6 +508,9 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps if ctx.inVendorRamdisk() { flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Vendor_ramdisk.Cflags)...) } + if !ctx.useSdk() { + flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Platform.Cflags)...) + } // We can enforce some rules more strictly in the code we own. strict // indicates if this is code that we can be stricter with. If we have diff --git a/cc/linker.go b/cc/linker.go index 13df23296..49e754a32 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -111,6 +111,10 @@ type BaseLinkerProperties struct { // product variant of the C/C++ module. Static_libs []string + // list of ehader libs that only should be used to build vendor or product + // variant of the C/C++ module. + Header_libs []string + // list of shared libs that should not be used to build vendor or // product variant of the C/C++ module. Exclude_shared_libs []string @@ -179,6 +183,14 @@ type BaseLinkerProperties struct { // in most cases the same libraries are available for the SDK and platform // variants. Shared_libs []string + + // list of ehader libs that only should be used to build platform variant of + // the C/C++ module. + Header_libs []string + + // list of shared libs that should not be used to build the platform variant + // of the C/C++ module. + Exclude_shared_libs []string } Apex struct { // list of shared libs that should not be used to build the apex variant of @@ -300,6 +312,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, linker.Properties.Target.Vendor.Exclude_shared_libs) deps.StaticLibs = append(deps.StaticLibs, linker.Properties.Target.Vendor.Static_libs...) deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs) + deps.HeaderLibs = append(deps.HeaderLibs, linker.Properties.Target.Vendor.Header_libs...) deps.HeaderLibs = removeListFromList(deps.HeaderLibs, linker.Properties.Target.Vendor.Exclude_header_libs) deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Vendor.Exclude_static_libs) deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs) @@ -349,6 +362,8 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { if !ctx.useSdk() { deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Target.Platform.Shared_libs...) + deps.SharedLibs = removeListFromList(deps.SharedLibs, linker.Properties.Target.Platform.Exclude_shared_libs) + deps.HeaderLibs = append(deps.HeaderLibs, linker.Properties.Target.Platform.Header_libs...) } deps.SystemSharedLibs = linker.overrideDefaultSharedLibraries(ctx) From 57291b7a7a8d3c2f191e82ca5451ebef68052787 Mon Sep 17 00:00:00 2001 From: Martijn Coenen Date: Mon, 19 Jul 2021 08:08:53 +0000 Subject: [PATCH 013/148] Revert "Add more target-specific properties" Revert submission 15310714-remove_ndk_platform Reason for revert: b/193935495 Reverted Changes: Ia87b2881e:NDK backends supports both apps and platform Ia32d82d6e:*-ndk.so libraries are added to the VNDK set. Ie54b512a6:Add more target-specific properties Change-Id: I6d39f9e9570f141c725ec657e59ace476490cd04 --- cc/compiler.go | 9 --------- cc/linker.go | 15 --------------- 2 files changed, 24 deletions(-) diff --git a/cc/compiler.go b/cc/compiler.go index c4e967fbf..69ead3089 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -189,11 +189,6 @@ type BaseCompilerProperties struct { // variant of the C/C++ module. Cflags []string } - Platform struct { - // List of additional cflags that should be used to build the platform - // variant of the C/C++ module. - Cflags []string - } } Proto struct { @@ -315,7 +310,6 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps CheckBadCompilerFlags(ctx, "product.cflags", compiler.Properties.Target.Product.Cflags) CheckBadCompilerFlags(ctx, "recovery.cflags", compiler.Properties.Target.Recovery.Cflags) CheckBadCompilerFlags(ctx, "vendor_ramdisk.cflags", compiler.Properties.Target.Vendor_ramdisk.Cflags) - CheckBadCompilerFlags(ctx, "platform.cflags", compiler.Properties.Target.Platform.Cflags) esc := proptools.NinjaAndShellEscapeList @@ -508,9 +502,6 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps if ctx.inVendorRamdisk() { flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Vendor_ramdisk.Cflags)...) } - if !ctx.useSdk() { - flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Platform.Cflags)...) - } // We can enforce some rules more strictly in the code we own. strict // indicates if this is code that we can be stricter with. If we have diff --git a/cc/linker.go b/cc/linker.go index 49e754a32..13df23296 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -111,10 +111,6 @@ type BaseLinkerProperties struct { // product variant of the C/C++ module. Static_libs []string - // list of ehader libs that only should be used to build vendor or product - // variant of the C/C++ module. - Header_libs []string - // list of shared libs that should not be used to build vendor or // product variant of the C/C++ module. Exclude_shared_libs []string @@ -183,14 +179,6 @@ type BaseLinkerProperties struct { // in most cases the same libraries are available for the SDK and platform // variants. Shared_libs []string - - // list of ehader libs that only should be used to build platform variant of - // the C/C++ module. - Header_libs []string - - // list of shared libs that should not be used to build the platform variant - // of the C/C++ module. - Exclude_shared_libs []string } Apex struct { // list of shared libs that should not be used to build the apex variant of @@ -312,7 +300,6 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, linker.Properties.Target.Vendor.Exclude_shared_libs) deps.StaticLibs = append(deps.StaticLibs, linker.Properties.Target.Vendor.Static_libs...) deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs) - deps.HeaderLibs = append(deps.HeaderLibs, linker.Properties.Target.Vendor.Header_libs...) deps.HeaderLibs = removeListFromList(deps.HeaderLibs, linker.Properties.Target.Vendor.Exclude_header_libs) deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Vendor.Exclude_static_libs) deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs) @@ -362,8 +349,6 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { if !ctx.useSdk() { deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Target.Platform.Shared_libs...) - deps.SharedLibs = removeListFromList(deps.SharedLibs, linker.Properties.Target.Platform.Exclude_shared_libs) - deps.HeaderLibs = append(deps.HeaderLibs, linker.Properties.Target.Platform.Header_libs...) } deps.SystemSharedLibs = linker.overrideDefaultSharedLibraries(ctx) From 20179674872482423872fcb5c1b70a3097ac2ebc Mon Sep 17 00:00:00 2001 From: Joseph Murphy Date: Tue, 20 Jul 2021 13:58:15 -0700 Subject: [PATCH 014/148] Changes tree built Robolectric name Bug: b/194219998 Test: locally ran all in-tree Robolectric tests Change-Id: If13583f6a2882e2e78d3004afc476debf6692df9 --- java/robolectric.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/java/robolectric.go b/java/robolectric.go index 33b1b7a55..dd29cb9a9 100644 --- a/java/robolectric.go +++ b/java/robolectric.go @@ -405,8 +405,10 @@ func (r *robolectricRuntimes) GenerateAndroidBuildActions(ctx android.ModuleCont } runtimeFromSourceJar := android.OutputFileForModule(ctx, runtimeFromSourceModule, "") - runtimeName := fmt.Sprintf("android-all-%s-robolectric-r0.jar", - ctx.Config().PlatformSdkCodename()) + // "TREE" name is essential here because it hooks into the "TREE" name in + // Robolectric's SdkConfig.java that will always correspond to the NEWEST_SDK + // in Robolectric configs. + runtimeName := "android-all-current-robolectric-r0.jar" installedRuntime := ctx.InstallFile(androidAllDir, runtimeName, runtimeFromSourceJar) r.runtimes = append(r.runtimes, installedRuntime) } From bb14481408f3cf381897ffed60be5bd96c389629 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 16 Jul 2021 16:05:50 +0900 Subject: [PATCH 015/148] Reland: Add more target-specific properties Following properties are added: * vendor.header_libs * platform.cflags * platform.header_libs * platform.exclude_shared_libs These are used in the *-ndk libraries generated from the aidl_interface modules, so that we can build the platform variants of the libraries just like the *-ndk_platform libraries. Eventually, we will remove the *-ndk_platform libraries. Bug: 161456198 Test: m Change-Id: I126e272cd29eb1e03662c54bfa8bd64e704adc74 --- cc/compiler.go | 9 +++++++++ cc/linker.go | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/cc/compiler.go b/cc/compiler.go index b01ba4326..34ac47ae3 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -189,6 +189,11 @@ type BaseCompilerProperties struct { // variant of the C/C++ module. Cflags []string } + Platform struct { + // List of additional cflags that should be used to build the platform + // variant of the C/C++ module. + Cflags []string + } } Proto struct { @@ -310,6 +315,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps CheckBadCompilerFlags(ctx, "product.cflags", compiler.Properties.Target.Product.Cflags) CheckBadCompilerFlags(ctx, "recovery.cflags", compiler.Properties.Target.Recovery.Cflags) CheckBadCompilerFlags(ctx, "vendor_ramdisk.cflags", compiler.Properties.Target.Vendor_ramdisk.Cflags) + CheckBadCompilerFlags(ctx, "platform.cflags", compiler.Properties.Target.Platform.Cflags) esc := proptools.NinjaAndShellEscapeList @@ -502,6 +508,9 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps if ctx.inVendorRamdisk() { flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Vendor_ramdisk.Cflags)...) } + if !ctx.useSdk() { + flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Platform.Cflags)...) + } // We can enforce some rules more strictly in the code we own. strict // indicates if this is code that we can be stricter with. If we have diff --git a/cc/linker.go b/cc/linker.go index a712391c2..9932374cb 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -111,6 +111,10 @@ type BaseLinkerProperties struct { // product variant of the C/C++ module. Static_libs []string + // list of ehader libs that only should be used to build vendor or product + // variant of the C/C++ module. + Header_libs []string + // list of shared libs that should not be used to build vendor or // product variant of the C/C++ module. Exclude_shared_libs []string @@ -179,6 +183,14 @@ type BaseLinkerProperties struct { // in most cases the same libraries are available for the SDK and platform // variants. Shared_libs []string + + // list of ehader libs that only should be used to build platform variant of + // the C/C++ module. + Header_libs []string + + // list of shared libs that should not be used to build the platform variant + // of the C/C++ module. + Exclude_shared_libs []string } Apex struct { // list of shared libs that should not be used to build the apex variant of @@ -300,6 +312,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, linker.Properties.Target.Vendor.Exclude_shared_libs) deps.StaticLibs = append(deps.StaticLibs, linker.Properties.Target.Vendor.Static_libs...) deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs) + deps.HeaderLibs = append(deps.HeaderLibs, linker.Properties.Target.Vendor.Header_libs...) deps.HeaderLibs = removeListFromList(deps.HeaderLibs, linker.Properties.Target.Vendor.Exclude_header_libs) deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Vendor.Exclude_static_libs) deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs) @@ -349,6 +362,8 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { if !ctx.useSdk() { deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Target.Platform.Shared_libs...) + deps.SharedLibs = removeListFromList(deps.SharedLibs, linker.Properties.Target.Platform.Exclude_shared_libs) + deps.HeaderLibs = append(deps.HeaderLibs, linker.Properties.Target.Platform.Header_libs...) } deps.SystemSharedLibs = linker.overrideDefaultSharedLibraries(ctx) From b58719c1567606a10d9af626bfe0cd1818ca1836 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Thu, 22 Jul 2021 03:06:58 +0000 Subject: [PATCH 016/148] *-ndk.so libraries are added to VndkMustUseVendorVariantList We will replace the ndk_platform backend with the ndk backend. The former hasn't been deleted yet because there already are references to it. When the existing references are all replaced with the ndk backend, we will remove the ndk_platform backend and the corresponding libraries will be removed from this list. Bug: 161456198 Test: m Change-Id: I7c7aa1025a876e45fc4779378825d91098164e84 --- cc/config/vndk.go | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/cc/config/vndk.go b/cc/config/vndk.go index 00e974cb3..ac3d980f6 100644 --- a/cc/config/vndk.go +++ b/cc/config/vndk.go @@ -19,53 +19,71 @@ package config // has VndkUseCoreVariant set. // TODO(b/150578172): clean up unstable and non-versioned aidl module var VndkMustUseVendorVariantList = []string{ - "android.hardware.authsecret-unstable-ndk_platform", - "android.hardware.authsecret-ndk_platform", + "android.hardware.authsecret-V1-ndk", "android.hardware.authsecret-V1-ndk_platform", - "android.hardware.automotive.occupant_awareness-ndk_platform", + "android.hardware.authsecret-ndk_platform", + "android.hardware.authsecret-unstable-ndk_platform", + "android.hardware.automotive.occupant_awareness-V1-ndk", "android.hardware.automotive.occupant_awareness-V1-ndk_platform", - "android.hardware.gnss-unstable-ndk_platform", - "android.hardware.gnss-ndk_platform", + "android.hardware.automotive.occupant_awareness-ndk_platform", + "android.hardware.gnss-V1-ndk", "android.hardware.gnss-V1-ndk_platform", + "android.hardware.gnss-ndk_platform", + "android.hardware.gnss-unstable-ndk_platform", + "android.hardware.health.storage-V1-ndk", "android.hardware.health.storage-V1-ndk_platform", "android.hardware.health.storage-ndk_platform", "android.hardware.health.storage-unstable-ndk_platform", - "android.hardware.light-V1-ndk_platform", - "android.hardware.light-ndk_platform", "android.hardware.identity-V2-ndk_platform", + "android.hardware.identity-V3-ndk", "android.hardware.identity-V3-ndk_platform", "android.hardware.identity-ndk_platform", - "android.hardware.nfc@1.2", + "android.hardware.light-V1-ndk", + "android.hardware.light-V1-ndk_platform", + "android.hardware.light-ndk_platform", + "android.hardware.memtrack-V1-ndk", "android.hardware.memtrack-V1-ndk_platform", "android.hardware.memtrack-ndk_platform", "android.hardware.memtrack-unstable-ndk_platform", + "android.hardware.nfc@1.2", + "android.hardware.oemlock-V1-ndk", "android.hardware.oemlock-V1-ndk_platform", "android.hardware.oemlock-ndk_platform", "android.hardware.oemlock-unstable-ndk_platform", "android.hardware.power-V1-ndk_platform", + "android.hardware.power-V2-ndk", "android.hardware.power-V2-ndk_platform", "android.hardware.power-ndk_platform", + "android.hardware.power.stats-V1-ndk", "android.hardware.power.stats-V1-ndk_platform", "android.hardware.power.stats-ndk_platform", "android.hardware.power.stats-unstable-ndk_platform", + "android.hardware.rebootescrow-V1-ndk", "android.hardware.rebootescrow-V1-ndk_platform", "android.hardware.rebootescrow-ndk_platform", + "android.hardware.security.keymint-V1-ndk", "android.hardware.security.keymint-V1-ndk_platform", "android.hardware.security.keymint-ndk_platform", "android.hardware.security.keymint-unstable-ndk_platform", + "android.hardware.security.secureclock-V1-ndk", "android.hardware.security.secureclock-V1-ndk_platform", - "android.hardware.security.secureclock-unstable-ndk_platform", "android.hardware.security.secureclock-ndk_platform", + "android.hardware.security.secureclock-unstable-ndk_platform", + "android.hardware.security.sharedsecret-V1-ndk", "android.hardware.security.sharedsecret-V1-ndk_platform", "android.hardware.security.sharedsecret-ndk_platform", "android.hardware.security.sharedsecret-unstable-ndk_platform", + "android.hardware.soundtrigger3-V1-ndk", "android.hardware.soundtrigger3-V1-ndk_platform", "android.hardware.vibrator-V1-ndk_platform", + "android.hardware.vibrator-V2-ndk", "android.hardware.vibrator-V2-ndk_platform", "android.hardware.vibrator-ndk_platform", + "android.hardware.weaver-V1-ndk", "android.hardware.weaver-V1-ndk_platform", "android.hardware.weaver-ndk_platform", "android.hardware.weaver-unstable-ndk_platform", + "android.system.keystore2-V1-ndk", "android.system.keystore2-V1-ndk_platform", "android.system.keystore2-ndk_platform", "android.system.keystore2-unstable-ndk_platform", From 32b0b9f9e4d8dbdb6f0a7a340b963bb705cda353 Mon Sep 17 00:00:00 2001 From: Kalesh Singh Date: Thu, 22 Jul 2021 00:36:17 +0000 Subject: [PATCH 017/148] Update VndkMustUseVendorVariantList Add android.system.suspend-V1-ndk_platform Bug: 170260236 Test: m Change-Id: I93b84112e0fcdd3593ca196308338945376acc1a (cherry picked from commit ada357aeb4f0702c332d68b26815c52b623dcede) --- cc/config/vndk.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cc/config/vndk.go b/cc/config/vndk.go index ac3d980f6..e98a7d96c 100644 --- a/cc/config/vndk.go +++ b/cc/config/vndk.go @@ -87,6 +87,7 @@ var VndkMustUseVendorVariantList = []string{ "android.system.keystore2-V1-ndk_platform", "android.system.keystore2-ndk_platform", "android.system.keystore2-unstable-ndk_platform", + "android.system.suspend-V1-ndk_platform", "libbinder", "libcrypto", "libexpat", From db4604c2af72e6423989cfb02aa7169ef4ee6e30 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 23 Jul 2021 16:26:45 -0700 Subject: [PATCH 018/148] Add android.system.suspend-V1-ndk to VndkMustUseVendorVariantList Test: manual Change-Id: I1a759370e1f2676539baf93ee2e40e789557d676 --- cc/config/vndk.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cc/config/vndk.go b/cc/config/vndk.go index e98a7d96c..6375e1ddd 100644 --- a/cc/config/vndk.go +++ b/cc/config/vndk.go @@ -87,6 +87,7 @@ var VndkMustUseVendorVariantList = []string{ "android.system.keystore2-V1-ndk_platform", "android.system.keystore2-ndk_platform", "android.system.keystore2-unstable-ndk_platform", + "android.system.suspend-V1-ndk", "android.system.suspend-V1-ndk_platform", "libbinder", "libcrypto", From d23d2f1e88c4de7538c0fb4eb182b02cfe176ac4 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 16 Jul 2021 16:05:50 +0900 Subject: [PATCH 019/148] Reland: Add more target-specific properties Following properties are added: * vendor.header_libs * platform.cflags * platform.header_libs * platform.exclude_shared_libs These are used in the *-ndk libraries generated from the aidl_interface modules, so that we can build the platform variants of the libraries just like the *-ndk_platform libraries. Eventually, we will remove the *-ndk_platform libraries. Bug: 161456198 Test: m Merged-In: I126e272cd29eb1e03662c54bfa8bd64e704adc74 Change-Id: I126e272cd29eb1e03662c54bfa8bd64e704adc74 (cherry picked from commit bb14481408f3cf381897ffed60be5bd96c389629) --- cc/compiler.go | 9 +++++++++ cc/linker.go | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/cc/compiler.go b/cc/compiler.go index 78a5a5da3..a6e5ce2af 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -189,6 +189,11 @@ type BaseCompilerProperties struct { // variant of the C/C++ module. Cflags []string } + Platform struct { + // List of additional cflags that should be used to build the platform + // variant of the C/C++ module. + Cflags []string + } } Proto struct { @@ -310,6 +315,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps CheckBadCompilerFlags(ctx, "product.cflags", compiler.Properties.Target.Product.Cflags) CheckBadCompilerFlags(ctx, "recovery.cflags", compiler.Properties.Target.Recovery.Cflags) CheckBadCompilerFlags(ctx, "vendor_ramdisk.cflags", compiler.Properties.Target.Vendor_ramdisk.Cflags) + CheckBadCompilerFlags(ctx, "platform.cflags", compiler.Properties.Target.Platform.Cflags) esc := proptools.NinjaAndShellEscapeList @@ -502,6 +508,9 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps if ctx.inVendorRamdisk() { flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Vendor_ramdisk.Cflags)...) } + if !ctx.useSdk() { + flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Platform.Cflags)...) + } // We can enforce some rules more strictly in the code we own. strict // indicates if this is code that we can be stricter with. If we have diff --git a/cc/linker.go b/cc/linker.go index 449b9ad96..344e5de00 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -104,6 +104,10 @@ type BaseLinkerProperties struct { // product variant of the C/C++ module. Static_libs []string + // list of ehader libs that only should be used to build vendor or product + // variant of the C/C++ module. + Header_libs []string + // list of shared libs that should not be used to build vendor or // product variant of the C/C++ module. Exclude_shared_libs []string @@ -172,6 +176,14 @@ type BaseLinkerProperties struct { // in most cases the same libraries are available for the SDK and platform // variants. Shared_libs []string + + // list of ehader libs that only should be used to build platform variant of + // the C/C++ module. + Header_libs []string + + // list of shared libs that should not be used to build the platform variant + // of the C/C++ module. + Exclude_shared_libs []string } Apex struct { // list of shared libs that should not be used to build the apex variant of @@ -268,6 +280,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, linker.Properties.Target.Vendor.Exclude_shared_libs) deps.StaticLibs = append(deps.StaticLibs, linker.Properties.Target.Vendor.Static_libs...) deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs) + deps.HeaderLibs = append(deps.HeaderLibs, linker.Properties.Target.Vendor.Header_libs...) deps.HeaderLibs = removeListFromList(deps.HeaderLibs, linker.Properties.Target.Vendor.Exclude_header_libs) deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Vendor.Exclude_static_libs) deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs) @@ -317,6 +330,8 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { if !ctx.useSdk() { deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Target.Platform.Shared_libs...) + deps.SharedLibs = removeListFromList(deps.SharedLibs, linker.Properties.Target.Platform.Exclude_shared_libs) + deps.HeaderLibs = append(deps.HeaderLibs, linker.Properties.Target.Platform.Header_libs...) } if ctx.toolchain().Bionic() { From 64646ee5d7a0355e460a73580e1445d697051a7b Mon Sep 17 00:00:00 2001 From: satayev Date: Tue, 15 Jun 2021 16:21:17 +0100 Subject: [PATCH 020/148] Rename ClasspathFragmentToConfiguredJarList methods to configuredJars. They are internal implementation details of individual fragments. Bug: 191127295 Test: m Change-Id: Ib350135f5f6720741492f362f7b3203e5107772e Merged-In: Ib350135f5f6720741492f362f7b3203e5107772e --- java/bootclasspath_fragment.go | 6 +++--- java/classpath_fragment.go | 4 ---- java/platform_bootclasspath.go | 4 ++-- java/systemserver_classpath_fragment.go | 8 ++++---- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index a0399645f..12c7623e0 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -516,14 +516,14 @@ func (b *BootclasspathFragmentModule) generateClasspathProtoBuildActions(ctx and var classpathJars []classpathJar if "art" == proptools.String(b.properties.Image_name) { // ART and platform boot jars must have a corresponding entry in DEX2OATBOOTCLASSPATH - classpathJars = configuredJarListToClasspathJars(ctx, b.ClasspathFragmentToConfiguredJarList(ctx), BOOTCLASSPATH, DEX2OATBOOTCLASSPATH) + classpathJars = configuredJarListToClasspathJars(ctx, b.configuredJars(ctx), BOOTCLASSPATH, DEX2OATBOOTCLASSPATH) } else { - classpathJars = configuredJarListToClasspathJars(ctx, b.ClasspathFragmentToConfiguredJarList(ctx), b.classpathType) + classpathJars = configuredJarListToClasspathJars(ctx, b.configuredJars(ctx), b.classpathType) } b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, classpathJars) } -func (b *BootclasspathFragmentModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList { +func (b *BootclasspathFragmentModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { if "art" == proptools.String(b.properties.Image_name) { return b.getImageConfig(ctx).modules } diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go index ecfdfb7e5..e057b6e7a 100644 --- a/java/classpath_fragment.go +++ b/java/classpath_fragment.go @@ -52,10 +52,6 @@ type classpathFragment interface { android.Module classpathFragmentBase() *ClasspathFragmentBase - - // ClasspathFragmentToConfiguredJarList returns android.ConfiguredJarList representation of all - // the jars in this classpath fragment. - ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList } // ClasspathFragmentBase is meant to be embedded in any module types that implement classpathFragment; diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index 10739b015..b5ad4ceb4 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -199,11 +199,11 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo // Generate classpaths.proto config func (b *platformBootclasspathModule) generateClasspathProtoBuildActions(ctx android.ModuleContext) { // ART and platform boot jars must have a corresponding entry in DEX2OATBOOTCLASSPATH - classpathJars := configuredJarListToClasspathJars(ctx, b.ClasspathFragmentToConfiguredJarList(ctx), BOOTCLASSPATH, DEX2OATBOOTCLASSPATH) + classpathJars := configuredJarListToClasspathJars(ctx, b.configuredJars(ctx), BOOTCLASSPATH, DEX2OATBOOTCLASSPATH) b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, classpathJars) } -func (b *platformBootclasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList { +func (b *platformBootclasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { return b.getImageConfig(ctx).modules } diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go index a2006b778..780a24213 100644 --- a/java/systemserver_classpath_fragment.go +++ b/java/systemserver_classpath_fragment.go @@ -48,11 +48,11 @@ func (p *platformSystemServerClasspathModule) AndroidMkEntries() (entries []andr } func (p *platformSystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { - classpathJars := configuredJarListToClasspathJars(ctx, p.ClasspathFragmentToConfiguredJarList(ctx), p.classpathType) + classpathJars := configuredJarListToClasspathJars(ctx, p.configuredJars(ctx), p.classpathType) p.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, classpathJars) } -func (p *platformSystemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList { +func (p *platformSystemServerClasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { global := dexpreopt.GetGlobalConfig(ctx) return global.SystemServerJars } @@ -91,11 +91,11 @@ func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.Mo ctx.PropertyErrorf("contents", "empty contents are not allowed") } - classpathJars := configuredJarListToClasspathJars(ctx, s.ClasspathFragmentToConfiguredJarList(ctx), s.classpathType) + classpathJars := configuredJarListToClasspathJars(ctx, s.configuredJars(ctx), s.classpathType) s.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, classpathJars) } -func (s *SystemServerClasspathModule) ClasspathFragmentToConfiguredJarList(ctx android.ModuleContext) android.ConfiguredJarList { +func (s *SystemServerClasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { global := dexpreopt.GetGlobalConfig(ctx) possibleUpdatableModules := gatherPossibleUpdatableModuleNamesAndStems(ctx, s.properties.Contents, systemServerClasspathFragmentContentDepTag) From ffe797109ac948957b6fff8b37f10b0ca7e4cdc7 Mon Sep 17 00:00:00 2001 From: satayev Date: Tue, 15 Jun 2021 16:49:50 +0100 Subject: [PATCH 021/148] Add classpath fragment property to skip proto generation. This must always be true for updatable apexes, but is not necessary for non-updatable apexes like com.android.i18n. In a follow up this will be used to figure out whether apex boot jars should be bundled into platform_bootclasspath. Bug: 191127295 Test: atest CtsClasspathsTestCases derive_classpath_test Change-Id: Ib7dc5b057cb24955222fb97f3ff9da079f30ed77 Merged-In: Ib7dc5b057cb24955222fb97f3ff9da079f30ed77 --- apex/apex.go | 42 ++++++++++++---- apex/apex_test.go | 41 ++++++++++++++++ apex/systemserver_classpath_fragment_test.go | 51 ++++++++++++++++++++ java/classpath_fragment.go | 39 ++++++++++----- 4 files changed, 150 insertions(+), 23 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index bea54bccc..7382610c6 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1714,7 +1714,9 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { ctx.PropertyErrorf("systemserverclasspath_fragments", "%q is not a systemserverclasspath_fragment module", depName) return false } - filesInfo = append(filesInfo, apexClasspathFragmentProtoFile(ctx, child)) + if af := apexClasspathFragmentProtoFile(ctx, child); af != nil { + filesInfo = append(filesInfo, *af) + } return true } case javaLibTag: @@ -2111,17 +2113,23 @@ func apexBootclasspathFragmentFiles(ctx android.ModuleContext, module blueprint. } // Add classpaths.proto config. - filesToAdd = append(filesToAdd, apexClasspathFragmentProtoFile(ctx, module)) + if af := apexClasspathFragmentProtoFile(ctx, module); af != nil { + filesToAdd = append(filesToAdd, *af) + } return filesToAdd } -// apexClasspathFragmentProtoFile returns apexFile structure defining the classpath.proto config that -// the module contributes to the apex. -func apexClasspathFragmentProtoFile(ctx android.ModuleContext, module blueprint.Module) apexFile { - fragmentInfo := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo) - classpathProtoOutput := fragmentInfo.ClasspathFragmentProtoOutput - return newApexFile(ctx, classpathProtoOutput, classpathProtoOutput.Base(), fragmentInfo.ClasspathFragmentProtoInstallDir.Rel(), etc, nil) +// apexClasspathFragmentProtoFile returns *apexFile structure defining the classpath.proto config that +// the module contributes to the apex; or nil if the proto config was not generated. +func apexClasspathFragmentProtoFile(ctx android.ModuleContext, module blueprint.Module) *apexFile { + info := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo) + if !info.ClasspathFragmentProtoGenerated { + return nil + } + classpathProtoOutput := info.ClasspathFragmentProtoOutput + af := newApexFile(ctx, classpathProtoOutput, classpathProtoOutput.Base(), info.ClasspathFragmentProtoInstallDir.Rel(), etc, nil) + return &af } // apexFileForBootclasspathFragmentContentModule creates an apexFile for a bootclasspath_fragment @@ -2303,16 +2311,30 @@ func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext }) } -// Enforce that Java deps of the apex are using stable SDKs to compile +// checkUpdatable enforces APEX and its transitive dep properties to have desired values for updatable APEXes. func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) { if a.Updatable() { if String(a.properties.Min_sdk_version) == "" { ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well") } a.checkJavaStableSdkVersion(ctx) + a.checkClasspathFragments(ctx) } } +// checkClasspathFragments enforces that all classpath fragments in deps generate classpaths.proto config. +func (a *apexBundle) checkClasspathFragments(ctx android.ModuleContext) { + ctx.VisitDirectDeps(func(module android.Module) { + if tag := ctx.OtherModuleDependencyTag(module); tag == bcpfTag || tag == sscpfTag { + info := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo) + if !info.ClasspathFragmentProtoGenerated { + ctx.OtherModuleErrorf(module, "is included in updatable apex %v, it must not set generate_classpaths_proto to false", ctx.ModuleName()) + } + } + }) +} + +// checkJavaStableSdkVersion enforces that all Java deps are using stable SDKs to compile. func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) { // Visit direct deps only. As long as we guarantee top-level deps are using stable SDKs, // java's checkLinkType guarantees correct usage for transitive deps @@ -2331,7 +2353,7 @@ func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) { }) } -// Ensures that the all the dependencies are marked as available for this APEX +// checkApexAvailability ensures that the all the dependencies are marked as available for this APEX. func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { // Let's be practical. Availability for test, host, and the VNDK apex isn't important if ctx.Host() || a.testApex || a.vndkApex { diff --git a/apex/apex_test.go b/apex/apex_test.go index 7b01b9481..75c7d47fa 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -6666,6 +6666,47 @@ func TestUpdatableDefault_should_set_min_sdk_version(t *testing.T) { `) } +func TestUpdatable_should_not_set_generate_classpaths_proto(t *testing.T) { + testApexError(t, `"mysystemserverclasspathfragment" .* it must not set generate_classpaths_proto to false`, ` + apex { + name: "myapex", + key: "myapex.key", + systemserverclasspath_fragments: [ + "mysystemserverclasspathfragment", + ], + min_sdk_version: "29", + updatable: true, + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + java_library { + name: "foo", + srcs: ["b.java"], + min_sdk_version: "29", + installable: true, + apex_available: [ + "myapex", + ], + } + + systemserverclasspath_fragment { + name: "mysystemserverclasspathfragment", + generate_classpaths_proto: false, + contents: [ + "foo", + ], + apex_available: [ + "myapex", + ], + } + `) +} + func TestNoUpdatableJarsInBootImage(t *testing.T) { // Set the BootJars in dexpreopt.GlobalConfig and productVariables to the same value. This can // result in an invalid configuration as it does not set the ArtApexJars and allows art apex diff --git a/apex/systemserver_classpath_fragment_test.go b/apex/systemserver_classpath_fragment_test.go index 95b6e230d..537f51d95 100644 --- a/apex/systemserver_classpath_fragment_test.go +++ b/apex/systemserver_classpath_fragment_test.go @@ -76,3 +76,54 @@ func TestSystemserverclasspathFragmentContents(t *testing.T) { `mysystemserverclasspathfragment`, }) } + +func TestSystemserverclasspathFragmentNoGeneratedProto(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForTestWithSystemserverclasspathFragment, + prepareForTestWithMyapex, + ).RunTestWithBp(t, ` + apex { + name: "myapex", + key: "myapex.key", + systemserverclasspath_fragments: [ + "mysystemserverclasspathfragment", + ], + updatable: false, + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + java_library { + name: "foo", + srcs: ["b.java"], + installable: true, + apex_available: [ + "myapex", + ], + } + + systemserverclasspath_fragment { + name: "mysystemserverclasspathfragment", + generate_classpaths_proto: false, + contents: [ + "foo", + ], + apex_available: [ + "myapex", + ], + } + `) + + ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{ + "javalib/foo.jar", + }) + + java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex_image", []string{ + `myapex.key`, + `mysystemserverclasspathfragment`, + }) +} diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go index e057b6e7a..815da7d63 100644 --- a/java/classpath_fragment.go +++ b/java/classpath_fragment.go @@ -19,6 +19,7 @@ package java import ( "fmt" "github.com/google/blueprint" + "github.com/google/blueprint/proptools" "strings" "android/soong/android" @@ -44,6 +45,11 @@ func (c classpathType) String() string { } type classpathFragmentProperties struct { + // Whether to generated classpaths.proto config instance for the fragment. If the config is not + // generated, then relevant boot jars are added to platform classpath, i.e. platform_bootclasspath + // or platform_systemserverclasspath. This is useful for non-updatable APEX boot jars, to keep + // them as part of dexopt on device. Defaults to true. + Generate_classpaths_proto *bool } // classpathFragment interface is implemented by a module that contributes jars to a *CLASSPATH @@ -124,24 +130,28 @@ func configuredJarListToClasspathJars(ctx android.ModuleContext, configuredJars } func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.ModuleContext, jars []classpathJar) { - outputFilename := strings.ToLower(c.classpathType.String()) + ".pb" - c.outputFilepath = android.PathForModuleOut(ctx, outputFilename).OutputPath - c.installDirPath = android.PathForModuleInstall(ctx, "etc", "classpaths") + generateProto := proptools.BoolDefault(c.properties.Generate_classpaths_proto, true) + if generateProto { + outputFilename := strings.ToLower(c.classpathType.String()) + ".pb" + c.outputFilepath = android.PathForModuleOut(ctx, outputFilename).OutputPath + c.installDirPath = android.PathForModuleInstall(ctx, "etc", "classpaths") - generatedJson := android.PathForModuleOut(ctx, outputFilename+".json") - writeClasspathsJson(ctx, generatedJson, jars) + generatedJson := android.PathForModuleOut(ctx, outputFilename+".json") + writeClasspathsJson(ctx, generatedJson, jars) - rule := android.NewRuleBuilder(pctx, ctx) - rule.Command(). - BuiltTool("conv_classpaths_proto"). - Flag("encode"). - Flag("--format=json"). - FlagWithInput("--input=", generatedJson). - FlagWithOutput("--output=", c.outputFilepath) + rule := android.NewRuleBuilder(pctx, ctx) + rule.Command(). + BuiltTool("conv_classpaths_proto"). + Flag("encode"). + Flag("--format=json"). + FlagWithInput("--input=", generatedJson). + FlagWithOutput("--output=", c.outputFilepath) - rule.Build("classpath_fragment", "Compiling "+c.outputFilepath.String()) + rule.Build("classpath_fragment", "Compiling "+c.outputFilepath.String()) + } classpathProtoInfo := ClasspathFragmentProtoContentInfo{ + ClasspathFragmentProtoGenerated: generateProto, ClasspathFragmentProtoInstallDir: c.installDirPath, ClasspathFragmentProtoOutput: c.outputFilepath, } @@ -187,6 +197,9 @@ func (c *ClasspathFragmentBase) androidMkEntries() []android.AndroidMkEntries { var ClasspathFragmentProtoContentInfoProvider = blueprint.NewProvider(ClasspathFragmentProtoContentInfo{}) type ClasspathFragmentProtoContentInfo struct { + // Whether the classpaths.proto config is generated for the fragment. + ClasspathFragmentProtoGenerated bool + // ClasspathFragmentProtoOutput is an output path for the generated classpaths.proto config of this module. // // The file should be copied to a relevant place on device, see ClasspathFragmentProtoInstallDir From 1d0f023abf3fb2d293aa61b6435bf0092e582f99 Mon Sep 17 00:00:00 2001 From: satayev Date: Tue, 15 Jun 2021 17:49:10 +0100 Subject: [PATCH 022/148] Append platform classpath proto configs with missing apex jars. Any apex classpath fragment that doesn't generate its own classpaths proto, must still propagate it's boot jars for the platform classpath fragment to include for complete CLASSPATH variables on device. Bug: 191127295 Test: atest CtsClasspathsTestCases derive_classpath_test Change-Id: I93687f69006741fcd66eb6e04891a4b4bbcc3b47 Merged-In: I93687f69006741fcd66eb6e04891a4b4bbcc3b47 --- apex/platform_bootclasspath_test.go | 59 +++++++++++++++++++++++++ java/bootclasspath_fragment.go | 7 +-- java/classpath_fragment.go | 6 ++- java/platform_bootclasspath.go | 22 +++++++-- java/systemserver_classpath_fragment.go | 14 +++--- java/testing.go | 11 +++++ 6 files changed, 106 insertions(+), 13 deletions(-) diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go index bc354790f..7209c0275 100644 --- a/apex/platform_bootclasspath_test.go +++ b/apex/platform_bootclasspath_test.go @@ -482,3 +482,62 @@ func CheckModuleDependencies(t *testing.T, ctx *android.TestContext, name, varia pairs := java.ApexNamePairsFromModules(ctx, modules) android.AssertDeepEquals(t, "module dependencies", expected, pairs) } + +// TestPlatformBootclasspath_IncludesRemainingApexJars verifies that any apex boot jar is present in +// platform_bootclasspath's classpaths.proto config, if the apex does not generate its own config +// by setting generate_classpaths_proto property to false. +func TestPlatformBootclasspath_IncludesRemainingApexJars(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForTestWithPlatformBootclasspath, + prepareForTestWithMyapex, + java.FixtureConfigureUpdatableBootJars("myapex:foo"), + android.FixtureWithRootAndroidBp(` + platform_bootclasspath { + name: "platform-bootclasspath", + fragments: [ + { + apex: "myapex", + module:"foo-fragment", + }, + ], + } + + apex { + name: "myapex", + key: "myapex.key", + bootclasspath_fragments: ["foo-fragment"], + updatable: false, + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + bootclasspath_fragment { + name: "foo-fragment", + generate_classpaths_proto: false, + contents: ["foo"], + apex_available: ["myapex"], + } + + java_library { + name: "foo", + srcs: ["a.java"], + system_modules: "none", + sdk_version: "none", + compile_dex: true, + apex_available: ["myapex"], + permitted_packages: ["foo"], + } + `), + ).RunTest(t) + + java.CheckClasspathFragmentProtoContentInfoProvider(t, result, + true, // proto should be generated + "myapex:foo", // apex doesn't generate its own config, so must be in platform_bootclasspath + "bootclasspath.pb", + "out/soong/target/product/test_device/system/etc/classpaths", + ) +} diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index 12c7623e0..0d9cde2ca 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -514,13 +514,14 @@ func (b *BootclasspathFragmentModule) provideApexContentInfo(ctx android.ModuleC // generateClasspathProtoBuildActions generates all required build actions for classpath.proto config func (b *BootclasspathFragmentModule) generateClasspathProtoBuildActions(ctx android.ModuleContext) { var classpathJars []classpathJar + configuredJars := b.configuredJars(ctx) if "art" == proptools.String(b.properties.Image_name) { // ART and platform boot jars must have a corresponding entry in DEX2OATBOOTCLASSPATH - classpathJars = configuredJarListToClasspathJars(ctx, b.configuredJars(ctx), BOOTCLASSPATH, DEX2OATBOOTCLASSPATH) + classpathJars = configuredJarListToClasspathJars(ctx, configuredJars, BOOTCLASSPATH, DEX2OATBOOTCLASSPATH) } else { - classpathJars = configuredJarListToClasspathJars(ctx, b.configuredJars(ctx), b.classpathType) + classpathJars = configuredJarListToClasspathJars(ctx, configuredJars, b.classpathType) } - b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, classpathJars) + b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars) } func (b *BootclasspathFragmentModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go index 815da7d63..12bb71174 100644 --- a/java/classpath_fragment.go +++ b/java/classpath_fragment.go @@ -129,7 +129,7 @@ func configuredJarListToClasspathJars(ctx android.ModuleContext, configuredJars return jars } -func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.ModuleContext, jars []classpathJar) { +func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.ModuleContext, configuredJars android.ConfiguredJarList, jars []classpathJar) { generateProto := proptools.BoolDefault(c.properties.Generate_classpaths_proto, true) if generateProto { outputFilename := strings.ToLower(c.classpathType.String()) + ".pb" @@ -152,6 +152,7 @@ func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.M classpathProtoInfo := ClasspathFragmentProtoContentInfo{ ClasspathFragmentProtoGenerated: generateProto, + ClasspathFragmentProtoContents: configuredJars, ClasspathFragmentProtoInstallDir: c.installDirPath, ClasspathFragmentProtoOutput: c.outputFilepath, } @@ -200,6 +201,9 @@ type ClasspathFragmentProtoContentInfo struct { // Whether the classpaths.proto config is generated for the fragment. ClasspathFragmentProtoGenerated bool + // ClasspathFragmentProtoContents contains a list of jars that are part of this classpath fragment. + ClasspathFragmentProtoContents android.ConfiguredJarList + // ClasspathFragmentProtoOutput is an output path for the generated classpaths.proto config of this module. // // The file should be copied to a relevant place on device, see ClasspathFragmentProtoInstallDir diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index b5ad4ceb4..c1e14b21e 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -198,13 +198,29 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo // Generate classpaths.proto config func (b *platformBootclasspathModule) generateClasspathProtoBuildActions(ctx android.ModuleContext) { + configuredJars := b.configuredJars(ctx) // ART and platform boot jars must have a corresponding entry in DEX2OATBOOTCLASSPATH - classpathJars := configuredJarListToClasspathJars(ctx, b.configuredJars(ctx), BOOTCLASSPATH, DEX2OATBOOTCLASSPATH) - b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, classpathJars) + classpathJars := configuredJarListToClasspathJars(ctx, configuredJars, BOOTCLASSPATH, DEX2OATBOOTCLASSPATH) + b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars) } func (b *platformBootclasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { - return b.getImageConfig(ctx).modules + // Include all non APEX jars + jars := b.getImageConfig(ctx).modules + + // Include jars from APEXes that don't populate their classpath proto config. + remainingJars := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars + for _, fragment := range b.fragments { + info := ctx.OtherModuleProvider(fragment, ClasspathFragmentProtoContentInfoProvider).(ClasspathFragmentProtoContentInfo) + if info.ClasspathFragmentProtoGenerated { + remainingJars = remainingJars.RemoveList(info.ClasspathFragmentProtoContents) + } + } + for i := 0; i < remainingJars.Len(); i++ { + jars = jars.Append(remainingJars.Apex(i), remainingJars.Jar(i)) + } + + return jars } // checkNonUpdatableModules ensures that the non-updatable modules supplied are not part of an diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go index 780a24213..e01a06fab 100644 --- a/java/systemserver_classpath_fragment.go +++ b/java/systemserver_classpath_fragment.go @@ -48,13 +48,14 @@ func (p *platformSystemServerClasspathModule) AndroidMkEntries() (entries []andr } func (p *platformSystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { - classpathJars := configuredJarListToClasspathJars(ctx, p.configuredJars(ctx), p.classpathType) - p.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, classpathJars) + configuredJars := p.configuredJars(ctx) + classpathJars := configuredJarListToClasspathJars(ctx, configuredJars, p.classpathType) + p.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars) } func (p *platformSystemServerClasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { - global := dexpreopt.GetGlobalConfig(ctx) - return global.SystemServerJars + // TODO(satayev): include any apex jars that don't populate their classpath proto config. + return dexpreopt.GetGlobalConfig(ctx).SystemServerJars } type SystemServerClasspathModule struct { @@ -91,8 +92,9 @@ func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.Mo ctx.PropertyErrorf("contents", "empty contents are not allowed") } - classpathJars := configuredJarListToClasspathJars(ctx, s.configuredJars(ctx), s.classpathType) - s.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, classpathJars) + configuredJars := s.configuredJars(ctx) + classpathJars := configuredJarListToClasspathJars(ctx, configuredJars, s.classpathType) + s.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars) } func (s *SystemServerClasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { diff --git a/java/testing.go b/java/testing.go index 3ef51bd4d..e2ff5cd12 100644 --- a/java/testing.go +++ b/java/testing.go @@ -364,6 +364,17 @@ func CheckPlatformBootclasspathModules(t *testing.T, result *android.TestResult, android.AssertDeepEquals(t, fmt.Sprintf("%s modules", "platform-bootclasspath"), expected, pairs) } +func CheckClasspathFragmentProtoContentInfoProvider(t *testing.T, result *android.TestResult, generated bool, contents, outputFilename, installDir string) { + t.Helper() + p := result.Module("platform-bootclasspath", "android_common").(*platformBootclasspathModule) + info := result.ModuleProvider(p, ClasspathFragmentProtoContentInfoProvider).(ClasspathFragmentProtoContentInfo) + + android.AssertBoolEquals(t, "classpath proto generated", generated, info.ClasspathFragmentProtoGenerated) + android.AssertStringEquals(t, "classpath proto contents", contents, info.ClasspathFragmentProtoContents.String()) + android.AssertStringEquals(t, "output filepath", outputFilename, info.ClasspathFragmentProtoOutput.Base()) + android.AssertPathRelativeToTopEquals(t, "install filepath", installDir, info.ClasspathFragmentProtoInstallDir) +} + // ApexNamePairsFromModules returns the apex:module pair for the supplied modules. func ApexNamePairsFromModules(ctx *android.TestContext, modules []android.Module) []string { pairs := []string{} From 8137c6a2b63480d32b82e9f8b4dc314dfee01421 Mon Sep 17 00:00:00 2001 From: satayev Date: Thu, 15 Jul 2021 13:22:31 +0100 Subject: [PATCH 023/148] Update a comment about PRODUCT_UPDATABLE_BOOT_JARS. Bug: 191127295 Test: n/a Change-Id: I3d8e8689a79be79714b01cfd8abac34e7d963aee Merged-In: I3d8e8689a79be79714b01cfd8abac34e7d963aee --- java/dexpreopt_bootjars.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 19c65cac7..0ba56caa5 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -159,7 +159,9 @@ import ( // library is a part of a non-updatable APEX). // // A related variable PRODUCT_UPDATABLE_BOOT_JARS contains bootclasspath libraries that are in -// updatable APEXes. They are not included in the boot image. +// APEXes. They are not included in the boot image. The only exception here is core-icu4j.jar that +// has been historically part of the boot image and is now in a non updatable apex; it is treated +// as being part of PRODUCT_BOOT_JARS and is in the boot image. // // One exception to the above rules are "coverage" builds (a special build flavor which requires // setting environment variable EMMA_INSTRUMENT_FRAMEWORK=true). In coverage builds the Java code in From 64e8e775acfff6cd0677ca7b76fa8fc5ff4a5b1d Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Mon, 9 Aug 2021 15:59:14 -0700 Subject: [PATCH 024/148] Add uwb HAL to VndkMustUseVendorVariantList Bug: 195308730 Test: Compiles Change-Id: I8ad83f4aae90a58cfd66d6a2cf320c145cdc7549 --- cc/config/vndk.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cc/config/vndk.go b/cc/config/vndk.go index fe9a9249b..555252462 100644 --- a/cc/config/vndk.go +++ b/cc/config/vndk.go @@ -75,6 +75,8 @@ var VndkMustUseVendorVariantList = []string{ "android.hardware.security.sharedsecret-unstable-ndk_platform", "android.hardware.soundtrigger3-V1-ndk", "android.hardware.soundtrigger3-V1-ndk_platform", + "android.hardware.uwb-V1-ndk", + "android.hardware.uwb-V1-ndk_platform", "android.hardware.vibrator-V1-ndk_platform", "android.hardware.vibrator-V2-ndk", "android.hardware.vibrator-V2-ndk_platform", From 7a552ba9f43763d909aae4a34a5833eecf909cb3 Mon Sep 17 00:00:00 2001 From: satayev Date: Wed, 21 Jul 2021 14:23:52 +0100 Subject: [PATCH 025/148] Rename UpdatableBootJars to ApexBootJars. Note that ART apex boot jars and core-icu4j are exceptions here as they are not part of ApexBootJars. ART apex boot jars are defined in their own variable, while core-icu4j is treated as a regular non-updatable boot jar. Bug: 191127295 Test: atest CtsClasspathsTestCases Change-Id: I3cea3d82ef521655a1a5ffa8cae2258ab9d08bfc Merged-In: I3cea3d82ef521655a1a5ffa8cae2258ab9d08bfc --- android/config.go | 8 +-- android/variable.go | 8 +-- apex/apex_test.go | 10 ++-- apex/bootclasspath_fragment_test.go | 2 +- apex/platform_bootclasspath_test.go | 10 ++-- dexpreopt/config.go | 12 ++--- dexpreopt/testing.go | 6 +-- java/app_test.go | 2 +- java/bootclasspath_fragment.go | 10 ++-- java/classpath_fragment.go | 6 +-- java/dexpreopt_bootjars.go | 12 ++--- java/dexpreopt_config.go | 36 +++++++------- java/hiddenapi.go | 10 ++-- java/java.go | 2 +- java/platform_bootclasspath.go | 65 +++++++++++++------------ java/systemserver_classpath_fragment.go | 6 +-- java/testing.go | 8 +-- sdk/bootclasspath_fragment_sdk_test.go | 4 +- 18 files changed, 105 insertions(+), 112 deletions(-) diff --git a/android/config.go b/android/config.go index 24fc522df..61383e762 100644 --- a/android/config.go +++ b/android/config.go @@ -1812,16 +1812,16 @@ var earlyBootJarsKey = NewOnceKey("earlyBootJars") func (c *config) BootJars() []string { return c.Once(earlyBootJarsKey, func() interface{} { list := c.productVariables.BootJars.CopyOfJars() - return append(list, c.productVariables.UpdatableBootJars.CopyOfJars()...) + return append(list, c.productVariables.ApexBootJars.CopyOfJars()...) }).([]string) } -func (c *config) NonUpdatableBootJars() ConfiguredJarList { +func (c *config) NonApexBootJars() ConfiguredJarList { return c.productVariables.BootJars } -func (c *config) UpdatableBootJars() ConfiguredJarList { - return c.productVariables.UpdatableBootJars +func (c *config) ApexBootJars() ConfiguredJarList { + return c.productVariables.ApexBootJars } func (c *config) RBEWrapper() string { diff --git a/android/variable.go b/android/variable.go index 0dc5262c7..fa2e83e77 100644 --- a/android/variable.go +++ b/android/variable.go @@ -249,8 +249,8 @@ type productVariables struct { UncompressPrivAppDex *bool `json:",omitempty"` ModulesLoadedByPrivilegedModules []string `json:",omitempty"` - BootJars ConfiguredJarList `json:",omitempty"` - UpdatableBootJars ConfiguredJarList `json:",omitempty"` + BootJars ConfiguredJarList `json:",omitempty"` + ApexBootJars ConfiguredJarList `json:",omitempty"` IntegerOverflowExcludePaths []string `json:",omitempty"` @@ -439,8 +439,8 @@ func (v *productVariables) SetDefaultConfig() { Malloc_pattern_fill_contents: boolPtr(false), Safestack: boolPtr(false), - BootJars: ConfiguredJarList{apexes: []string{}, jars: []string{}}, - UpdatableBootJars: ConfiguredJarList{apexes: []string{}, jars: []string{}}, + BootJars: ConfiguredJarList{apexes: []string{}, jars: []string{}}, + ApexBootJars: ConfiguredJarList{apexes: []string{}, jars: []string{}}, } if runtime.GOOS == "linux" { diff --git a/apex/apex_test.go b/apex/apex_test.go index 75c7d47fa..12317a275 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -6840,7 +6840,7 @@ func TestDexpreoptAccessDexFilesFromPrebuiltApex(t *testing.T) { }) } -func testApexPermittedPackagesRules(t *testing.T, errmsg, bp string, apexBootJars []string, rules []android.Rule) { +func testApexPermittedPackagesRules(t *testing.T, errmsg, bp string, bootJars []string, rules []android.Rule) { t.Helper() bp += ` apex_key { @@ -6865,11 +6865,11 @@ func testApexPermittedPackagesRules(t *testing.T, errmsg, bp string, apexBootJar PrepareForTestWithApexBuildComponents, android.PrepareForTestWithNeverallowRules(rules), android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - updatableBootJars := make([]string, 0, len(apexBootJars)) - for _, apexBootJar := range apexBootJars { - updatableBootJars = append(updatableBootJars, "myapex:"+apexBootJar) + apexBootJars := make([]string, 0, len(bootJars)) + for _, apexBootJar := range bootJars { + apexBootJars = append(apexBootJars, "myapex:"+apexBootJar) } - variables.UpdatableBootJars = android.CreateTestConfiguredJarList(updatableBootJars) + variables.ApexBootJars = android.CreateTestConfiguredJarList(apexBootJars) }), fs.AddToFixture(), ). diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go index 4b1600e1c..a1d7797aa 100644 --- a/apex/bootclasspath_fragment_test.go +++ b/apex/bootclasspath_fragment_test.go @@ -734,7 +734,7 @@ func TestBootclasspathFragment_HiddenAPIList(t *testing.T) { prepareForTestWithMyapex, // Configure bootclasspath jars to ensure that hidden API encoding is performed on them. java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"), - java.FixtureConfigureUpdatableBootJars("myapex:foo", "myapex:bar"), + java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"), // Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding // is disabled. android.FixtureAddTextFile("frameworks/base/Android.bp", ""), diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go index 7209c0275..eaee20dd0 100644 --- a/apex/platform_bootclasspath_test.go +++ b/apex/platform_bootclasspath_test.go @@ -173,7 +173,7 @@ func TestPlatformBootclasspathDependencies(t *testing.T) { prepareForTestWithMyapex, // Configure some libraries in the art and framework boot images. java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz", "platform:foo"), - java.FixtureConfigureUpdatableBootJars("myapex:bar"), + java.FixtureConfigureApexBootJars("myapex:bar"), java.PrepareForTestWithJavaSdkLibraryFiles, java.FixtureWithLastReleaseApis("foo"), ).RunTestWithBp(t, ` @@ -288,7 +288,7 @@ func TestPlatformBootclasspathDependencies(t *testing.T) { "com.android.art:quuz", "platform:foo", - // The configured contents of UpdatableBootJars. + // The configured contents of ApexBootJars. "myapex:bar", }) @@ -313,7 +313,7 @@ func TestPlatformBootclasspathDependencies(t *testing.T) { `com.android.art:quuz`, `platform:foo`, - // The configured contents of UpdatableBootJars. + // The configured contents of ApexBootJars. `myapex:bar`, // The fragments. @@ -348,7 +348,7 @@ func TestPlatformBootclasspath_AlwaysUsePrebuiltSdks(t *testing.T) { // if the dependency on myapex:foo is filtered out because of either of those conditions then // the dependencies resolved by the platform_bootclasspath will not match the configured list // and so will fail the test. - java.FixtureConfigureUpdatableBootJars("myapex:foo", "myapex:bar"), + java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"), java.PrepareForTestWithJavaSdkLibraryFiles, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true) @@ -490,7 +490,7 @@ func TestPlatformBootclasspath_IncludesRemainingApexJars(t *testing.T) { result := android.GroupFixturePreparers( prepareForTestWithPlatformBootclasspath, prepareForTestWithMyapex, - java.FixtureConfigureUpdatableBootJars("myapex:foo"), + java.FixtureConfigureApexBootJars("myapex:foo"), android.FixtureWithRootAndroidBp(` platform_bootclasspath { name: "platform-bootclasspath", diff --git a/dexpreopt/config.go b/dexpreopt/config.go index 0bcec17b5..d4ab4bc3b 100644 --- a/dexpreopt/config.go +++ b/dexpreopt/config.go @@ -44,8 +44,8 @@ type GlobalConfig struct { DisableGenerateProfile bool // don't generate profiles ProfileDir string // directory to find profiles in - BootJars android.ConfiguredJarList // modules for jars that form the boot class path - UpdatableBootJars android.ConfiguredJarList // jars within apex that form the boot class path + BootJars android.ConfiguredJarList // modules for jars that form the boot class path + ApexBootJars android.ConfiguredJarList // jars within apex that form the boot class path ArtApexJars android.ConfiguredJarList // modules for jars that are in the ART APEX @@ -531,7 +531,7 @@ func ParseGlobalSoongConfig(ctx android.PathContext, data []byte) (*GlobalSoongC return config, nil } -// checkBootJarsConfigConsistency checks the consistency of BootJars and UpdatableBootJars fields in +// checkBootJarsConfigConsistency checks the consistency of BootJars and ApexBootJars fields in // DexpreoptGlobalConfig and Config.productVariables. func checkBootJarsConfigConsistency(ctx android.SingletonContext, dexpreoptConfig *GlobalConfig, config android.Config) { compareBootJars := func(property string, dexpreoptJars, variableJars android.ConfiguredJarList) { @@ -545,8 +545,8 @@ func checkBootJarsConfigConsistency(ctx android.SingletonContext, dexpreoptConfi } } - compareBootJars("BootJars", dexpreoptConfig.BootJars, config.NonUpdatableBootJars()) - compareBootJars("UpdatableBootJars", dexpreoptConfig.UpdatableBootJars, config.UpdatableBootJars()) + compareBootJars("BootJars", dexpreoptConfig.BootJars, config.NonApexBootJars()) + compareBootJars("ApexBootJars", dexpreoptConfig.ApexBootJars, config.ApexBootJars()) } func (s *globalSoongConfigSingleton) GenerateBuildActions(ctx android.SingletonContext) { @@ -614,7 +614,7 @@ func GlobalConfigForTests(ctx android.PathContext) *GlobalConfig { DisableGenerateProfile: false, ProfileDir: "", BootJars: android.EmptyConfiguredJarList(), - UpdatableBootJars: android.EmptyConfiguredJarList(), + ApexBootJars: android.EmptyConfiguredJarList(), ArtApexJars: android.EmptyConfiguredJarList(), SystemServerJars: android.EmptyConfiguredJarList(), SystemServerApps: nil, diff --git a/dexpreopt/testing.go b/dexpreopt/testing.go index c0ba5ca4e..2f996555f 100644 --- a/dexpreopt/testing.go +++ b/dexpreopt/testing.go @@ -118,10 +118,10 @@ func FixtureSetBootJars(bootJars ...string) android.FixturePreparer { }) } -// FixtureSetUpdatableBootJars sets the UpdatableBootJars property in the global config. -func FixtureSetUpdatableBootJars(bootJars ...string) android.FixturePreparer { +// FixtureSetApexBootJars sets the ApexBootJars property in the global config. +func FixtureSetApexBootJars(bootJars ...string) android.FixturePreparer { return FixtureModifyGlobalConfig(func(dexpreoptConfig *GlobalConfig) { - dexpreoptConfig.UpdatableBootJars = android.CreateTestConfiguredJarList(bootJars) + dexpreoptConfig.ApexBootJars = android.CreateTestConfiguredJarList(bootJars) }) } diff --git a/java/app_test.go b/java/app_test.go index a99ac62da..7997f7ad8 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -2471,7 +2471,7 @@ func TestDexpreoptBcp(t *testing.T) { PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("runtime-library", "foo", "bar"), dexpreopt.FixtureSetBootJars("platform:foo"), - dexpreopt.FixtureSetUpdatableBootJars("platform:bar"), + dexpreopt.FixtureSetApexBootJars("platform:bar"), dexpreopt.FixtureSetPreoptWithUpdatableBcp(test.with), ).RunTestWithBp(t, bp) diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index 0d9cde2ca..750ed852f 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -531,15 +531,11 @@ func (b *BootclasspathFragmentModule) configuredJars(ctx android.ModuleContext) global := dexpreopt.GetGlobalConfig(ctx) - possibleUpdatableModules := gatherPossibleUpdatableModuleNamesAndStems(ctx, b.properties.Contents, bootclasspathFragmentContentDepTag) - - // Only create configs for updatable boot jars. Non-updatable boot jars must be part of the - // platform_bootclasspath's classpath proto config to guarantee that they come before any - // updatable jars at runtime. - jars := global.UpdatableBootJars.Filter(possibleUpdatableModules) + possibleUpdatableModules := gatherPossibleApexModuleNamesAndStems(ctx, b.properties.Contents, bootclasspathFragmentContentDepTag) + jars := global.ApexBootJars.Filter(possibleUpdatableModules) // TODO(satayev): for apex_test we want to include all contents unconditionally to classpaths - // config. However, any test specific jars would not be present in UpdatableBootJars. Instead, + // config. However, any test specific jars would not be present in ApexBootJars. Instead, // we should check if we are creating a config for apex_test via ApexInfo and amend the values. // This is an exception to support end-to-end test for SdkExtensions, until such support exists. if android.InList("test_framework-sdkextensions", possibleUpdatableModules) { diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go index 12bb71174..f63d81d6e 100644 --- a/java/classpath_fragment.go +++ b/java/classpath_fragment.go @@ -91,8 +91,8 @@ type classpathJar struct { maxSdkVersion int32 } -// gatherPossibleUpdatableModuleNamesAndStems returns a set of module and stem names from the -// supplied contents that may be in the updatable boot jars. +// gatherPossibleApexModuleNamesAndStems returns a set of module and stem names from the +// supplied contents that may be in the apex boot jars. // // The module names are included because sometimes the stem is set to just change the name of // the installed file and it expects the configuration to still use the actual module name. @@ -100,7 +100,7 @@ type classpathJar struct { // The stem names are included because sometimes the stem is set to change the effective name of the // module that is used in the configuration as well,e .g. when a test library is overriding an // actual boot jar -func gatherPossibleUpdatableModuleNamesAndStems(ctx android.ModuleContext, contents []string, tag blueprint.DependencyTag) []string { +func gatherPossibleApexModuleNamesAndStems(ctx android.ModuleContext, contents []string, tag blueprint.DependencyTag) []string { set := map[string]struct{}{} for _, name := range contents { dep := ctx.GetDirectDepWithTag(name, tag) diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 0ba56caa5..a9ace19da 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -158,10 +158,10 @@ import ( // name (if the library is a part of the Platform), or a colon-separated pair (if the // library is a part of a non-updatable APEX). // -// A related variable PRODUCT_UPDATABLE_BOOT_JARS contains bootclasspath libraries that are in -// APEXes. They are not included in the boot image. The only exception here is core-icu4j.jar that -// has been historically part of the boot image and is now in a non updatable apex; it is treated -// as being part of PRODUCT_BOOT_JARS and is in the boot image. +// A related variable PRODUCT_APEX_BOOT_JARS contains bootclasspath libraries that are in APEXes. +// They are not included in the boot image. The only exception here are ART jars and core-icu4j.jar +// that have been historically part of the boot image and are now in apexes; they are in boot images +// and core-icu4j.jar is generally treated as being part of PRODUCT_BOOT_JARS. // // One exception to the above rules are "coverage" builds (a special build flavor which requires // setting environment variable EMMA_INSTRUMENT_FRAMEWORK=true). In coverage builds the Java code in @@ -801,10 +801,10 @@ func bootFrameworkProfileRule(ctx android.ModuleContext, image *bootImageConfig) // generateUpdatableBcpPackagesRule generates the rule to create the updatable-bcp-packages.txt file // and returns a path to the generated file. -func generateUpdatableBcpPackagesRule(ctx android.ModuleContext, image *bootImageConfig, updatableModules []android.Module) android.WritablePath { +func generateUpdatableBcpPackagesRule(ctx android.ModuleContext, image *bootImageConfig, apexModules []android.Module) android.WritablePath { // Collect `permitted_packages` for updatable boot jars. var updatablePackages []string - for _, module := range updatableModules { + for _, module := range apexModules { if j, ok := module.(PermittedPackagesForUpdatableBootJars); ok { pp := j.PermittedPackagesForUpdatableBootJars() if len(pp) > 0 { diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go index b13955fba..9d16aa20e 100644 --- a/java/dexpreopt_config.go +++ b/java/dexpreopt_config.go @@ -142,14 +142,14 @@ func defaultBootImageConfig(ctx android.PathContext) *bootImageConfig { return genBootImageConfigs(ctx)[frameworkBootImageName] } -// Updatable boot config allows to access build/install paths of updatable boot jars without going +// Apex boot config allows to access build/install paths of apex boot jars without going // through the usual trouble of registering dependencies on those modules and extracting build paths // from those dependencies. -type updatableBootConfig struct { - // A list of updatable boot jars. +type apexBootConfig struct { + // A list of apex boot jars. modules android.ConfiguredJarList - // A list of predefined build paths to updatable boot jars. They are configured very early, + // A list of predefined build paths to apex boot jars. They are configured very early, // before the modules for these jars are processed and the actual paths are generated, and // later on a singleton adds commands to copy actual jars to the predefined paths. dexPaths android.WritablePaths @@ -161,21 +161,21 @@ type updatableBootConfig struct { dexLocations []string } -var updatableBootConfigKey = android.NewOnceKey("updatableBootConfig") +var updatableBootConfigKey = android.NewOnceKey("apexBootConfig") -// Returns updatable boot config. -func GetUpdatableBootConfig(ctx android.PathContext) updatableBootConfig { +// Returns apex boot config. +func GetApexBootConfig(ctx android.PathContext) apexBootConfig { return ctx.Config().Once(updatableBootConfigKey, func() interface{} { - updatableBootJars := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars + apexBootJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars - dir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "updatable_bootjars") - dexPaths := updatableBootJars.BuildPaths(ctx, dir) - dexPathsByModuleName := updatableBootJars.BuildPathsByModule(ctx, dir) + dir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "apex_bootjars") + dexPaths := apexBootJars.BuildPaths(ctx, dir) + dexPathsByModuleName := apexBootJars.BuildPathsByModule(ctx, dir) - dexLocations := updatableBootJars.DevicePaths(ctx.Config(), android.Android) + dexLocations := apexBootJars.DevicePaths(ctx.Config(), android.Android) - return updatableBootConfig{updatableBootJars, dexPaths, dexPathsByModuleName, dexLocations} - }).(updatableBootConfig) + return apexBootConfig{apexBootJars, dexPaths, dexPathsByModuleName, dexLocations} + }).(apexBootConfig) } // Returns a list of paths and a list of locations for the boot jars used in dexpreopt (to be @@ -188,10 +188,10 @@ func bcpForDexpreopt(ctx android.PathContext, withUpdatable bool) (android.Writa dexLocations := bootImage.getAnyAndroidVariant().dexLocationsDeps if withUpdatable { - // Updatable boot jars (they are used only in dexpreopt, but not in the boot image). - updBootConfig := GetUpdatableBootConfig(ctx) - dexPaths = append(dexPaths, updBootConfig.dexPaths...) - dexLocations = append(dexLocations, updBootConfig.dexLocations...) + // Apex boot jars (they are used only in dexpreopt, but not in the boot image). + apexBootConfig := GetApexBootConfig(ctx) + dexPaths = append(dexPaths, apexBootConfig.dexPaths...) + dexLocations = append(dexLocations, apexBootConfig.dexLocations...) } return dexPaths, dexLocations diff --git a/java/hiddenapi.go b/java/hiddenapi.go index f901434a0..30683daa0 100644 --- a/java/hiddenapi.go +++ b/java/hiddenapi.go @@ -118,11 +118,11 @@ func (h *hiddenAPI) initHiddenAPI(ctx android.ModuleContext, dexJar, classesJar } func isModuleInBootClassPath(ctx android.BaseModuleContext, module android.Module) bool { - // Get the configured non-updatable and updatable boot jars. - nonUpdatableBootJars := ctx.Config().NonUpdatableBootJars() - updatableBootJars := ctx.Config().UpdatableBootJars() - active := isModuleInConfiguredList(ctx, module, nonUpdatableBootJars) || - isModuleInConfiguredList(ctx, module, updatableBootJars) + // Get the configured platform and apex boot jars. + nonApexBootJars := ctx.Config().NonApexBootJars() + apexBootJars := ctx.Config().ApexBootJars() + active := isModuleInConfiguredList(ctx, module, nonApexBootJars) || + isModuleInConfiguredList(ctx, module, apexBootJars) return active } diff --git a/java/java.go b/java/java.go index bbed42def..02e06e0c0 100644 --- a/java/java.go +++ b/java/java.go @@ -450,7 +450,7 @@ type Library struct { var _ android.ApexModule = (*Library)(nil) -// Provides access to the list of permitted packages from updatable boot jars. +// Provides access to the list of permitted packages from apex boot jars. type PermittedPackagesForUpdatableBootJars interface { PermittedPackagesForUpdatableBootJars() []string } diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index c1e14b21e..cf266b80b 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -32,9 +32,9 @@ func registerPlatformBootclasspathBuildComponents(ctx android.RegistrationContex // The tags used for the dependencies between the platform bootclasspath and any configured boot // jars. var ( - platformBootclasspathArtBootJarDepTag = bootclasspathDependencyTag{name: "art-boot-jar"} - platformBootclasspathNonUpdatableBootJarDepTag = bootclasspathDependencyTag{name: "non-updatable-boot-jar"} - platformBootclasspathUpdatableBootJarDepTag = bootclasspathDependencyTag{name: "updatable-boot-jar"} + platformBootclasspathArtBootJarDepTag = bootclasspathDependencyTag{name: "art-boot-jar"} + platformBootclasspathBootJarDepTag = bootclasspathDependencyTag{name: "platform-boot-jar"} + platformBootclasspathApexBootJarDepTag = bootclasspathDependencyTag{name: "apex-boot-jar"} ) type platformBootclasspathModule struct { @@ -131,11 +131,11 @@ func (b *platformBootclasspathModule) BootclasspathDepsMutator(ctx android.Botto // Add dependencies on all the non-updatable module configured in the "boot" boot image. That does // not include modules configured in the "art" boot image. bootImageConfig := b.getImageConfig(ctx) - addDependenciesOntoBootImageModules(ctx, bootImageConfig.modules, platformBootclasspathNonUpdatableBootJarDepTag) + addDependenciesOntoBootImageModules(ctx, bootImageConfig.modules, platformBootclasspathBootJarDepTag) - // Add dependencies on all the updatable modules. - updatableModules := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars - addDependenciesOntoBootImageModules(ctx, updatableModules, platformBootclasspathUpdatableBootJarDepTag) + // Add dependencies on all the apex jars. + apexJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars + addDependenciesOntoBootImageModules(ctx, apexJars, platformBootclasspathApexBootJarDepTag) // Add dependencies on all the fragments. b.properties.BootclasspathFragmentsDepsProperties.addDependenciesOntoFragments(ctx) @@ -163,16 +163,16 @@ func (d *platformBootclasspathModule) MakeVars(ctx android.MakeVarsContext) { } func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { - // Gather all the dependencies from the art, updatable and non-updatable boot jars. + // Gather all the dependencies from the art, platform, and apex boot jars. artModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathArtBootJarDepTag) - nonUpdatableModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathNonUpdatableBootJarDepTag) - updatableModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathUpdatableBootJarDepTag) + platformModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathBootJarDepTag) + apexModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathApexBootJarDepTag) // Concatenate them all, in order as they would appear on the bootclasspath. var allModules []android.Module allModules = append(allModules, artModules...) - allModules = append(allModules, nonUpdatableModules...) - allModules = append(allModules, updatableModules...) + allModules = append(allModules, platformModules...) + allModules = append(allModules, apexModules...) b.configuredModules = allModules // Gather all the fragments dependencies. @@ -180,8 +180,8 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo // Check the configuration of the boot modules. // ART modules are checked by the art-bootclasspath-fragment. - b.checkNonUpdatableModules(ctx, nonUpdatableModules) - b.checkUpdatableModules(ctx, updatableModules) + b.checkPlatformModules(ctx, platformModules) + b.checkApexModules(ctx, apexModules) b.generateClasspathProtoBuildActions(ctx) @@ -193,7 +193,7 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo return } - b.generateBootImageBuildActions(ctx, nonUpdatableModules, updatableModules) + b.generateBootImageBuildActions(ctx, platformModules, apexModules) } // Generate classpaths.proto config @@ -209,7 +209,7 @@ func (b *platformBootclasspathModule) configuredJars(ctx android.ModuleContext) jars := b.getImageConfig(ctx).modules // Include jars from APEXes that don't populate their classpath proto config. - remainingJars := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars + remainingJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars for _, fragment := range b.fragments { info := ctx.OtherModuleProvider(fragment, ClasspathFragmentProtoContentInfoProvider).(ClasspathFragmentProtoContentInfo) if info.ClasspathFragmentProtoGenerated { @@ -223,9 +223,10 @@ func (b *platformBootclasspathModule) configuredJars(ctx android.ModuleContext) return jars } -// checkNonUpdatableModules ensures that the non-updatable modules supplied are not part of an -// updatable module. -func (b *platformBootclasspathModule) checkNonUpdatableModules(ctx android.ModuleContext, modules []android.Module) { +// checkPlatformModules ensures that the non-updatable modules supplied are not part of an +// apex module. +func (b *platformBootclasspathModule) checkPlatformModules(ctx android.ModuleContext, modules []android.Module) { + // TODO(satayev): change this check to only allow core-icu4j, all apex jars should not be here. for _, m := range modules { apexInfo := ctx.OtherModuleProvider(m, android.ApexInfoProvider).(android.ApexInfo) fromUpdatableApex := apexInfo.Updatable @@ -238,8 +239,8 @@ func (b *platformBootclasspathModule) checkNonUpdatableModules(ctx android.Modul } } -// checkUpdatableModules ensures that the updatable modules supplied are not from the platform. -func (b *platformBootclasspathModule) checkUpdatableModules(ctx android.ModuleContext, modules []android.Module) { +// checkApexModules ensures that the apex modules supplied are not from the platform. +func (b *platformBootclasspathModule) checkApexModules(ctx android.ModuleContext, modules []android.Module) { for _, m := range modules { apexInfo := ctx.OtherModuleProvider(m, android.ApexInfoProvider).(android.ApexInfo) fromUpdatableApex := apexInfo.Updatable @@ -255,12 +256,12 @@ func (b *platformBootclasspathModule) checkUpdatableModules(ctx android.ModuleCo // modules is complete. if !ctx.Config().AlwaysUsePrebuiltSdks() { // error: this jar is part of the platform - ctx.ModuleErrorf("module %q from platform is not allowed in the updatable boot jars list", name) + ctx.ModuleErrorf("module %q from platform is not allowed in the apex boot jars list", name) } } else { // TODO(b/177892522): Treat this as an error. // Cannot do that at the moment because framework-wifi and framework-tethering are in the - // PRODUCT_UPDATABLE_BOOT_JARS but not marked as updatable in AOSP. + // PRODUCT_APEX_BOOT_JARS but not marked as updatable in AOSP. } } } @@ -405,7 +406,7 @@ func (b *platformBootclasspathModule) generateHiddenApiMakeVars(ctx android.Make } // generateBootImageBuildActions generates ninja rules related to the boot image creation. -func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android.ModuleContext, nonUpdatableModules, updatableModules []android.Module) { +func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android.ModuleContext, platformModules, apexModules []android.Module) { // Force the GlobalSoongConfig to be created and cached for use by the dex_bootjars // GenerateSingletonBuildActions method as it cannot create it for itself. dexpreopt.GetGlobalSoongConfig(ctx) @@ -424,16 +425,16 @@ func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android. bootFrameworkProfileRule(ctx, imageConfig) // Generate the updatable bootclasspath packages rule. - generateUpdatableBcpPackagesRule(ctx, imageConfig, updatableModules) + generateUpdatableBcpPackagesRule(ctx, imageConfig, apexModules) - // Copy non-updatable module dex jars to their predefined locations. - nonUpdatableBootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, nonUpdatableModules) - copyBootJarsToPredefinedLocations(ctx, nonUpdatableBootDexJarsByModule, imageConfig.dexPathsByModule) + // Copy platform module dex jars to their predefined locations. + platformBootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, platformModules) + copyBootJarsToPredefinedLocations(ctx, platformBootDexJarsByModule, imageConfig.dexPathsByModule) - // Copy updatable module dex jars to their predefined locations. - config := GetUpdatableBootConfig(ctx) - updatableBootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, updatableModules) - copyBootJarsToPredefinedLocations(ctx, updatableBootDexJarsByModule, config.dexPathsByModule) + // Copy apex module dex jars to their predefined locations. + config := GetApexBootConfig(ctx) + apexBootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, apexModules) + copyBootJarsToPredefinedLocations(ctx, apexBootDexJarsByModule, config.dexPathsByModule) // Build a profile for the image config and then use that to build the boot image. profile := bootImageProfileRule(ctx, imageConfig) diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go index e01a06fab..f2ec6167d 100644 --- a/java/systemserver_classpath_fragment.go +++ b/java/systemserver_classpath_fragment.go @@ -100,11 +100,7 @@ func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.Mo func (s *SystemServerClasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { global := dexpreopt.GetGlobalConfig(ctx) - possibleUpdatableModules := gatherPossibleUpdatableModuleNamesAndStems(ctx, s.properties.Contents, systemServerClasspathFragmentContentDepTag) - - // Only create configs for updatable boot jars. Non-updatable system server jars must be part of the - // platform_systemserverclasspath's classpath proto config to guarantee that they come before any - // updatable jars at runtime. + possibleUpdatableModules := gatherPossibleApexModuleNamesAndStems(ctx, s.properties.Contents, systemServerClasspathFragmentContentDepTag) return global.UpdatableSystemServerJars.Filter(possibleUpdatableModules) } diff --git a/java/testing.go b/java/testing.go index e2ff5cd12..8860b45fa 100644 --- a/java/testing.go +++ b/java/testing.go @@ -214,15 +214,15 @@ func FixtureConfigureBootJars(bootJars ...string) android.FixturePreparer { ) } -// FixtureConfigureUpdatableBootJars configures the updatable boot jars in both the +// FixtureConfigureApexBootJars configures the apex boot jars in both the // dexpreopt.GlobalConfig and Config.productVariables structs. As a side effect that enables // dexpreopt. -func FixtureConfigureUpdatableBootJars(bootJars ...string) android.FixturePreparer { +func FixtureConfigureApexBootJars(bootJars ...string) android.FixturePreparer { return android.GroupFixturePreparers( android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.UpdatableBootJars = android.CreateTestConfiguredJarList(bootJars) + variables.ApexBootJars = android.CreateTestConfiguredJarList(bootJars) }), - dexpreopt.FixtureSetUpdatableBootJars(bootJars...), + dexpreopt.FixtureSetApexBootJars(bootJars...), // Add a fake dex2oatd module. dexpreopt.PrepareForTestWithFakeDex2oatd, diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go index 412e80682..1718734c0 100644 --- a/sdk/bootclasspath_fragment_sdk_test.go +++ b/sdk/bootclasspath_fragment_sdk_test.go @@ -224,7 +224,7 @@ func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) { java.PrepareForTestWithJavaDefaultModules, java.PrepareForTestWithJavaSdkLibraryFiles, java.FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"), - java.FixtureConfigureUpdatableBootJars("myapex:mybootlib", "myapex:myothersdklibrary"), + java.FixtureConfigureApexBootJars("myapex:mybootlib", "myapex:myothersdklibrary"), prepareForSdkTestWithApex, // Add a platform_bootclasspath that depends on the fragment. @@ -607,7 +607,7 @@ func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { java.PrepareForTestWithJavaDefaultModules, java.PrepareForTestWithJavaSdkLibraryFiles, java.FixtureWithLastReleaseApis("mysdklibrary"), - java.FixtureConfigureUpdatableBootJars("myapex:mybootlib"), + java.FixtureConfigureApexBootJars("myapex:mybootlib"), prepareForSdkTestWithApex, // Add a platform_bootclasspath that depends on the fragment. From fcea20c4e7e5869aa90dcccffb8071452cc04781 Mon Sep 17 00:00:00 2001 From: satayev Date: Wed, 28 Jul 2021 14:04:49 +0100 Subject: [PATCH 026/148] Rename UpdatableSystemServerJars to ApexSystemServerJars. This is consistent with naming for boot jars, e.g. ApexBootJars. Bug: 191127295 Test: presubmit Change-Id: I6e8828d55ac86b7f5260ed7f8d4eca1c0b3dced8 Merged-In: I6e8828d55ac86b7f5260ed7f8d4eca1c0b3dced8 --- dexpreopt/config.go | 10 +++++----- dexpreopt/dexpreopt.go | 14 +++++++------- java/systemserver_classpath_fragment.go | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dexpreopt/config.go b/dexpreopt/config.go index d4ab4bc3b..7a74506b7 100644 --- a/dexpreopt/config.go +++ b/dexpreopt/config.go @@ -49,10 +49,10 @@ type GlobalConfig struct { ArtApexJars android.ConfiguredJarList // modules for jars that are in the ART APEX - SystemServerJars android.ConfiguredJarList // jars that form the system server - SystemServerApps []string // apps that are loaded into system server - UpdatableSystemServerJars android.ConfiguredJarList // jars within apex that are loaded into system server - SpeedApps []string // apps that should be speed optimized + SystemServerJars android.ConfiguredJarList // jars that form the system server + SystemServerApps []string // apps that are loaded into system server + ApexSystemServerJars android.ConfiguredJarList // jars within apex that are loaded into system server + SpeedApps []string // apps that should be speed optimized BrokenSuboptimalOrderOfSystemServerJars bool // if true, sub-optimal order does not cause a build error @@ -618,7 +618,7 @@ func GlobalConfigForTests(ctx android.PathContext) *GlobalConfig { ArtApexJars: android.EmptyConfiguredJarList(), SystemServerJars: android.EmptyConfiguredJarList(), SystemServerApps: nil, - UpdatableSystemServerJars: android.EmptyConfiguredJarList(), + ApexSystemServerJars: android.EmptyConfiguredJarList(), SpeedApps: nil, PreoptFlags: nil, DefaultCompilerFilter: "", diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go index da015a389..4c6ae82e9 100644 --- a/dexpreopt/dexpreopt.go +++ b/dexpreopt/dexpreopt.go @@ -111,7 +111,7 @@ func dexpreoptDisabled(ctx android.PathContext, global *GlobalConfig, module *Mo } // Don't preopt system server jars that are updatable. - if global.UpdatableSystemServerJars.ContainsJar(module.Name) { + if global.ApexSystemServerJars.ContainsJar(module.Name) { return true } @@ -234,7 +234,7 @@ func dexpreoptCommand(ctx android.PathContext, globalSoong *GlobalSoongConfig, g invocationPath := odexPath.ReplaceExtension(ctx, "invocation") - systemServerJars := NonUpdatableSystemServerJars(ctx, global) + systemServerJars := NonApexSystemServerJars(ctx, global) rule.Command().FlagWithArg("mkdir -p ", filepath.Dir(odexPath.String())) rule.Command().FlagWithOutput("rm -f ", odexPath) @@ -523,13 +523,13 @@ func makefileMatch(pattern, s string) bool { } } -var nonUpdatableSystemServerJarsKey = android.NewOnceKey("nonUpdatableSystemServerJars") +var nonApexSystemServerJarsKey = android.NewOnceKey("nonApexSystemServerJars") // TODO: eliminate the superficial global config parameter by moving global config definition // from java subpackage to dexpreopt. -func NonUpdatableSystemServerJars(ctx android.PathContext, global *GlobalConfig) []string { - return ctx.Config().Once(nonUpdatableSystemServerJarsKey, func() interface{} { - return android.RemoveListFromList(global.SystemServerJars.CopyOfJars(), global.UpdatableSystemServerJars.CopyOfJars()) +func NonApexSystemServerJars(ctx android.PathContext, global *GlobalConfig) []string { + return ctx.Config().Once(nonApexSystemServerJarsKey, func() interface{} { + return android.RemoveListFromList(global.SystemServerJars.CopyOfJars(), global.ApexSystemServerJars.CopyOfJars()) }).([]string) } @@ -556,7 +556,7 @@ func checkSystemServerOrder(ctx android.PathContext, jarIndex int) { mctx, isModule := ctx.(android.ModuleContext) if isModule { config := GetGlobalConfig(ctx) - jars := NonUpdatableSystemServerJars(ctx, config) + jars := NonApexSystemServerJars(ctx, config) mctx.WalkDeps(func(dep android.Module, parent android.Module) bool { depIndex := android.IndexList(dep.Name(), jars) if jarIndex < depIndex && !config.BrokenSuboptimalOrderOfSystemServerJars { diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go index f2ec6167d..10dbd01e2 100644 --- a/java/systemserver_classpath_fragment.go +++ b/java/systemserver_classpath_fragment.go @@ -101,7 +101,7 @@ func (s *SystemServerClasspathModule) configuredJars(ctx android.ModuleContext) global := dexpreopt.GetGlobalConfig(ctx) possibleUpdatableModules := gatherPossibleApexModuleNamesAndStems(ctx, s.properties.Contents, systemServerClasspathFragmentContentDepTag) - return global.UpdatableSystemServerJars.Filter(possibleUpdatableModules) + return global.ApexSystemServerJars.Filter(possibleUpdatableModules) } type systemServerClasspathFragmentContentDependencyTag struct { From fbaf725ed3e70b3661bcdbd4d7c91d262abf43fd Mon Sep 17 00:00:00 2001 From: "Lukacs T. Berki" Date: Thu, 19 Aug 2021 09:36:42 +0200 Subject: [PATCH 027/148] Rename BuildDir and NinjaBuildDir. These are just out/ and out/soong/ and the old names were quite confusing. Test: Presubmits. Change-Id: I999ca62162062f27e449f83ffb00fa580d4065b8 --- android/bazel_handler.go | 14 +++++----- android/bazel_handler_test.go | 4 +-- android/bazel_paths.go | 2 +- android/config.go | 32 +++++++++++----------- android/fixture.go | 2 +- android/paths.go | 50 +++++++++++++++++------------------ android/singleton.go | 8 +++--- android/test_asserts.go | 4 +-- android/testing.go | 10 +++---- android/writedocs.go | 6 ++--- apex/apex_test.go | 2 +- cmd/soong_build/main.go | 22 +++++++-------- dexpreopt/config.go | 2 +- java/app_test.go | 2 +- java/base.go | 2 +- java/java_test.go | 2 +- rust/project_json_test.go | 2 +- ui/build/soong.go | 16 +++++------ 18 files changed, 91 insertions(+), 91 deletions(-) diff --git a/android/bazel_handler.go b/android/bazel_handler.go index 312f00919..40a5a7378 100644 --- a/android/bazel_handler.go +++ b/android/bazel_handler.go @@ -106,7 +106,7 @@ type bazelPaths struct { bazelPath string outputBase string workspaceDir string - buildDir string + soongOutDir string metricsDir string } @@ -254,7 +254,7 @@ func NewBazelContext(c *config) (BazelContext, error) { func bazelPathsFromConfig(c *config) (*bazelPaths, error) { p := bazelPaths{ - buildDir: c.buildDir, + soongOutDir: c.soongOutDir, } missingEnvVars := []string{} if len(c.Getenv("BAZEL_HOME")) > 1 { @@ -382,7 +382,7 @@ func (r *builtinBazelRunner) issueBazelCommand(paths *bazelPaths, runName bazel. bazelCmd.Env = append(os.Environ(), "HOME="+paths.homeDir, pwdPrefix(), - "BUILD_DIR="+absolutePath(paths.buildDir), + "BUILD_DIR="+absolutePath(paths.soongOutDir), // Make OUT_DIR absolute here so tools/bazel.sh uses the correct // OUT_DIR at /out, instead of /out/soong/workspace/out. "OUT_DIR="+absolutePath(paths.outDir()), @@ -599,24 +599,24 @@ def format(target): // Returns a path containing build-related metadata required for interfacing // with Bazel. Example: out/soong/bazel. func (p *bazelPaths) intermediatesDir() string { - return filepath.Join(p.buildDir, "bazel") + return filepath.Join(p.soongOutDir, "bazel") } // Returns the path where the contents of the @soong_injection repository live. // It is used by Soong to tell Bazel things it cannot over the command line. func (p *bazelPaths) injectedFilesDir() string { - return filepath.Join(p.buildDir, bazel.SoongInjectionDirName) + return filepath.Join(p.soongOutDir, bazel.SoongInjectionDirName) } // Returns the path of the synthetic Bazel workspace that contains a symlink // forest composed the whole source tree and BUILD files generated by bp2build. func (p *bazelPaths) syntheticWorkspaceDir() string { - return filepath.Join(p.buildDir, "workspace") + return filepath.Join(p.soongOutDir, "workspace") } // Returns the path to the top level out dir ($OUT_DIR). func (p *bazelPaths) outDir() string { - return filepath.Dir(p.buildDir) + return filepath.Dir(p.soongOutDir) } // Issues commands to Bazel to receive results for all cquery requests diff --git a/android/bazel_handler_test.go b/android/bazel_handler_test.go index f1fabecad..557faea21 100644 --- a/android/bazel_handler_test.go +++ b/android/bazel_handler_test.go @@ -101,7 +101,7 @@ func TestInvokeBazelPopulatesBuildStatements(t *testing.T) { func testBazelContext(t *testing.T, bazelCommandResults map[bazelCommand]string) (*bazelContext, string) { t.Helper() p := bazelPaths{ - buildDir: t.TempDir(), + soongOutDir: t.TempDir(), outputBase: "outputbase", workspaceDir: "workspace_dir", } @@ -114,5 +114,5 @@ func testBazelContext(t *testing.T, bazelCommandResults map[bazelCommand]string) bazelRunner: runner, paths: &p, requests: map[cqueryKey]bool{}, - }, p.buildDir + }, p.soongOutDir } diff --git a/android/bazel_paths.go b/android/bazel_paths.go index c09d218f4..a4bd2efcf 100644 --- a/android/bazel_paths.go +++ b/android/bazel_paths.go @@ -414,7 +414,7 @@ func PathForBazelOut(ctx PathContext, paths ...string) BazelOutPath { } outputPath := OutputPath{basePath{"", ""}, - ctx.Config().buildDir, + ctx.Config().soongOutDir, ctx.Config().BazelContext.OutputBase()} return BazelOutPath{ diff --git a/android/config.go b/android/config.go index 35403b831..f13697726 100644 --- a/android/config.go +++ b/android/config.go @@ -67,12 +67,12 @@ type Config struct { } // BuildDir returns the build output directory for the configuration. -func (c Config) BuildDir() string { - return c.buildDir +func (c Config) SoongOutDir() string { + return c.soongOutDir } -func (c Config) NinjaBuildDir() string { - return c.buildDir +func (c Config) OutDir() string { + return c.soongOutDir } func (c Config) DebugCompilation() bool { @@ -122,7 +122,7 @@ type config struct { deviceConfig *deviceConfig - buildDir string // the path of the build output directory + soongOutDir string // the path of the build output directory moduleListFile string // the path to the file which lists blueprint files to parse. env map[string]string @@ -283,11 +283,11 @@ func saveToBazelConfigFile(config *productVariables, outDir string) error { // NullConfig returns a mostly empty Config for use by standalone tools like dexpreopt_gen that // use the android package. -func NullConfig(buildDir string) Config { +func NullConfig(soongOutDir string) Config { return Config{ config: &config{ - buildDir: buildDir, - fs: pathtools.OsFs, + soongOutDir: soongOutDir, + fs: pathtools.OsFs, }, } } @@ -319,7 +319,7 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string ShippingApiLevel: stringPtr("30"), }, - buildDir: buildDir, + soongOutDir: buildDir, captureBuild: true, env: envCopy, @@ -397,7 +397,7 @@ func TestArchConfig(buildDir string, env map[string]string, bp string, fs map[st // multiple runs in the same program execution is carried over (such as Bazel // context or environment deps). func ConfigForAdditionalRun(c Config) (Config, error) { - newConfig, err := NewConfig(c.buildDir, c.moduleListFile, c.env) + newConfig, err := NewConfig(c.soongOutDir, c.moduleListFile, c.env) if err != nil { return Config{}, err } @@ -408,14 +408,14 @@ func ConfigForAdditionalRun(c Config) (Config, error) { // NewConfig creates a new Config object. The srcDir argument specifies the path // to the root source directory. It also loads the config file, if found. -func NewConfig(buildDir string, moduleListFile string, availableEnv map[string]string) (Config, error) { +func NewConfig(soongOutDir string, moduleListFile string, availableEnv map[string]string) (Config, error) { // Make a config with default options. config := &config{ - ProductVariablesFileName: filepath.Join(buildDir, productVariablesFileName), + ProductVariablesFileName: filepath.Join(soongOutDir, productVariablesFileName), env: availableEnv, - buildDir: buildDir, + soongOutDir: soongOutDir, multilibConflicts: make(map[ArchType]bool), moduleListFile: moduleListFile, @@ -428,7 +428,7 @@ func NewConfig(buildDir string, moduleListFile string, availableEnv map[string]s // Soundness check of the build and source directories. This won't catch strange // configurations with symlinks, but at least checks the obvious case. - absBuildDir, err := filepath.Abs(buildDir) + absBuildDir, err := filepath.Abs(soongOutDir) if err != nil { return Config{}, err } @@ -448,7 +448,7 @@ func NewConfig(buildDir string, moduleListFile string, availableEnv map[string]s return Config{}, err } - KatiEnabledMarkerFile := filepath.Join(buildDir, ".soong.kati_enabled") + KatiEnabledMarkerFile := filepath.Join(soongOutDir, ".soong.kati_enabled") if _, err := os.Stat(absolutePath(KatiEnabledMarkerFile)); err == nil { config.katiEnabled = true } @@ -556,7 +556,7 @@ var _ bootstrap.ConfigStopBefore = (*config)(nil) // BlueprintToolLocation returns the directory containing build system tools // from Blueprint, like soong_zip and merge_zips. func (c *config) BlueprintToolLocation() string { - return filepath.Join(c.buildDir, "host", c.PrebuiltOS(), "bin") + return filepath.Join(c.soongOutDir, "host", c.PrebuiltOS(), "bin") } var _ bootstrap.ConfigBlueprintToolLocation = (*config)(nil) diff --git a/android/fixture.go b/android/fixture.go index fd051a7a4..728f0318f 100644 --- a/android/fixture.go +++ b/android/fixture.go @@ -834,7 +834,7 @@ func (f *fixture) outputDebugState() { func (r *TestResult) NormalizePathForTesting(path Path) string { pathContext := PathContextForTesting(r.Config) pathAsString := path.String() - if rel, isRel := MaybeRel(pathContext, r.Config.BuildDir(), pathAsString); isRel { + if rel, isRel := MaybeRel(pathContext, r.Config.SoongOutDir(), pathAsString); isRel { return rel } return pathAsString diff --git a/android/paths.go b/android/paths.go index 71caaab83..a733558ba 100644 --- a/android/paths.go +++ b/android/paths.go @@ -186,13 +186,13 @@ type Path interface { // A standard build has the following structure: // ../top/ // out/ - make install files go here. - // out/soong - this is the buildDir passed to NewTestConfig() + // out/soong - this is the soongOutDir passed to NewTestConfig() // ... - the source files // // This function converts a path so that it appears relative to the ../top/ directory, i.e. - // * Make install paths, which have the pattern "buildDir/../" are converted into the top + // * Make install paths, which have the pattern "soongOutDir/../" are converted into the top // relative path "out/" - // * Soong install paths and other writable paths, which have the pattern "buildDir/" are + // * Soong install paths and other writable paths, which have the pattern "soongOutDir/" are // converted into the top relative path "out/soong/". // * Source paths are already relative to the top. // * Phony paths are not relative to anything. @@ -211,7 +211,7 @@ type WritablePath interface { Path // return the path to the build directory. - getBuildDir() string + getSoongOutDir() string // the writablePath method doesn't directly do anything, // but it allows a struct to distinguish between whether or not it implements the WritablePath interface @@ -992,7 +992,7 @@ func safePathForSource(ctx PathContext, pathComponents ...string) (SourcePath, e } // absolute path already checked by validateSafePath - if strings.HasPrefix(ret.String(), ctx.Config().buildDir) { + if strings.HasPrefix(ret.String(), ctx.Config().soongOutDir) { return ret, fmt.Errorf("source path %q is in output", ret.String()) } @@ -1008,7 +1008,7 @@ func pathForSource(ctx PathContext, pathComponents ...string) (SourcePath, error } // absolute path already checked by validatePath - if strings.HasPrefix(ret.String(), ctx.Config().buildDir) { + if strings.HasPrefix(ret.String(), ctx.Config().soongOutDir) { return ret, fmt.Errorf("source path %q is in output", ret.String()) } @@ -1151,7 +1151,7 @@ type OutputPath struct { basePath // The soong build directory, i.e. Config.BuildDir() - buildDir string + soongOutDir string fullPath string } @@ -1167,8 +1167,8 @@ func (p OutputPath) WithoutRel() OutputPath { return p } -func (p OutputPath) getBuildDir() string { - return p.buildDir +func (p OutputPath) getSoongOutDir() string { + return p.soongOutDir } func (p OutputPath) RelativeToTop() Path { @@ -1176,8 +1176,8 @@ func (p OutputPath) RelativeToTop() Path { } func (p OutputPath) outputPathRelativeToTop() OutputPath { - p.fullPath = StringPathRelativeToTop(p.buildDir, p.fullPath) - p.buildDir = OutSoongDir + p.fullPath = StringPathRelativeToTop(p.soongOutDir, p.fullPath) + p.soongOutDir = OutSoongDir return p } @@ -1218,12 +1218,12 @@ func PathForOutput(ctx PathContext, pathComponents ...string) OutputPath { if err != nil { reportPathError(ctx, err) } - fullPath := filepath.Join(ctx.Config().buildDir, path) + fullPath := filepath.Join(ctx.Config().soongOutDir, path) path = fullPath[len(fullPath)-len(path):] - return OutputPath{basePath{path, ""}, ctx.Config().buildDir, fullPath} + return OutputPath{basePath{path, ""}, ctx.Config().soongOutDir, fullPath} } -// PathsForOutput returns Paths rooted from buildDir +// PathsForOutput returns Paths rooted from soongOutDir func PathsForOutput(ctx PathContext, paths []string) WritablePaths { ret := make(WritablePaths, len(paths)) for i, path := range paths { @@ -1545,7 +1545,7 @@ type InstallPath struct { basePath // The soong build directory, i.e. Config.BuildDir() - buildDir string + soongOutDir string // partitionDir is the part of the InstallPath that is automatically determined according to the context. // For example, it is host/- for host modules, and target/product// for device modules. @@ -1565,12 +1565,12 @@ func ensureTestOnly() { func (p InstallPath) RelativeToTop() Path { ensureTestOnly() - p.buildDir = OutSoongDir + p.soongOutDir = OutSoongDir return p } -func (p InstallPath) getBuildDir() string { - return p.buildDir +func (p InstallPath) getSoongOutDir() string { + return p.soongOutDir } func (p InstallPath) ReplaceExtension(ctx PathContext, ext string) OutputPath { @@ -1585,9 +1585,9 @@ func (p InstallPath) writablePath() {} func (p InstallPath) String() string { if p.makePath { // Make path starts with out/ instead of out/soong. - return filepath.Join(p.buildDir, "../", p.path) + return filepath.Join(p.soongOutDir, "../", p.path) } else { - return filepath.Join(p.buildDir, p.path) + return filepath.Join(p.soongOutDir, p.path) } } @@ -1596,9 +1596,9 @@ func (p InstallPath) String() string { // The ./soong is dropped if the install path is for Make. func (p InstallPath) PartitionDir() string { if p.makePath { - return filepath.Join(p.buildDir, "../", p.partitionDir) + return filepath.Join(p.soongOutDir, "../", p.partitionDir) } else { - return filepath.Join(p.buildDir, p.partitionDir) + return filepath.Join(p.soongOutDir, p.partitionDir) } } @@ -1694,7 +1694,7 @@ func pathForInstall(ctx PathContext, os OsType, arch ArchType, partition string, base := InstallPath{ basePath: basePath{partionPath, ""}, - buildDir: ctx.Config().buildDir, + soongOutDir: ctx.Config().soongOutDir, partitionDir: partionPath, makePath: false, } @@ -1705,7 +1705,7 @@ func pathForInstall(ctx PathContext, os OsType, arch ArchType, partition string, func pathForNdkOrSdkInstall(ctx PathContext, prefix string, paths []string) InstallPath { base := InstallPath{ basePath: basePath{prefix, ""}, - buildDir: ctx.Config().buildDir, + soongOutDir: ctx.Config().soongOutDir, partitionDir: prefix, makePath: false, } @@ -1851,7 +1851,7 @@ type PhonyPath struct { func (p PhonyPath) writablePath() {} -func (p PhonyPath) getBuildDir() string { +func (p PhonyPath) getSoongOutDir() string { // A phone path cannot contain any / so cannot be relative to the build directory. return "" } diff --git a/android/singleton.go b/android/singleton.go index bb6614dad..7ff96c9d5 100644 --- a/android/singleton.go +++ b/android/singleton.go @@ -54,10 +54,10 @@ type SingletonContext interface { RequireNinjaVersion(major, minor, micro int) - // SetNinjaBuildDir sets the value of the top-level "builddir" Ninja variable + // SetOutDir sets the value of the top-level "builddir" Ninja variable // that controls where Ninja stores its build log files. This value can be // set at most one time for a single build, later calls are ignored. - SetNinjaBuildDir(pctx PackageContext, value string) + SetOutDir(pctx PackageContext, value string) // Eval takes a string with embedded ninja variables, and returns a string // with all of the variables recursively expanded. Any variables references @@ -180,8 +180,8 @@ func (s *singletonContextAdaptor) Phony(name string, deps ...Path) { addPhony(s.Config(), name, deps...) } -func (s *singletonContextAdaptor) SetNinjaBuildDir(pctx PackageContext, value string) { - s.SingletonContext.SetNinjaBuildDir(pctx.PackageContext, value) +func (s *singletonContextAdaptor) SetOutDir(pctx PackageContext, value string) { + s.SingletonContext.SetOutDir(pctx.PackageContext, value) } func (s *singletonContextAdaptor) Eval(pctx PackageContext, ninjaStr string) (string, error) { diff --git a/android/test_asserts.go b/android/test_asserts.go index edeb40889..064f6562b 100644 --- a/android/test_asserts.go +++ b/android/test_asserts.go @@ -77,14 +77,14 @@ func AssertPathsRelativeToTopEquals(t *testing.T, message string, expected []str // StringPathRelativeToTop on the actual string path. func AssertStringPathRelativeToTopEquals(t *testing.T, message string, config Config, expected string, actual string) { t.Helper() - AssertStringEquals(t, message, expected, StringPathRelativeToTop(config.buildDir, actual)) + AssertStringEquals(t, message, expected, StringPathRelativeToTop(config.soongOutDir, actual)) } // AssertStringPathsRelativeToTopEquals checks if the expected value is equal to the result of // calling StringPathsRelativeToTop on the actual string paths. func AssertStringPathsRelativeToTopEquals(t *testing.T, message string, config Config, expected []string, actual []string) { t.Helper() - AssertDeepEquals(t, message, expected, StringPathsRelativeToTop(config.buildDir, actual)) + AssertDeepEquals(t, message, expected, StringPathsRelativeToTop(config.soongOutDir, actual)) } // AssertErrorMessageEquals checks if the error is not nil and has the expected message. If it does diff --git a/android/testing.go b/android/testing.go index 6ba8e3cde..e25e5c5f5 100644 --- a/android/testing.go +++ b/android/testing.go @@ -664,15 +664,15 @@ func newBaseTestingComponent(config Config, provider testBuildProvider) baseTest // containing at most one instance of the temporary build directory at the start of the path while // this assumes that there can be any number at any position. func normalizeStringRelativeToTop(config Config, s string) string { - // The buildDir usually looks something like: /tmp/testFoo2345/001 + // The soongOutDir usually looks something like: /tmp/testFoo2345/001 // - // Replace any usage of the buildDir with out/soong, e.g. replace "/tmp/testFoo2345/001" with + // Replace any usage of the soongOutDir with out/soong, e.g. replace "/tmp/testFoo2345/001" with // "out/soong". - outSoongDir := filepath.Clean(config.buildDir) + outSoongDir := filepath.Clean(config.soongOutDir) re := regexp.MustCompile(`\Q` + outSoongDir + `\E\b`) s = re.ReplaceAllString(s, "out/soong") - // Replace any usage of the buildDir/.. with out, e.g. replace "/tmp/testFoo2345" with + // Replace any usage of the soongOutDir/.. with out, e.g. replace "/tmp/testFoo2345" with // "out". This must come after the previous replacement otherwise this would replace // "/tmp/testFoo2345/001" with "out/001" instead of "out/soong". outDir := filepath.Dir(outSoongDir) @@ -991,7 +991,7 @@ func NormalizePathForTesting(path Path) string { } p := path.String() if w, ok := path.(WritablePath); ok { - rel, err := filepath.Rel(w.getBuildDir(), p) + rel, err := filepath.Rel(w.getSoongOutDir(), p) if err != nil { panic(err) } diff --git a/android/writedocs.go b/android/writedocs.go index 67b9aa3ad..c380a3d84 100644 --- a/android/writedocs.go +++ b/android/writedocs.go @@ -34,12 +34,12 @@ func DocsSingleton() Singleton { type docsSingleton struct{} func primaryBuilderPath(ctx SingletonContext) Path { - buildDir := absolutePath(ctx.Config().BuildDir()) + soongOutDir := absolutePath(ctx.Config().SoongOutDir()) binary := absolutePath(os.Args[0]) - primaryBuilder, err := filepath.Rel(buildDir, binary) + primaryBuilder, err := filepath.Rel(soongOutDir, binary) if err != nil { ctx.Errorf("path to primary builder %q is not in build dir %q (%q)", - os.Args[0], ctx.Config().BuildDir(), err) + os.Args[0], ctx.Config().SoongOutDir(), err) } return PathForOutput(ctx, primaryBuilder) diff --git a/apex/apex_test.go b/apex/apex_test.go index 06b5b12a0..b9c7c86a2 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -4741,7 +4741,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { } } if !foundLibfooJar { - t.Errorf("Rule for libfoo.jar missing in dex_bootjars singleton outputs %q", android.StringPathsRelativeToTop(ctx.Config().BuildDir(), s.AllOutputs())) + t.Errorf("Rule for libfoo.jar missing in dex_bootjars singleton outputs %q", android.StringPathsRelativeToTop(ctx.Config().SoongOutDir(), s.AllOutputs())) } } diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index 8aea037d9..cff65f92e 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -146,7 +146,7 @@ func runMixedModeBuild(configuration android.Config, firstCtx *android.Context, ninjaDeps := bootstrap.RunBlueprint(secondArgs, secondCtx.Context, secondConfig) ninjaDeps = append(ninjaDeps, extraNinjaDeps...) - globListFiles := writeBuildGlobsNinjaFile(secondCtx.SrcDir(), configuration.BuildDir(), secondCtx.Globs, configuration) + globListFiles := writeBuildGlobsNinjaFile(secondCtx.SrcDir(), configuration.SoongOutDir(), secondCtx.Globs, configuration) ninjaDeps = append(ninjaDeps, globListFiles...) err = deptools.WriteDepFile(shared.JoinPath(topDir, secondArgs.DepFile), secondArgs.OutFile, ninjaDeps) @@ -177,7 +177,7 @@ func runSoongDocs(configuration android.Config) { } func writeMetrics(configuration android.Config) { - metricsFile := filepath.Join(configuration.BuildDir(), "soong_build_metrics.pb") + metricsFile := filepath.Join(configuration.SoongOutDir(), "soong_build_metrics.pb") err := android.WriteMetrics(configuration, metricsFile) if err != nil { fmt.Fprintf(os.Stderr, "error writing soong_build metrics %s: %s", metricsFile, err) @@ -194,7 +194,7 @@ func writeJsonModuleGraph(configuration android.Config, ctx *android.Context, pa defer f.Close() ctx.Context.PrintJSONGraph(f) - writeFakeNinjaFile(extraNinjaDeps, configuration.BuildDir()) + writeFakeNinjaFile(extraNinjaDeps, configuration.SoongOutDir()) } func writeBuildGlobsNinjaFile(srcDir, buildDir string, globs func() pathtools.MultipleGlobResults, config interface{}) []string { @@ -233,7 +233,7 @@ func doChosenActivity(configuration android.Config, extraNinjaDeps []string) str ninjaDeps := bootstrap.RunBlueprint(blueprintArgs, ctx.Context, configuration) ninjaDeps = append(ninjaDeps, extraNinjaDeps...) - globListFiles := writeBuildGlobsNinjaFile(ctx.SrcDir(), configuration.BuildDir(), ctx.Globs, configuration) + globListFiles := writeBuildGlobsNinjaFile(ctx.SrcDir(), configuration.SoongOutDir(), ctx.Globs, configuration) ninjaDeps = append(ninjaDeps, globListFiles...) err := deptools.WriteDepFile(shared.JoinPath(topDir, blueprintArgs.DepFile), blueprintArgs.OutFile, ninjaDeps) @@ -307,7 +307,7 @@ func main() { if shared.IsDebugging() { // Add a non-existent file to the dependencies so that soong_build will rerun when the debugger is // enabled even if it completed successfully. - extraNinjaDeps = append(extraNinjaDeps, filepath.Join(configuration.BuildDir(), "always_rerun_for_delve")) + extraNinjaDeps = append(extraNinjaDeps, filepath.Join(configuration.SoongOutDir(), "always_rerun_for_delve")) } if docFile != "" { @@ -356,12 +356,12 @@ func writeUsedEnvironmentFile(configuration android.Config, finalOutputFile stri // These files are: build.ninja and build.ninja.d. Since Kati hasn't been // ran as well, and `nothing` is defined in a .mk file, there isn't a ninja // target called `nothing`, so we manually create it here. -func writeFakeNinjaFile(extraNinjaDeps []string, buildDir string) { +func writeFakeNinjaFile(extraNinjaDeps []string, soongOutDir string) { extraNinjaDepsString := strings.Join(extraNinjaDeps, " \\\n ") ninjaFileName := "build.ninja" - ninjaFile := shared.JoinPath(topDir, buildDir, ninjaFileName) - ninjaFileD := shared.JoinPath(topDir, buildDir, ninjaFileName+".d") + ninjaFile := shared.JoinPath(topDir, soongOutDir, ninjaFileName) + ninjaFileD := shared.JoinPath(topDir, soongOutDir, ninjaFileName+".d") // A workaround to create the 'nothing' ninja target so `m nothing` works, // since bp2build runs without Kati, and the 'nothing' target is declared in // a Makefile. @@ -505,7 +505,7 @@ func runBp2Build(configuration android.Config, extraNinjaDeps []string) { ninjaDeps := bootstrap.RunBlueprint(blueprintArgs, bp2buildCtx.Context, configuration) ninjaDeps = append(ninjaDeps, extraNinjaDeps...) - globListFiles := writeBuildGlobsNinjaFile(bp2buildCtx.SrcDir(), configuration.BuildDir(), bp2buildCtx.Globs, configuration) + globListFiles := writeBuildGlobsNinjaFile(bp2buildCtx.SrcDir(), configuration.SoongOutDir(), bp2buildCtx.Globs, configuration) ninjaDeps = append(ninjaDeps, globListFiles...) // Run the code-generation phase to convert BazelTargetModules to BUILD files @@ -513,8 +513,8 @@ func runBp2Build(configuration android.Config, extraNinjaDeps []string) { codegenContext := bp2build.NewCodegenContext(configuration, *bp2buildCtx, bp2build.Bp2Build) metrics := bp2build.Codegen(codegenContext) - generatedRoot := shared.JoinPath(configuration.BuildDir(), "bp2build") - workspaceRoot := shared.JoinPath(configuration.BuildDir(), "workspace") + generatedRoot := shared.JoinPath(configuration.SoongOutDir(), "bp2build") + workspaceRoot := shared.JoinPath(configuration.SoongOutDir(), "workspace") excludes := []string{ "bazel-bin", diff --git a/dexpreopt/config.go b/dexpreopt/config.go index 7a74506b7..de3666a33 100644 --- a/dexpreopt/config.go +++ b/dexpreopt/config.go @@ -159,7 +159,7 @@ func init() { } func constructPath(ctx android.PathContext, path string) android.Path { - buildDirPrefix := ctx.Config().BuildDir() + "/" + buildDirPrefix := ctx.Config().SoongOutDir() + "/" if path == "" { return nil } else if strings.HasPrefix(path, buildDirPrefix) { diff --git a/java/app_test.go b/java/app_test.go index c14c65d18..f4fdfa756 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -1737,7 +1737,7 @@ func TestPackageNameOverride(t *testing.T) { foo := result.ModuleForTests("foo", "android_common") - outSoongDir := result.Config.BuildDir() + outSoongDir := result.Config.SoongOutDir() outputs := foo.AllOutputs() outputMap := make(map[string]bool) diff --git a/java/base.go b/java/base.go index ea5b13721..416d82a67 100644 --- a/java/base.go +++ b/java/base.go @@ -793,7 +793,7 @@ func (j *Module) collectJavacFlags( // Manually specify build directory in case it is not under the repo root. // (javac doesn't seem to expand into symbolic links when searching for patch-module targets, so // just adding a symlink under the root doesn't help.) - patchPaths := []string{".", ctx.Config().BuildDir()} + patchPaths := []string{".", ctx.Config().SoongOutDir()} // b/150878007 // diff --git a/java/java_test.go b/java/java_test.go index b6780c20c..8bb017f0b 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -1183,7 +1183,7 @@ func checkPatchModuleFlag(t *testing.T, ctx *android.TestContext, moduleName str break } } - if expected != android.StringPathRelativeToTop(ctx.Config().BuildDir(), got) { + if expected != android.StringPathRelativeToTop(ctx.Config().SoongOutDir(), got) { t.Errorf("Unexpected patch-module flag for module %q - expected %q, but got %q", moduleName, expected, got) } } diff --git a/rust/project_json_test.go b/rust/project_json_test.go index bdd54c59b..f7b668122 100644 --- a/rust/project_json_test.go +++ b/rust/project_json_test.go @@ -36,7 +36,7 @@ func testProjectJson(t *testing.T, bp string) []byte { // The JSON file is generated via WriteFileToOutputDir. Therefore, it // won't appear in the Output of the TestingSingleton. Manually verify // it exists. - content, err := ioutil.ReadFile(filepath.Join(result.Config.BuildDir(), rustProjectJsonFileName)) + content, err := ioutil.ReadFile(filepath.Join(result.Config.SoongOutDir(), rustProjectJsonFileName)) if err != nil { t.Errorf("rust-project.json has not been generated") } diff --git a/ui/build/soong.go b/ui/build/soong.go index 8ef8c745a..06210b9f8 100644 --- a/ui/build/soong.go +++ b/ui/build/soong.go @@ -71,17 +71,17 @@ func writeEnvironmentFile(ctx Context, envFile string, envDeps map[string]string // A tiny struct used to tell Blueprint that it's in bootstrap mode. It would // probably be nicer to use a flag in bootstrap.Args instead. type BlueprintConfig struct { - buildDir string - ninjaBuildDir string + soongOutDir string + outDir string debugCompilation bool } -func (c BlueprintConfig) BuildDir() string { - return c.buildDir +func (c BlueprintConfig) SoongOutDir() string { + return c.soongOutDir } -func (c BlueprintConfig) NinjaBuildDir() string { - return c.ninjaBuildDir +func (c BlueprintConfig) OutDir() string { + return c.outDir } func (c BlueprintConfig) DebugCompilation() bool { @@ -189,8 +189,8 @@ func bootstrapBlueprint(ctx Context, config Config) { blueprintCtx := blueprint.NewContext() blueprintCtx.SetIgnoreUnknownModuleTypes(true) blueprintConfig := BlueprintConfig{ - buildDir: config.SoongOutDir(), - ninjaBuildDir: config.OutDir(), + soongOutDir: config.SoongOutDir(), + outDir: config.OutDir(), debugCompilation: os.Getenv("SOONG_DELVE") != "", } From 6254db8b42faf1aa338320e74027ef4ad4f626c2 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Fri, 27 Aug 2021 17:35:40 +0100 Subject: [PATCH 028/148] Add support for extension version in variables This makes the sdk extension version usable in genrule cmds via %d. Bug: 195281582 Test: current_sdkinfo module in packages/modules/common. Change-Id: I82a90b83d23b0ba3779a943c2ad444bf5cf937da Merged-In: I82a90b83d23b0ba3779a943c2ad444bf5cf937da (cherry picked from commit e720c41f67a7e9309f1e6e48d5975383be7b2d28) --- android/variable.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/android/variable.go b/android/variable.go index fa2e83e77..784b535e9 100644 --- a/android/variable.go +++ b/android/variable.go @@ -42,6 +42,10 @@ type variableProperties struct { Cflags []string } + Platform_sdk_extension_version struct { + Cmd *string + } + // unbundled_build is a catch-all property to annotate modules that don't build in one or // more unbundled branches, usually due to dependencies missing from the manifest. Unbundled_build struct { @@ -163,6 +167,7 @@ type productVariables struct { Platform_sdk_version *int `json:",omitempty"` Platform_sdk_codename *string `json:",omitempty"` Platform_sdk_final *bool `json:",omitempty"` + Platform_sdk_extension_version *int `json:",omitempty"` Platform_version_active_codenames []string `json:",omitempty"` Platform_vndk_version *string `json:",omitempty"` Platform_systemsdk_versions []string `json:",omitempty"` From 8151d23f8359f5b7a5162fb855bcd368f8d5064e Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Tue, 31 Aug 2021 20:00:52 +0000 Subject: [PATCH 029/148] Add support for --optional-uses-libs to pom2bp Fixes: 198303986 Test: ./update_prebuilts.py -x Change-Id: I4eb322e905f636eb18d1940f05682f38e448a344 --- cmd/pom2bp/pom2bp.go | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/cmd/pom2bp/pom2bp.go b/cmd/pom2bp/pom2bp.go index d31489e3a..fe567a976 100644 --- a/cmd/pom2bp/pom2bp.go +++ b/cmd/pom2bp/pom2bp.go @@ -93,6 +93,8 @@ var extraStaticLibs = make(ExtraDeps) var extraLibs = make(ExtraDeps) +var optionalUsesLibs = make(ExtraDeps) + type Exclude map[string]bool func (e Exclude) String() string { @@ -269,6 +271,10 @@ func (p Pom) BpExtraLibs() []string { return extraLibs[p.BpName()] } +func (p Pom) BpOptionalUsesLibs() []string { + return optionalUsesLibs[p.BpName()] +} + // BpDeps obtains dependencies filtered by type and scope. The results of this // method are formatted as Android.bp targets, e.g. run through MavenToBp rules. func (p Pom) BpDeps(typeExt string, scopes []string) []string { @@ -401,6 +407,13 @@ var bpTemplate = template.Must(template.New("bp").Parse(` {{- end}} ], {{- end}} + {{- if .BpOptionalUsesLibs}} + optional_uses_libs: [ + {{- range .BpOptionalUsesLibs}} + "{{.}}", + {{- end}} + ], + {{- end}} {{- else if not .IsHostOnly}} min_sdk_version: "{{.DefaultMinSdkVersion}}", {{- end}} @@ -488,6 +501,13 @@ var bpDepsTemplate = template.Must(template.New("bp").Parse(` {{- end}} ], {{- end}} + {{- if .BpOptionalUsesLibs}} + optional_uses_libs: [ + {{- range .BpOptionalUsesLibs}} + "{{.}}", + {{- end}} + ], + {{- end}} java_version: "1.7", } `)) @@ -587,7 +607,7 @@ func main() { The tool will extract the necessary information from *.pom files to create an Android.bp whose aar libraries can be linked against when using AAPT2. -Usage: %s [--rewrite =] [-exclude ] [--extra-static-libs =[,]] [--extra-libs =[,]] [] [-regen ] +Usage: %s [--rewrite =] [--exclude ] [--extra-static-libs =[,]] [--extra-libs =[,]] [--optional-uses-libs =[,]] [] [-regen ] -rewrite = rewrite can be used to specify mappings between Maven projects and Android.bp modules. The -rewrite @@ -605,6 +625,11 @@ Usage: %s [--rewrite =] [-exclude ] [--extra-static-libs Some Android.bp modules have transitive runtime dependencies that must be specified when they are depended upon (like androidx.test.rules requires android.test.base). This may be specified multiple times to declare these dependencies. + -optional-uses-libs =[,] + Some Android.bp modules have optional dependencies (typically specified with in + the module's AndroidManifest.xml) that must be specified when they are depended upon (like + androidx.window:window optionally requires androidx.window:window-extensions). + This may be specified multiple times to declare these dependencies. -sdk-version Sets sdk_version: "" for all modules. -default-min-sdk-version @@ -629,6 +654,7 @@ Usage: %s [--rewrite =] [-exclude ] [--extra-static-libs flag.Var(&excludes, "exclude", "Exclude module") flag.Var(&extraStaticLibs, "extra-static-libs", "Extra static dependencies needed when depending on a module") flag.Var(&extraLibs, "extra-libs", "Extra runtime dependencies needed when depending on a module") + flag.Var(&optionalUsesLibs, "optional-uses-libs", "Extra optional dependencies needed when depending on a module") flag.Var(&rewriteNames, "rewrite", "Regex(es) to rewrite artifact names") flag.Var(&hostModuleNames, "host", "Specifies that the corresponding module (specified in the form 'module.group:module.artifact') is a host module") flag.Var(&hostAndDeviceModuleNames, "host-and-device", "Specifies that the corresponding module (specified in the form 'module.group:module.artifact') is both a host and device module.") From c10d5da3d40ce56f1c79ec1005cd54479f41f716 Mon Sep 17 00:00:00 2001 From: Sarah Chin Date: Wed, 16 Jun 2021 15:58:04 -0700 Subject: [PATCH 030/148] Add Radio AIDL to VNDK variant list Test: build Bug: 198331182 Change-Id: I922961b8311d024ebbf3f3339dfdb41c72ee9dd9 --- cc/config/vndk.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cc/config/vndk.go b/cc/config/vndk.go index 555252462..1d695dbf9 100644 --- a/cc/config/vndk.go +++ b/cc/config/vndk.go @@ -61,6 +61,8 @@ var VndkMustUseVendorVariantList = []string{ "android.hardware.rebootescrow-V1-ndk", "android.hardware.rebootescrow-V1-ndk_platform", "android.hardware.rebootescrow-ndk_platform", + "android.hardware.radio-V1-ndk", + "android.hardware.radio-V1-ndk_platform", "android.hardware.security.keymint-V1-ndk", "android.hardware.security.keymint-V1-ndk_platform", "android.hardware.security.keymint-ndk_platform", From 826863c8e0844b2172fde38ccdcc0d83aa2ae7e5 Mon Sep 17 00:00:00 2001 From: Pedro Loureiro Date: Tue, 7 Sep 2021 17:21:59 +0000 Subject: [PATCH 031/148] Add support for new permissions library tag attributes We are expanding PackageManager's supported attributes and this change enables the developer to define them in the .bp file. Test: m nothing Bug: 191978330 Change-Id: I01d579190fb585662086a7fc456f3b33cb89fb57 --- apex/apex_test.go | 2 +- java/sdk_library.go | 188 +++++++++++++++++++++++++++++++++------ java/sdk_library_test.go | 71 ++++++++++++++- 3 files changed, 233 insertions(+), 28 deletions(-) diff --git a/apex/apex_test.go b/apex/apex_test.go index 9d6753ef9..8cd05841a 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -6180,7 +6180,7 @@ func TestJavaSDKLibrary(t *testing.T) { }) // Permission XML should point to the activated path of impl jar of java_sdk_library sdkLibrary := ctx.ModuleForTests("foo.xml", "android_common_myapex").Rule("java_sdk_xml") - ensureContains(t, sdkLibrary.RuleParams.Command, `\n` + - `\n` + - `\n` + - ` \n` + - `\n` + sdkXmlFileSuffix = ".xml" ) // A tag to associated a dependency with a specific api scope. @@ -629,6 +612,33 @@ type commonToSdkLibraryAndImportProperties struct { // Files containing information about supported java doc tags. Doctag_files []string `android:"path"` + + // Signals that this shared library is part of the bootclasspath starting + // on the version indicated in this attribute. + // + // This will make platforms at this level and above to ignore + // tags with this library name because the library is already + // available + On_bootclasspath_since *string + + // Signals that this shared library was part of the bootclasspath before + // (but not including) the version indicated in this attribute. + // + // The system will automatically add a tag with this library to + // apps that target any SDK less than the version indicated in this attribute. + On_bootclasspath_before *string + + // Indicates that PackageManager should ignore this shared library if the + // platform is below the version indicated in this attribute. + // + // This means that the device won't recognise this library as installed. + Min_device_sdk *string + + // Indicates that PackageManager should ignore this shared library if the + // platform is above the version indicated in this attribute. + // + // This means that the device won't recognise this library as installed. + Max_device_sdk *string } // commonSdkLibraryAndImportModule defines the interface that must be provided by a module that @@ -1567,13 +1577,21 @@ func (module *SdkLibrary) UniqueApexVariations() bool { // Creates the xml file that publicizes the runtime library func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) { props := struct { - Name *string - Lib_name *string - Apex_available []string + Name *string + Lib_name *string + Apex_available []string + On_bootclasspath_since *string + On_bootclasspath_before *string + Min_device_sdk *string + Max_device_sdk *string }{ - Name: proptools.StringPtr(module.xmlPermissionsModuleName()), - Lib_name: proptools.StringPtr(module.BaseModuleName()), - Apex_available: module.ApexProperties.Apex_available, + Name: proptools.StringPtr(module.xmlPermissionsModuleName()), + Lib_name: proptools.StringPtr(module.BaseModuleName()), + Apex_available: module.ApexProperties.Apex_available, + On_bootclasspath_since: module.commonSdkLibraryProperties.On_bootclasspath_since, + On_bootclasspath_before: module.commonSdkLibraryProperties.On_bootclasspath_before, + Min_device_sdk: module.commonSdkLibraryProperties.Min_device_sdk, + Max_device_sdk: module.commonSdkLibraryProperties.Max_device_sdk, } mctx.CreateModule(sdkLibraryXmlFactory, &props) @@ -2354,6 +2372,33 @@ type sdkLibraryXml struct { type sdkLibraryXmlProperties struct { // canonical name of the lib Lib_name *string + + // Signals that this shared library is part of the bootclasspath starting + // on the version indicated in this attribute. + // + // This will make platforms at this level and above to ignore + // tags with this library name because the library is already + // available + On_bootclasspath_since *string + + // Signals that this shared library was part of the bootclasspath before + // (but not including) the version indicated in this attribute. + // + // The system will automatically add a tag with this library to + // apps that target any SDK less than the version indicated in this attribute. + On_bootclasspath_before *string + + // Indicates that PackageManager should ignore this shared library if the + // platform is below the version indicated in this attribute. + // + // This means that the device won't recognise this library as installed. + Min_device_sdk *string + + // Indicates that PackageManager should ignore this shared library if the + // platform is above the version indicated in this attribute. + // + // This means that the device won't recognise this library as installed. + Max_device_sdk *string } // java_sdk_library_xml builds the permission xml file for a java_sdk_library. @@ -2430,11 +2475,71 @@ func (module *sdkLibraryXml) implPath(ctx android.ModuleContext) string { return "/" + partition + "/framework/" + implName + ".jar" } +func formattedOptionalSdkLevelAttribute(ctx android.ModuleContext, attrName string, value *string) string { + if value == nil { + return "" + } + apiLevel, err := android.ApiLevelFromUser(ctx, *value) + if err != nil { + ctx.PropertyErrorf(attrName, err.Error()) + return "" + } + intStr := strconv.Itoa(apiLevel.FinalOrPreviewInt()) + return formattedOptionalAttribute(attrName, &intStr) +} + +// formats an attribute for the xml permissions file if the value is not null +// returns empty string otherwise +func formattedOptionalAttribute(attrName string, value *string) string { + if value == nil { + return "" + } + return fmt.Sprintf(` %s=\"%s\"\n`, attrName, *value) +} + +func (module *sdkLibraryXml) permissionsContents(ctx android.ModuleContext) string { + libName := proptools.String(module.properties.Lib_name) + libNameAttr := formattedOptionalAttribute("name", &libName) + filePath := module.implPath(ctx) + filePathAttr := formattedOptionalAttribute("file", &filePath) + implicitFromAttr := formattedOptionalSdkLevelAttribute(ctx, "on_bootclasspath_since", module.properties.On_bootclasspath_since) + implicitUntilAttr := formattedOptionalSdkLevelAttribute(ctx, "on_bootclasspath_before", module.properties.On_bootclasspath_before) + minSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "min_device_sdk", module.properties.Min_device_sdk) + maxSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "max_device_sdk", module.properties.Max_device_sdk) + + return strings.Join([]string{ + `\n`, + `\n`, + `\n`, + ` \n`, + `\n`}, "") +} + func (module *sdkLibraryXml) GenerateAndroidBuildActions(ctx android.ModuleContext) { module.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() libName := proptools.String(module.properties.Lib_name) - xmlContent := fmt.Sprintf(permissionsTemplate, libName, module.implPath(ctx)) + xmlContent := module.permissionsContents(ctx) module.outputFilePath = android.PathForModuleOut(ctx, libName+".xml").OutputPath rule := android.NewRuleBuilder(pctx, ctx) @@ -2518,6 +2623,33 @@ type sdkLibrarySdkMemberProperties struct { Doctag_paths android.Paths Permitted_packages []string + + // Signals that this shared library is part of the bootclasspath starting + // on the version indicated in this attribute. + // + // This will make platforms at this level and above to ignore + // tags with this library name because the library is already + // available + On_bootclasspath_since *string + + // Signals that this shared library was part of the bootclasspath before + // (but not including) the version indicated in this attribute. + // + // The system will automatically add a tag with this library to + // apps that target any SDK less than the version indicated in this attribute. + On_bootclasspath_before *string + + // Indicates that PackageManager should ignore this shared library if the + // platform is below the version indicated in this attribute. + // + // This means that the device won't recognise this library as installed. + Min_device_sdk *string + + // Indicates that PackageManager should ignore this shared library if the + // platform is above the version indicated in this attribute. + // + // This means that the device won't recognise this library as installed. + Max_device_sdk *string } type scopeProperties struct { @@ -2559,6 +2691,10 @@ func (s *sdkLibrarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMembe s.Compile_dex = sdk.dexProperties.Compile_dex s.Doctag_paths = sdk.doctagPaths s.Permitted_packages = sdk.PermittedPackagesForUpdatableBootJars() + s.On_bootclasspath_since = sdk.commonSdkLibraryProperties.On_bootclasspath_since + s.On_bootclasspath_before = sdk.commonSdkLibraryProperties.On_bootclasspath_before + s.Min_device_sdk = sdk.commonSdkLibraryProperties.Min_device_sdk + s.Max_device_sdk = sdk.commonSdkLibraryProperties.Max_device_sdk } func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) { diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 938bb2895..bcd837c04 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -107,7 +107,7 @@ func TestJavaSdkLibrary(t *testing.T) { libs: ["foo"], sdk_version: "module_30", } - `) + `) // check the existence of the internal modules foo := result.ModuleForTests("foo", "android_common") @@ -162,6 +162,75 @@ func TestJavaSdkLibrary(t *testing.T) { } } +func TestJavaSdkLibrary_UpdatableLibrary(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForJavaTest, + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithPrebuiltApis(map[string][]string{ + "28": {"foo"}, + "29": {"foo"}, + "30": {"foo", "fooUpdatable", "fooUpdatableErr"}, + }), + ).RunTestWithBp(t, + ` + java_sdk_library { + name: "fooUpdatable", + srcs: ["a.java", "b.java"], + api_packages: ["foo"], + on_bootclasspath_since: "29", + on_bootclasspath_before: "30", + min_device_sdk: "R", + max_device_sdk: "current", + } + java_sdk_library { + name: "foo", + srcs: ["a.java", "b.java"], + api_packages: ["foo"], + } +`) + // test that updatability attributes are passed on correctly + fooUpdatable := result.ModuleForTests("fooUpdatable.xml", "android_common").Rule("java_sdk_xml") + android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on_bootclasspath_since=\"29\"`) + android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on_bootclasspath_before=\"30\"`) + android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `min_device_sdk=\"30\"`) + android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `max_device_sdk=\"10000\"`) + + // double check that updatability attributes are not written if they don't exist in the bp file + // the permissions file for the foo library defined above + fooPermissions := result.ModuleForTests("foo.xml", "android_common").Rule("java_sdk_xml") + android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `on_bootclasspath_since`) + android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `on_bootclasspath_before`) + android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `min_device_sdk`) + android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `max_device_sdk`) +} + +func TestJavaSdkLibrary_UpdatableLibrary_Validation(t *testing.T) { + android.GroupFixturePreparers( + prepareForJavaTest, + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithPrebuiltApis(map[string][]string{ + "30": {"fooUpdatable", "fooUpdatableErr"}, + }), + ).ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern( + []string{ + `on_bootclasspath_since: "aaa" could not be parsed as an integer and is not a recognized codename`, + `on_bootclasspath_before: "bbc" could not be parsed as an integer and is not a recognized codename`, + `min_device_sdk: "ccc" could not be parsed as an integer and is not a recognized codename`, + `max_device_sdk: "ddd" could not be parsed as an integer and is not a recognized codename`, + })).RunTestWithBp(t, + ` + java_sdk_library { + name: "fooUpdatableErr", + srcs: ["a.java", "b.java"], + api_packages: ["foo"], + on_bootclasspath_since: "aaa", + on_bootclasspath_before: "bbc", + min_device_sdk: "ccc", + max_device_sdk: "ddd", + } +`) +} + func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) { result := android.GroupFixturePreparers( prepareForJavaTest, From b727c1e0ba9dfc7e2784d942b9a1ad07e0ee3208 Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Thu, 16 Sep 2021 14:24:13 +0100 Subject: [PATCH 032/148] Add back the api_srcs argument This arg provides the ability to pass sources to the metalava invocations that are part of a java_sdk_library without affecting the runtime library. This is useful in various scenarios, e.g.: when javadoc in some source files affects the metalava behavior. For example, the javadoc-generation javadoc tags @paramDoc, @returnDoc etc. Passing these as a library does not work because class files do not contain javadoc. Bug: 186197911 Test: manually inspect module stub src for doc enhancements Change-Id: I2ce98f891283514e1896c52d9335550c1f5435fb --- java/sdk_library.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/java/sdk_library.go b/java/sdk_library.go index 8c664383d..12353c90e 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -376,6 +376,9 @@ type ApiScopeProperties struct { } type sdkLibraryProperties struct { + // List of source files that are needed to compile the API, but are not part of runtime library. + Api_srcs []string `android:"arch_variant"` + // Visibility for impl library module. If not specified then defaults to the // visibility property. Impl_library_visibility []string @@ -1442,6 +1445,7 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC props.Name = proptools.StringPtr(name) props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_source_visibility) props.Srcs = append(props.Srcs, module.properties.Srcs...) + props.Srcs = append(props.Srcs, module.sdkLibraryProperties.Api_srcs...) props.Sdk_version = module.deviceProperties.Sdk_version props.System_modules = module.deviceProperties.System_modules props.Installable = proptools.BoolPtr(false) From 48e0e339161da454e8605cafa1ecc97d450915b1 Mon Sep 17 00:00:00 2001 From: Serik Beketayev Date: Wed, 15 Sep 2021 17:16:46 -0700 Subject: [PATCH 033/148] [IRadioConfig] Add to VNDK variant list Test: build Bug: 198331805 Change-Id: Ibacc996f42c4bfa12b135247a2cebe1e28bbff09 --- cc/config/vndk.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cc/config/vndk.go b/cc/config/vndk.go index 231d60160..9e0ff00c3 100644 --- a/cc/config/vndk.go +++ b/cc/config/vndk.go @@ -63,6 +63,8 @@ var VndkMustUseVendorVariantList = []string{ "android.hardware.rebootescrow-ndk_platform", "android.hardware.radio-V1-ndk", "android.hardware.radio-V1-ndk_platform", + "android.hardware.radio.config-V1-ndk", + "android.hardware.radio.config-V1-ndk_platform", "android.hardware.security.keymint-V1-ndk", "android.hardware.security.keymint-V1-ndk_platform", "android.hardware.security.keymint-ndk_platform", From 85a8afa9e72feff6d804c5d0a0827db63cb55fb9 Mon Sep 17 00:00:00 2001 From: Jay Aliomer Date: Thu, 23 Sep 2021 15:49:54 -0400 Subject: [PATCH 034/148] Added src and exclude_src to debuggable builds Fixes: 200976245 Test: manually tested Change-Id: I68b6230f30aa2c15e6a80010cd639ea453b4b29e --- android/variable.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android/variable.go b/android/variable.go index aef1bba0e..02ada4c6e 100644 --- a/android/variable.go +++ b/android/variable.go @@ -114,6 +114,9 @@ type variableProperties struct { Shared_libs []string Cmdline []string + + Srcs []string + Exclude_srcs []string } // eng is true for -eng builds, and can be used to turn on additionaly heavyweight debugging From f9e584dd20068334f7ab44c8a989fc1b177e3886 Mon Sep 17 00:00:00 2001 From: Pedro Loureiro Date: Tue, 28 Sep 2021 15:40:23 +0000 Subject: [PATCH 035/148] Perform validation of shared library attributes Perform consistency checks as per http://go/updatable-shared-libraries These include: * no attribute can specified can be less than T * max-device-sdk can't be less than min-device-sdk * min and max-device-sdk need to be at least the module's min_sdk_version * using on-bootclasspath-before implies that the module's min_sdk_version is at least T or the library has min-device-sdk of at least T Test: m nothing Bug: 191978330 Change-Id: Iaca5cf23fb0bc7e65effb3529c8e829560894c2e --- android/config.go | 2 +- apex/apex_test.go | 4 +- java/sdk_library.go | 126 ++++++++++++++++++++++++++++++----- java/sdk_library_test.go | 137 +++++++++++++++++++++++++++++++++++---- 4 files changed, 239 insertions(+), 30 deletions(-) diff --git a/android/config.go b/android/config.go index c8d7cfdc9..cd1ac31dc 100644 --- a/android/config.go +++ b/android/config.go @@ -322,7 +322,7 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string DeviceName: stringPtr("test_device"), Platform_sdk_version: intPtr(30), Platform_sdk_codename: stringPtr("S"), - Platform_version_active_codenames: []string{"S"}, + Platform_version_active_codenames: []string{"S", "Tiramisu"}, DeviceSystemSdkVersions: []string{"14", "15"}, Platform_systemsdk_versions: []string{"29", "30"}, AAPTConfig: []string{"normal", "large", "xlarge", "hdpi", "xhdpi", "xxhdpi"}, diff --git a/apex/apex_test.go b/apex/apex_test.go index dcf68328e..888311137 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -215,7 +215,9 @@ var prepareForApexTest = android.GroupFixturePreparers( variables.CertificateOverrides = []string{"myapex_keytest:myapex.certificate.override"} variables.Platform_sdk_codename = proptools.StringPtr("Q") variables.Platform_sdk_final = proptools.BoolPtr(false) - variables.Platform_version_active_codenames = []string{"Q"} + // "Tiramisu" needs to be in the next line for compatibility with soong code, + // not because of these tests specifically (it's not used by the tests) + variables.Platform_version_active_codenames = []string{"Q", "Tiramisu"} variables.Platform_vndk_version = proptools.StringPtr("29") }), ) diff --git a/java/sdk_library.go b/java/sdk_library.go index 906f859fd..ea8b2221a 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1589,22 +1589,29 @@ func (module *SdkLibrary) UniqueApexVariations() bool { // Creates the xml file that publicizes the runtime library func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) { + moduleMinApiLevel := module.Library.MinSdkVersion(mctx).ApiLevel + var moduleMinApiLevelStr = moduleMinApiLevel.String() + if moduleMinApiLevel == android.NoneApiLevel { + moduleMinApiLevelStr = "current" + } props := struct { - Name *string - Lib_name *string - Apex_available []string - On_bootclasspath_since *string - On_bootclasspath_before *string - Min_device_sdk *string - Max_device_sdk *string + Name *string + Lib_name *string + Apex_available []string + On_bootclasspath_since *string + On_bootclasspath_before *string + Min_device_sdk *string + Max_device_sdk *string + Sdk_library_min_api_level *string }{ - Name: proptools.StringPtr(module.xmlPermissionsModuleName()), - Lib_name: proptools.StringPtr(module.BaseModuleName()), - Apex_available: module.ApexProperties.Apex_available, - On_bootclasspath_since: module.commonSdkLibraryProperties.On_bootclasspath_since, - On_bootclasspath_before: module.commonSdkLibraryProperties.On_bootclasspath_before, - Min_device_sdk: module.commonSdkLibraryProperties.Min_device_sdk, - Max_device_sdk: module.commonSdkLibraryProperties.Max_device_sdk, + Name: proptools.StringPtr(module.xmlPermissionsModuleName()), + Lib_name: proptools.StringPtr(module.BaseModuleName()), + Apex_available: module.ApexProperties.Apex_available, + On_bootclasspath_since: module.commonSdkLibraryProperties.On_bootclasspath_since, + On_bootclasspath_before: module.commonSdkLibraryProperties.On_bootclasspath_before, + Min_device_sdk: module.commonSdkLibraryProperties.Min_device_sdk, + Max_device_sdk: module.commonSdkLibraryProperties.Max_device_sdk, + Sdk_library_min_api_level: &moduleMinApiLevelStr, } mctx.CreateModule(sdkLibraryXmlFactory, &props) @@ -2427,6 +2434,11 @@ type sdkLibraryXmlProperties struct { // // This means that the device won't recognise this library as installed. Max_device_sdk *string + + // The SdkLibrary's min api level as a string + // + // This value comes from the ApiLevel of the MinSdkVersion property. + Sdk_library_min_api_level *string } // java_sdk_library_xml builds the permission xml file for a java_sdk_library. @@ -2534,6 +2546,14 @@ func (module *sdkLibraryXml) permissionsContents(ctx android.ModuleContext) stri implicitUntilAttr := formattedOptionalSdkLevelAttribute(ctx, "on_bootclasspath_before", module.properties.On_bootclasspath_before) minSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "min_device_sdk", module.properties.Min_device_sdk) maxSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "max_device_sdk", module.properties.Max_device_sdk) + // is understood in all android versions whereas is only understood from API T (and ignored before that). + // similarly, min_device_sdk is only understood from T. So if a library is using that, we need to use the updatable-library to make sure this library is not loaded before T + var libraryTag string + if module.properties.Min_device_sdk != nil { + libraryTag = ` \n`, @@ -2552,7 +2572,7 @@ func (module *sdkLibraryXml) permissionsContents(ctx android.ModuleContext) stri ` limitations under the License.\n`, `-->\n`, `\n`, - ` Date: Mon, 4 Oct 2021 15:28:07 +0000 Subject: [PATCH 036/148] Fix script for package check to work on macOS The behaviour of shell parameter expansion on linux and macOS is different: - on linux "\/" in the replaced string is interpreted as simply "/" - on macOS it is interpreted as the full string "\/" For example, "android.package.example" would be changed to: - "android/package/example" on linux - "android\/package\/example" on macOS The character / is not a special character for pattern matching in bash, so it doesn't need to be escaped. Hence using / instead of \/ in the replaced string works on both linux and macOS. Test: in sdk_mac continuous build. Merged-In: Id6a5cf32afc53d5ffd989c0ac8aa0b9e0fcbaf82 Change-Id: Id6a5cf32afc53d5ffd989c0ac8aa0b9e0fcbaf82 Fixes: 201947033 (cherry picked from commit 03c64c87a41ccc28721683cbac51fdbc1519ff02) --- scripts/package-check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/package-check.sh b/scripts/package-check.sh index d7e602f31..9f4a9da21 100755 --- a/scripts/package-check.sh +++ b/scripts/package-check.sh @@ -42,7 +42,7 @@ while [[ $# -ge 1 ]]; do fi # Transform to a slash-separated path and add a trailing slash to enforce # package name boundary. - prefixes+=("${package//\./\/}/") + prefixes+=("${package//\.//}/") shift done From d446d282edaefd8bd5b179d581463f7d15cca84c Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 1 Oct 2021 13:19:58 +0100 Subject: [PATCH 037/148] Always perform permitted package check when building a library Previously, the permitted package check was designed to only be run when building checkbuild. Although, that appears to now be broken. This change uses a Validation dependency to ensure that the package check is performed whenever the output file of a java_library is built as part of the build. The package check runs in parallel with any other rules that depend on the file. Bug: 201753898 Test: - change the permitted_packages property in frameworks/base/test-mock so that the package check will fail. m out/soong/.intermediates/frameworks/base/test-mock/android.test.mock/android_common/package-check.stamp - as expected the package check failed. m droid - as expected the package check did not fail. # Made these changes then: m droid - as expected the package check now failed. Merged-In: Id38fe280c79e5505ee4555b845c6da2ae6747bc4 Change-Id: Id38fe280c79e5505ee4555b845c6da2ae6747bc4 (cherry picked from commit 08a18bf74ae2c7609026e25e3f489a5bfec56d3b) --- java/base.go | 19 +++++++++++++++++-- sdk/bootclasspath_fragment_sdk_test.go | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/java/base.go b/java/base.go index df70efb44..5d2927ac9 100644 --- a/java/base.go +++ b/java/base.go @@ -1152,10 +1152,25 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { // Check package restrictions if necessary. if len(j.properties.Permitted_packages) > 0 { - // Check packages and copy to package-checked file. + // Time stamp file created by the package check rule. pkgckFile := android.PathForModuleOut(ctx, "package-check.stamp") + + // Create a rule to copy the output jar to another path and add a validate dependency that + // will check that the jar only contains the permitted packages. The new location will become + // the output file of this module. + inputFile := outputFile + outputFile = android.PathForModuleOut(ctx, "package-check", jarName).OutputPath + ctx.Build(pctx, android.BuildParams{ + Rule: android.Cp, + Input: inputFile, + Output: outputFile, + // Make sure that any dependency on the output file will cause ninja to run the package check + // rule. + Validation: pkgckFile, + }) + + // Check packages and create a timestamp file when complete. CheckJarPackages(ctx, pkgckFile, outputFile, j.properties.Permitted_packages) - j.additionalCheckedModules = append(j.additionalCheckedModules, pkgckFile) if ctx.Failed() { return diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go index 1718734c0..c1b093064 100644 --- a/sdk/bootclasspath_fragment_sdk_test.go +++ b/sdk/bootclasspath_fragment_sdk_test.go @@ -499,7 +499,7 @@ sdk_snapshot { .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv -.intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar +.intermediates/mybootlib/android_common/package-check/mybootlib.jar -> java/mybootlib.jar .intermediates/myothersdklibrary.stubs/android_common/javac/myothersdklibrary.stubs.jar -> sdk_library/public/myothersdklibrary-stubs.jar .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_api.txt -> sdk_library/public/myothersdklibrary.txt .intermediates/myothersdklibrary.stubs.source/android_common/metalava/myothersdklibrary.stubs.source_removed.txt -> sdk_library/public/myothersdklibrary-removed.txt @@ -765,7 +765,7 @@ my-unsupported-packages.txt -> hiddenapi/my-unsupported-packages.txt .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv .intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv -.intermediates/mybootlib/android_common/javac/mybootlib.jar -> java/mybootlib.jar +.intermediates/mybootlib/android_common/package-check/mybootlib.jar -> java/mybootlib.jar .intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt .intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt From 65d9718328856b649efc76abf9ac4b6d0a2adcf6 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 12 Oct 2021 16:47:43 +0900 Subject: [PATCH 038/148] Add the device config GenerateAidlNdkPlatformBackend The config is used to force the generation of the AIDL ndk_platform backend which will eventually be removed in favor of the ndk backend. The switch is needed as an escape hatch for some devices whose BSP (outsourced and thus hardly modifiable) depends on the ndk_backend libraries. Bug: 161456198 Test: m Change-Id: Ie11ca62be05754bb2593da16e1380103c670b393 --- android/config.go | 4 ++++ android/variable.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/android/config.go b/android/config.go index cd1ac31dc..99b1ad177 100644 --- a/android/config.go +++ b/android/config.go @@ -1578,6 +1578,10 @@ func (c *deviceConfig) SepolicyFreezeTestExtraPrebuiltDirs() []string { return c.config.productVariables.SepolicyFreezeTestExtraPrebuiltDirs } +func (c *deviceConfig) GenerateAidlNdkPlatformBackend() bool { + return c.config.productVariables.GenerateAidlNdkPlatformBackend +} + // The ConfiguredJarList struct provides methods for handling a list of (apex, jar) pairs. // Such lists are used in the build system for things like bootclasspath jars or system server jars. // The apex part is either an apex name, or a special names "platform" or "system_ext". Jar is a diff --git a/android/variable.go b/android/variable.go index f489dd939..b7bc824b3 100644 --- a/android/variable.go +++ b/android/variable.go @@ -417,6 +417,8 @@ type productVariables struct { SepolicyFreezeTestExtraDirs []string `json:",omitempty"` SepolicyFreezeTestExtraPrebuiltDirs []string `json:",omitempty"` + + GenerateAidlNdkPlatformBackend bool `json:",omitempty"` } func boolPtr(v bool) *bool { From 3adf3c52eb569b2203160e5503a3ddfa68f7a4ac Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Tue, 21 Sep 2021 15:25:12 +0100 Subject: [PATCH 039/148] Add annotations.zip support to java_sdk_library The annotations zip file is produced by the "main" sdk build and is primarily consumed by android studio. In order to support building the main SDK without requiring the sources of all modules, we are adding module SDK artifacts that allows reconstructing these outputs. The annotations zip contains XML files which should be fairly easy to merge from all the individual parts. Bug: 187397779 Test: unit tests in this CL Test: m sdkextensions-sdk and inspect output Merged-In: I955cae720e6f1382936836ee1d8fb11003f51b7d Change-Id: I955cae720e6f1382936836ee1d8fb11003f51b7d --- java/droidstubs.go | 5 ++++ java/sdk_library.go | 32 ++++++++++++++++++++++---- java/sdk_library_test.go | 30 +++++++++++++++++++++++- java/testing.go | 1 + sdk/java_sdk_test.go | 49 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 112 insertions(+), 5 deletions(-) diff --git a/java/droidstubs.go b/java/droidstubs.go index c756815c6..9d383ce22 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -153,6 +153,7 @@ type ApiStubsSrcProvider interface { // Provider of information about API stubs, used by java_sdk_library. type ApiStubsProvider interface { + AnnotationsZip() android.Path ApiFilePath RemovedApiFilePath() android.Path @@ -207,6 +208,10 @@ func (d *Droidstubs) OutputFiles(tag string) (android.Paths, error) { } } +func (d *Droidstubs) AnnotationsZip() android.Path { + return d.annotationsZip +} + func (d *Droidstubs) ApiFilePath() android.Path { return d.apiFilePath } diff --git a/java/sdk_library.go b/java/sdk_library.go index 12353c90e..751a71d0c 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -550,6 +550,9 @@ type scopePaths struct { // The stubs source jar. stubsSrcJar android.OptionalPath + + // Extracted annotations. + annotationsZip android.OptionalPath } func (paths *scopePaths) extractStubsLibraryInfoFromDependency(ctx android.ModuleContext, dep android.Module) error { @@ -585,6 +588,7 @@ func (paths *scopePaths) treatDepAsApiStubsSrcProvider(dep android.Module, actio } func (paths *scopePaths) extractApiInfoFromApiStubsProvider(provider ApiStubsProvider) { + paths.annotationsZip = android.OptionalPathForPath(provider.AnnotationsZip()) paths.currentApiFilePath = android.OptionalPathForPath(provider.ApiFilePath()) paths.removedApiFilePath = android.OptionalPathForPath(provider.RemovedApiFilePath()) } @@ -739,6 +743,8 @@ const ( apiTxtComponentName = "api.txt" removedApiTxtComponentName = "removed-api.txt" + + annotationsComponentName = "annotations.zip" ) // A regular expression to match tags that reference a specific stubs component. @@ -757,7 +763,7 @@ var tagSplitter = func() *regexp.Regexp { scopesRegexp := choice(allScopeNames...) // Regular expression to match one of the components. - componentsRegexp := choice(stubsSourceComponentName, apiTxtComponentName, removedApiTxtComponentName) + componentsRegexp := choice(stubsSourceComponentName, apiTxtComponentName, removedApiTxtComponentName, annotationsComponentName) // Regular expression to match any combination of one scope and one component. return regexp.MustCompile(fmt.Sprintf(`^\.(%s)\.(%s)$`, scopesRegexp, componentsRegexp)) @@ -765,9 +771,7 @@ var tagSplitter = func() *regexp.Regexp { // For OutputFileProducer interface // -// ..stubs.source -// ..api.txt -// ..removed-api.txt +// .., for all ComponentNames (for example: .public.removed-api.txt) func (c *commonToSdkLibraryAndImport) commonOutputFiles(tag string) (android.Paths, error) { if groups := tagSplitter.FindStringSubmatch(tag); groups != nil { scopeName := groups[1] @@ -794,6 +798,11 @@ func (c *commonToSdkLibraryAndImport) commonOutputFiles(tag string) (android.Pat if paths.removedApiFilePath.Valid() { return android.Paths{paths.removedApiFilePath.Path()}, nil } + + case annotationsComponentName: + if paths.annotationsZip.Valid() { + return android.Paths{paths.annotationsZip.Path()}, nil + } } return nil, fmt.Errorf("%s not available for api scope %s", component, scopeName) @@ -1888,6 +1897,9 @@ type sdkLibraryScopeProperties struct { // The removed.txt Removed_api *string `android:"path"` + + // Annotation zip + Annotations *string `android:"path"` } type sdkLibraryImportProperties struct { @@ -2189,6 +2201,7 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo } paths := module.getScopePathsCreateIfNeeded(apiScope) + paths.annotationsZip = android.OptionalPathForModuleSrc(ctx, scopeProperties.Annotations) paths.currentApiFilePath = android.OptionalPathForModuleSrc(ctx, scopeProperties.Current_api) paths.removedApiFilePath = android.OptionalPathForModuleSrc(ctx, scopeProperties.Removed_api) } @@ -2529,6 +2542,7 @@ type scopeProperties struct { StubsSrcJar android.Path CurrentApiFile android.Path RemovedApiFile android.Path + AnnotationsZip android.Path SdkVersion string } @@ -2554,6 +2568,10 @@ func (s *sdkLibrarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMembe if paths.removedApiFilePath.Valid() { properties.RemovedApiFile = paths.removedApiFilePath.Path() } + // The annotations zip is only available for modules that set annotations_enabled: true. + if paths.annotationsZip.Valid() { + properties.AnnotationsZip = paths.annotationsZip.Path() + } s.Scopes[apiScope] = properties } } @@ -2618,6 +2636,12 @@ func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberCo scopeSet.AddProperty("removed_api", removedApiSnapshotPath) } + if properties.AnnotationsZip != nil { + annotationsSnapshotPath := filepath.Join(scopeDir, ctx.Name()+"_annotations.zip") + ctx.SnapshotBuilder().CopyToSnapshot(properties.AnnotationsZip, annotationsSnapshotPath) + scopeSet.AddProperty("annotations", annotationsSnapshotPath) + } + if properties.SdkVersion != "" { scopeSet.AddProperty("sdk_version", properties.SdkVersion) } diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 65af95314..3cf4987e1 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -247,12 +247,37 @@ func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) { } } -func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) { +func TestJavaSdkLibrary_AccessOutputFiles(t *testing.T) { android.GroupFixturePreparers( prepareForJavaTest, PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("foo"), ).RunTestWithBp(t, ` + java_sdk_library { + name: "foo", + srcs: ["a.java"], + api_packages: ["foo"], + annotations_enabled: true, + public: { + enabled: true, + }, + } + java_library { + name: "bar", + srcs: ["b.java", ":foo{.public.stubs.source}"], + java_resources: [":foo{.public.annotations.zip}"], + } + `) +} + +func TestJavaSdkLibrary_AccessOutputFiles_NoAnnotations(t *testing.T) { + android.GroupFixturePreparers( + prepareForJavaTest, + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo"), + ). + ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "bar" variant "android_common": path dependency ":foo{.public.annotations.zip}": annotations.zip not available for api scope public`)). + RunTestWithBp(t, ` java_sdk_library { name: "foo", srcs: ["a.java"], @@ -265,6 +290,7 @@ func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) { java_library { name: "bar", srcs: ["b.java", ":foo{.public.stubs.source}"], + java_resources: [":foo{.public.annotations.zip}"], } `) } @@ -328,6 +354,7 @@ func TestJavaSdkLibraryImport_AccessOutputFiles(t *testing.T) { stub_srcs: ["a.java"], current_api: "api/current.txt", removed_api: "api/removed.txt", + annotations: "x/annotations.zip", }, } @@ -337,6 +364,7 @@ func TestJavaSdkLibraryImport_AccessOutputFiles(t *testing.T) { java_resources: [ ":foo{.public.api.txt}", ":foo{.public.removed-api.txt}", + ":foo{.public.annotations.zip}", ], } `) diff --git a/java/testing.go b/java/testing.go index 8860b45fa..d5c464dd8 100644 --- a/java/testing.go +++ b/java/testing.go @@ -280,6 +280,7 @@ func gatherRequiredDepsForTest() string { "kotlin-stdlib-jdk7", "kotlin-stdlib-jdk8", "kotlin-annotations", + "stub-annotations", } for _, extra := range extraModules { diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go index 813dcfd6d..42826b79e 100644 --- a/sdk/java_sdk_test.go +++ b/sdk/java_sdk_test.go @@ -1204,6 +1204,55 @@ java_sdk_library_import { ) } +func TestSnapshotWithJavaSdkLibrary_AnnotationsZip(t *testing.T) { + result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` + sdk { + name: "mysdk", + java_sdk_libs: ["myjavalib"], + } + + java_sdk_library { + name: "myjavalib", + srcs: ["Test.java"], + sdk_version: "current", + shared_library: false, + annotations_enabled: true, + public: { + enabled: true, + }, + } + `) + + CheckSnapshot(t, result, "mysdk", "", + checkUnversionedAndroidBpContents(` +// This is auto-generated. DO NOT EDIT. + +java_sdk_library_import { + name: "myjavalib", + prefer: false, + visibility: ["//visibility:public"], + apex_available: ["//apex_available:platform"], + shared_library: false, + public: { + jars: ["sdk_library/public/myjavalib-stubs.jar"], + stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], + current_api: "sdk_library/public/myjavalib.txt", + removed_api: "sdk_library/public/myjavalib-removed.txt", + annotations: "sdk_library/public/myjavalib_annotations.zip", + sdk_version: "current", + }, +} + `), + checkAllCopyRules(` +.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar +.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt +.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt +.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_annotations.zip -> sdk_library/public/myjavalib_annotations.zip + `), + checkMergeZips(".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip"), + ) +} + func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) { result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` sdk { From 0e146ddb554ae0cb757fa90234dc2cb79474459e Mon Sep 17 00:00:00 2001 From: Baligh Uddin Date: Fri, 15 Oct 2021 21:28:47 +0000 Subject: [PATCH 040/148] update allowlist to new path for bluetooth BUG: 196026708 Test: TH Change-Id: Ia511786ea3f47f673d638bdde8581fe0a31a3cc1 --- rust/config/allowed_list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/config/allowed_list.go b/rust/config/allowed_list.go index 47ca3a7ec..6534e8f56 100644 --- a/rust/config/allowed_list.go +++ b/rust/config/allowed_list.go @@ -17,10 +17,10 @@ var ( "external/vm_tools/p9", "frameworks/native/libs/binder/rust", "frameworks/proto_logging/stats", + "packages/modules/Bluetooth", "packages/modules/DnsResolver", "packages/modules/Virtualization", "prebuilts/rust", - "system/bt", "system/core/libstats/pull_rust", "system/extras/profcollectd", "system/extras/simpleperf", From 6e3ba9ac3bb53eb565e98d3b7fb46e85e26f19ce Mon Sep 17 00:00:00 2001 From: Keun young Park Date: Mon, 18 Oct 2021 08:42:23 -0700 Subject: [PATCH 041/148] Make car apex's library optional in PRODUCT_APEX_SYSTEM_SERVER_JARS - car-frameworks-service-module is added from com.android.car.framework apex which only exisits in car products. Bug: 203233647 Bug: 203201931 Test: build, bootup Change-Id: I5f13b0505c1ac4fd2fd7b6559e080c8a6fb526e0 --- java/systemserver_classpath_fragment.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go index f209f4a68..b5f52fd10 100644 --- a/java/systemserver_classpath_fragment.go +++ b/java/systemserver_classpath_fragment.go @@ -120,7 +120,10 @@ func (s *SystemServerClasspathModule) configuredJars(ctx android.ModuleContext) jars, unknown := global.ApexSystemServerJars.Filter(possibleUpdatableModules) // TODO(satayev): remove geotz ssc_fragment, since geotz is not part of SSCP anymore. _, unknown = android.RemoveFromList("geotz", unknown) - + // This module only exists in car products. + // So ignore it even if it is not in PRODUCT_APEX_SYSTEM_SERVER_JARS. + // TODO(b/203233647): Add better mechanism to make it optional. + _, unknown = android.RemoveFromList("car-frameworks-service-module", unknown) // For non test apexes, make sure that all contents are actually declared in make. if global.ApexSystemServerJars.Len() > 0 && len(unknown) > 0 && !android.IsModuleInVersionedSdk(ctx.Module()) { ctx.ModuleErrorf("%s in contents must also be declared in PRODUCT_APEX_SYSTEM_SERVER_JARS", unknown) From 5979996e64e37d6fa1aa24a1602627042c8e82be Mon Sep 17 00:00:00 2001 From: Keun young Park Date: Thu, 14 Oct 2021 15:42:04 -0700 Subject: [PATCH 042/148] Allow skipping android.car-module library in PRODUCT_APEX_BOOT_JARS - The library is added to bootclass path only for car product through com.android.car.framework apex module - Ignore it even if it is not in PRODUCT_APEX_BOOT_JARS for non-car builds Bug: 202345178 Bug: 202896428 Test: test boot up for non-car build Change-Id: I4ba86b4c7f4d4005add9bb5c415aed39f119af0c --- java/bootclasspath_fragment.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index 8f18790ea..4c8a77914 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -619,6 +619,10 @@ func (b *BootclasspathFragmentModule) configuredJars(ctx android.ModuleContext) } else if global.ApexBootJars.Len() != 0 && !android.IsModuleInVersionedSdk(ctx.Module()) { unknown = android.RemoveListFromList(unknown, b.properties.Coverage.Contents) _, unknown = android.RemoveFromList("core-icu4j", unknown) + // This module only exists in car products. + // So ignore it even if it is not in PRODUCT_APEX_BOOT_JARS. + // TODO(b/202896428): Add better way to handle this. + _, unknown = android.RemoveFromList("android.car-module", unknown) if len(unknown) > 0 { ctx.ModuleErrorf("%s in contents must also be declared in PRODUCT_APEX_BOOT_JARS", unknown) } From 6941b9dbc02c8a47c256a7c1331a7e77b2e467c4 Mon Sep 17 00:00:00 2001 From: Arthur Ishiguro Date: Thu, 14 Oct 2021 16:15:13 +0000 Subject: [PATCH 043/148] Add sensors AIDL interface Bug: 195593357 Test: Presubmit Change-Id: Ie3947594a35c829245535f04937b1ad7f3798cde --- cc/config/vndk.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cc/config/vndk.go b/cc/config/vndk.go index fd23e53d0..20dd9b212 100644 --- a/cc/config/vndk.go +++ b/cc/config/vndk.go @@ -89,6 +89,7 @@ var VndkMustUseVendorVariantList = []string{ "android.hardware.security.sharedsecret-V1-ndk_platform", "android.hardware.security.sharedsecret-ndk_platform", "android.hardware.security.sharedsecret-unstable-ndk_platform", + "android.hardware.sensors-V1-ndk", "android.hardware.soundtrigger3-V1-ndk", "android.hardware.soundtrigger3-V1-ndk_platform", "android.hardware.uwb-V1-ndk", From 80751747e86b8fda015015fe7404ea85f408b968 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Thu, 28 Oct 2021 14:26:03 +0900 Subject: [PATCH 044/148] Respect `required` property of apex modules This CL fixes a bug that `required` property of apex modules is not reflected to the generated Android.mk file. Ignore-AOSP-First: needs to be merged together with a change in vendor directory Bug: N/A Test: m nothing Change-Id: I36ccf538882f083f9433bd3eb05b3a5127f3822b --- apex/androidmk.go | 3 +++ apex/apex_test.go | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/apex/androidmk.go b/apex/androidmk.go index 94b81163d..80237fb5f 100644 --- a/apex/androidmk.go +++ b/apex/androidmk.go @@ -326,6 +326,9 @@ func (a *apexBundle) writeRequiredModules(w io.Writer, apexBundleName string) { var required []string var targetRequired []string var hostRequired []string + required = append(required, a.RequiredModuleNames()...) + targetRequired = append(targetRequired, a.TargetRequiredModuleNames()...) + hostRequired = append(hostRequired, a.HostRequiredModuleNames()...) installMapSet := make(map[string]bool) // set of dependency module:location mappings for _, fi := range a.filesInfo { required = append(required, fi.requiredModuleNames...) diff --git a/apex/apex_test.go b/apex/apex_test.go index b4da9b4f1..f4c109145 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -8330,6 +8330,46 @@ func TestAndroidMk_DexpreoptBuiltInstalledForApex_Prebuilt(t *testing.T) { }) } +func TestAndroidMk_RequiredModules(t *testing.T) { + ctx := testApex(t, ` + apex { + name: "myapex", + key: "myapex.key", + updatable: false, + java_libs: ["foo"], + required: ["otherapex"], + } + + apex { + name: "otherapex", + key: "myapex.key", + updatable: false, + java_libs: ["foo"], + required: ["otherapex"], + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + java_library { + name: "foo", + srcs: ["foo.java"], + apex_available: ["myapex", "otherapex"], + installable: true, + } + `) + + apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle) + data := android.AndroidMkDataForTest(t, ctx, apexBundle) + var builder strings.Builder + data.Custom(&builder, apexBundle.BaseModuleName(), "TARGET_", "", data) + androidMk := builder.String() + ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += otherapex") +} + func TestMain(m *testing.M) { os.Exit(m.Run()) } From bde653e5fdde3c2136b524e2afbd42bfa008dd2f Mon Sep 17 00:00:00 2001 From: Pedro Loureiro Date: Fri, 29 Oct 2021 09:32:32 +0000 Subject: [PATCH 045/148] Fix attribute names in generated permissions.xml Previously it would write min_device_sdk whereas the correct name should be min-device-sdk. This happened for all shared libs attributes. Test: m nothing Test: manually installed an apex with a shared lib and made sure PM used the attributes as expected Bug: 191978330 Change-Id: Iecf7edd6bae98c7af908d3f320f10ae4973d0396 --- java/sdk_library.go | 11 ++++++----- java/sdk_library_test.go | 16 ++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index ea8b2221a..b0880839c 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -2521,7 +2521,8 @@ func formattedOptionalSdkLevelAttribute(ctx android.ModuleContext, attrName stri } apiLevel, err := android.ApiLevelFromUser(ctx, *value) if err != nil { - ctx.PropertyErrorf(attrName, err.Error()) + // attributes in bp files have underscores but in the xml have dashes. + ctx.PropertyErrorf(strings.ReplaceAll(attrName, "-", "_"), err.Error()) return "" } intStr := strconv.Itoa(apiLevel.FinalOrPreviewInt()) @@ -2542,10 +2543,10 @@ func (module *sdkLibraryXml) permissionsContents(ctx android.ModuleContext) stri libNameAttr := formattedOptionalAttribute("name", &libName) filePath := module.implPath(ctx) filePathAttr := formattedOptionalAttribute("file", &filePath) - implicitFromAttr := formattedOptionalSdkLevelAttribute(ctx, "on_bootclasspath_since", module.properties.On_bootclasspath_since) - implicitUntilAttr := formattedOptionalSdkLevelAttribute(ctx, "on_bootclasspath_before", module.properties.On_bootclasspath_before) - minSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "min_device_sdk", module.properties.Min_device_sdk) - maxSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "max_device_sdk", module.properties.Max_device_sdk) + implicitFromAttr := formattedOptionalSdkLevelAttribute(ctx, "on-bootclasspath-since", module.properties.On_bootclasspath_since) + implicitUntilAttr := formattedOptionalSdkLevelAttribute(ctx, "on-bootclasspath-before", module.properties.On_bootclasspath_before) + minSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "min-device-sdk", module.properties.Min_device_sdk) + maxSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "max-device-sdk", module.properties.Max_device_sdk) // is understood in all android versions whereas is only understood from API T (and ignored before that). // similarly, min_device_sdk is only understood from T. So if a library is using that, we need to use the updatable-library to make sure this library is not loaded before T var libraryTag string diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 9506c8aee..2271573b6 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -195,18 +195,18 @@ func TestJavaSdkLibrary_UpdatableLibrary(t *testing.T) { `) // test that updatability attributes are passed on correctly fooUpdatable := result.ModuleForTests("fooUpdatable.xml", "android_common").Rule("java_sdk_xml") - android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on_bootclasspath_since=\"9001\"`) - android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on_bootclasspath_before=\"9002\"`) - android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `min_device_sdk=\"9003\"`) - android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `max_device_sdk=\"10000\"`) + android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on-bootclasspath-since=\"9001\"`) + android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `on-bootclasspath-before=\"9002\"`) + android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `min-device-sdk=\"9003\"`) + android.AssertStringDoesContain(t, "fooUpdatable.xml java_sdk_xml command", fooUpdatable.RuleParams.Command, `max-device-sdk=\"10000\"`) // double check that updatability attributes are not written if they don't exist in the bp file // the permissions file for the foo library defined above fooPermissions := result.ModuleForTests("foo.xml", "android_common").Rule("java_sdk_xml") - android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `on_bootclasspath_since`) - android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `on_bootclasspath_before`) - android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `min_device_sdk`) - android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `max_device_sdk`) + android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `on-bootclasspath-since`) + android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `on-bootclasspath-before`) + android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `min-device-sdk`) + android.AssertStringDoesNotContain(t, "foo.xml java_sdk_xml command", fooPermissions.RuleParams.Command, `max-device-sdk`) } func TestJavaSdkLibrary_UpdatableLibrary_Validation_ValidVersion(t *testing.T) { From 8d22c2ed1b759603ed56ae6e70c592373d22675b Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Mon, 1 Nov 2021 14:23:47 +0000 Subject: [PATCH 046/148] Remove duplicate optional_uses_libs block Change-Id: I58e8484482a77cefd3f66076f4a04b720cf173c7 Fixes: 204589171 --- cmd/pom2bp/pom2bp.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cmd/pom2bp/pom2bp.go b/cmd/pom2bp/pom2bp.go index c045decb8..1c88bcae6 100644 --- a/cmd/pom2bp/pom2bp.go +++ b/cmd/pom2bp/pom2bp.go @@ -533,13 +533,6 @@ var bpTemplate = template.Must(template.New("bp").Parse(` {{- end}} ], {{- end}} - {{- if .BpOptionalUsesLibs}} - optional_uses_libs: [ - {{- range .BpOptionalUsesLibs}} - "{{.}}", - {{- end}} - ], - {{- end}} {{- else if not .IsHostOnly}} min_sdk_version: "{{.DefaultMinSdkVersion}}", {{- end}} From 7075ed03daa6dbe8db29e35f0a47bb5466e21f0a Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Thu, 28 Oct 2021 16:45:21 +0100 Subject: [PATCH 047/148] S V2 is now 32 Bug: 204295952 Test: N/A Change-Id: Ib13f30c27cf79c2903e05d3c2cd27d79c4a28668 --- android/api_levels.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android/api_levels.go b/android/api_levels.go index 93583bc07..a337371ae 100644 --- a/android/api_levels.go +++ b/android/api_levels.go @@ -290,6 +290,7 @@ func getFinalCodenamesMap(config Config) map[string]int { "Q": 29, "R": 30, "S": 31, + "S-V2": 32, } // TODO: Differentiate "current" and "future". @@ -333,6 +334,7 @@ func getApiLevelsMap(config Config) map[string]int { "Q": 29, "R": 30, "S": 31, + "S-V2": 32, } for i, codename := range config.PlatformVersionActiveCodenames() { apiLevelsMap[codename] = previewAPILevelBase + i From 8eab869bfebf007e334f4c710f5a92ca19efa5df Mon Sep 17 00:00:00 2001 From: Rupert Shuttleworth Date: Wed, 3 Nov 2021 10:39:39 -0400 Subject: [PATCH 048/148] Add ability to set --rotation-min-sdk-version for signapk via Android.bp files. (vs via Android.mk files, done earlier in http://ag/16094391) Bug: 197787352 Test: Added unit tests. Change-Id: I3ccd2f2134b069fb4c4a90fe384c23c1814c2ba2 --- java/app.go | 10 +- java/app_builder.go | 10 +- java/app_import.go | 8 +- java/app_import_test.go | 12 ++- java/app_test.go | 205 ++++++++++++++++++++-------------------- java/rro.go | 8 +- java/rro_test.go | 12 ++- 7 files changed, 147 insertions(+), 118 deletions(-) diff --git a/java/app.go b/java/app.go index 6554d6693..48576603e 100755 --- a/java/app.go +++ b/java/app.go @@ -128,6 +128,9 @@ type overridableAppProperties struct { // Name of the signing certificate lineage file or filegroup module. Lineage *string `android:"path"` + // For overriding the --rotation-min-sdk-version property of apksig + RotationMinSdkVersion *string + // the package name of this app. The package name in the manifest file is used if one was not given. Package_name *string @@ -693,7 +696,10 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) { if lineage := String(a.overridableAppProperties.Lineage); lineage != "" { lineageFile = android.PathForModuleSrc(ctx, lineage) } - CreateAndSignAppPackage(ctx, packageFile, a.exportPackage, jniJarFile, dexJarFile, certificates, apkDeps, v4SignatureFile, lineageFile) + + rotationMinSdkVersion := String(a.overridableAppProperties.RotationMinSdkVersion) + + CreateAndSignAppPackage(ctx, packageFile, a.exportPackage, jniJarFile, dexJarFile, certificates, apkDeps, v4SignatureFile, lineageFile, rotationMinSdkVersion) a.outputFile = packageFile if v4SigningRequested { a.extraOutputFiles = append(a.extraOutputFiles, v4SignatureFile) @@ -705,7 +711,7 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) { if v4SigningRequested { v4SignatureFile = android.PathForModuleOut(ctx, a.installApkName+"_"+split.suffix+".apk.idsig") } - CreateAndSignAppPackage(ctx, packageFile, split.path, nil, nil, certificates, apkDeps, v4SignatureFile, lineageFile) + CreateAndSignAppPackage(ctx, packageFile, split.path, nil, nil, certificates, apkDeps, v4SignatureFile, lineageFile, rotationMinSdkVersion) a.extraOutputFiles = append(a.extraOutputFiles, packageFile) if v4SigningRequested { a.extraOutputFiles = append(a.extraOutputFiles, v4SignatureFile) diff --git a/java/app_builder.go b/java/app_builder.go index 4a18dcada..74cd85c08 100644 --- a/java/app_builder.go +++ b/java/app_builder.go @@ -52,7 +52,7 @@ var combineApk = pctx.AndroidStaticRule("combineApk", }) func CreateAndSignAppPackage(ctx android.ModuleContext, outputFile android.WritablePath, - packageFile, jniJarFile, dexJarFile android.Path, certificates []Certificate, deps android.Paths, v4SignatureFile android.WritablePath, lineageFile android.Path) { + packageFile, jniJarFile, dexJarFile android.Path, certificates []Certificate, deps android.Paths, v4SignatureFile android.WritablePath, lineageFile android.Path, rotationMinSdkVersion string) { unsignedApkName := strings.TrimSuffix(outputFile.Base(), ".apk") + "-unsigned.apk" unsignedApk := android.PathForModuleOut(ctx, unsignedApkName) @@ -73,10 +73,10 @@ func CreateAndSignAppPackage(ctx android.ModuleContext, outputFile android.Writa Implicits: deps, }) - SignAppPackage(ctx, outputFile, unsignedApk, certificates, v4SignatureFile, lineageFile) + SignAppPackage(ctx, outputFile, unsignedApk, certificates, v4SignatureFile, lineageFile, rotationMinSdkVersion) } -func SignAppPackage(ctx android.ModuleContext, signedApk android.WritablePath, unsignedApk android.Path, certificates []Certificate, v4SignatureFile android.WritablePath, lineageFile android.Path) { +func SignAppPackage(ctx android.ModuleContext, signedApk android.WritablePath, unsignedApk android.Path, certificates []Certificate, v4SignatureFile android.WritablePath, lineageFile android.Path, rotationMinSdkVersion string) { var certificateArgs []string var deps android.Paths @@ -97,6 +97,10 @@ func SignAppPackage(ctx android.ModuleContext, signedApk android.WritablePath, u deps = append(deps, lineageFile) } + if rotationMinSdkVersion != "" { + flags = append(flags, "--rotation-min-sdk-version", rotationMinSdkVersion) + } + rule := Signapk args := map[string]string{ "certificates": strings.Join(certificateArgs, " "), diff --git a/java/app_import.go b/java/app_import.go index 3e5f972a4..faf471634 100644 --- a/java/app_import.go +++ b/java/app_import.go @@ -77,6 +77,9 @@ type AndroidAppImportProperties struct { // Name of the signing certificate lineage file or filegroup module. Lineage *string `android:"path"` + // For overriding the --rotation-min-sdk-version property of apksig + RotationMinSdkVersion *string + // Sign with the default system dev certificate. Must be used judiciously. Most imported apps // need to either specify a specific certificate or be presigned. Default_dev_cert *bool @@ -330,7 +333,10 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext if lineage := String(a.properties.Lineage); lineage != "" { lineageFile = android.PathForModuleSrc(ctx, lineage) } - SignAppPackage(ctx, signed, jnisUncompressed, certificates, nil, lineageFile) + + rotationMinSdkVersion := String(a.properties.RotationMinSdkVersion) + + SignAppPackage(ctx, signed, jnisUncompressed, certificates, nil, lineageFile, rotationMinSdkVersion) a.outputFile = signed } else { alignedApk := android.PathForModuleOut(ctx, "zip-aligned", apkFilename) diff --git a/java/app_import_test.go b/java/app_import_test.go index efa52c178..55d24c4b8 100644 --- a/java/app_import_test.go +++ b/java/app_import_test.go @@ -112,6 +112,7 @@ func TestAndroidAppImport_SigningLineage(t *testing.T) { certificate: "platform", additional_certificates: [":additional_certificate"], lineage: "lineage.bin", + rotationMinSdkVersion: "32", } android_app_certificate { @@ -131,11 +132,12 @@ func TestAndroidAppImport_SigningLineage(t *testing.T) { if expected != certificatesFlag { t.Errorf("Incorrect certificates flags, expected: %q, got: %q", expected, certificatesFlag) } - // Check cert signing lineage flag. - signingFlag := signedApk.Args["flags"] - expected = "--lineage lineage.bin" - if expected != signingFlag { - t.Errorf("Incorrect signing flags, expected: %q, got: %q", expected, signingFlag) + + // Check cert signing flags. + actualCertSigningFlags := signedApk.Args["flags"] + expectedCertSigningFlags := "--lineage lineage.bin --rotation-min-sdk-version 32" + if expectedCertSigningFlags != actualCertSigningFlags { + t.Errorf("Incorrect signing flags, expected: %q, got: %q", expectedCertSigningFlags, actualCertSigningFlags) } } diff --git a/java/app_test.go b/java/app_test.go index 07439fcd0..349c1b5f2 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -1485,11 +1485,11 @@ func TestJNISDK(t *testing.T) { func TestCertificates(t *testing.T) { testCases := []struct { - name string - bp string - certificateOverride string - expectedLineage string - expectedCertificate string + name string + bp string + certificateOverride string + expectedCertSigningFlags string + expectedCertificate string }{ { name: "default", @@ -1500,9 +1500,9 @@ func TestCertificates(t *testing.T) { sdk_version: "current", } `, - certificateOverride: "", - expectedLineage: "", - expectedCertificate: "build/make/target/product/security/testkey.x509.pem build/make/target/product/security/testkey.pk8", + certificateOverride: "", + expectedCertSigningFlags: "", + expectedCertificate: "build/make/target/product/security/testkey.x509.pem build/make/target/product/security/testkey.pk8", }, { name: "module certificate property", @@ -1519,9 +1519,9 @@ func TestCertificates(t *testing.T) { certificate: "cert/new_cert", } `, - certificateOverride: "", - expectedLineage: "", - expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8", + certificateOverride: "", + expectedCertSigningFlags: "", + expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8", }, { name: "path certificate property", @@ -1533,9 +1533,9 @@ func TestCertificates(t *testing.T) { sdk_version: "current", } `, - certificateOverride: "", - expectedLineage: "", - expectedCertificate: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8", + certificateOverride: "", + expectedCertSigningFlags: "", + expectedCertificate: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8", }, { name: "certificate overrides", @@ -1552,18 +1552,19 @@ func TestCertificates(t *testing.T) { certificate: "cert/new_cert", } `, - certificateOverride: "foo:new_certificate", - expectedLineage: "", - expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8", + certificateOverride: "foo:new_certificate", + expectedCertSigningFlags: "", + expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8", }, { - name: "certificate lineage", + name: "certificate signing flags", bp: ` android_app { name: "foo", srcs: ["a.java"], certificate: ":new_certificate", lineage: "lineage.bin", + rotationMinSdkVersion: "32", sdk_version: "current", } @@ -1572,18 +1573,19 @@ func TestCertificates(t *testing.T) { certificate: "cert/new_cert", } `, - certificateOverride: "", - expectedLineage: "--lineage lineage.bin", - expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8", + certificateOverride: "", + expectedCertSigningFlags: "--lineage lineage.bin --rotation-min-sdk-version 32", + expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8", }, { - name: "lineage from filegroup", + name: "cert signing flags from filegroup", bp: ` android_app { name: "foo", srcs: ["a.java"], certificate: ":new_certificate", lineage: ":lineage_bin", + rotationMinSdkVersion: "32", sdk_version: "current", } @@ -1597,9 +1599,9 @@ func TestCertificates(t *testing.T) { srcs: ["lineage.bin"], } `, - certificateOverride: "", - expectedLineage: "--lineage lineage.bin", - expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8", + certificateOverride: "", + expectedCertSigningFlags: "--lineage lineage.bin --rotation-min-sdk-version 32", + expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8", }, } @@ -1620,8 +1622,8 @@ func TestCertificates(t *testing.T) { signCertificateFlags := signapk.Args["certificates"] android.AssertStringEquals(t, "certificates flags", test.expectedCertificate, signCertificateFlags) - signFlags := signapk.Args["flags"] - android.AssertStringEquals(t, "signing flags", test.expectedLineage, signFlags) + certSigningFlags := signapk.Args["flags"] + android.AssertStringEquals(t, "cert signing flags", test.expectedCertSigningFlags, certSigningFlags) }) } } @@ -1800,6 +1802,7 @@ func TestOverrideAndroidApp(t *testing.T) { base: "foo", certificate: ":new_certificate", lineage: "lineage.bin", + rotationMinSdkVersion: "32", logging_parent: "bah", } @@ -1845,89 +1848,89 @@ func TestOverrideAndroidApp(t *testing.T) { `) expectedVariants := []struct { - name string - moduleName string - variantName string - apkName string - apkPath string - certFlag string - lineageFlag string - overrides []string - packageFlag string - renameResources bool - logging_parent string + name string + moduleName string + variantName string + apkName string + apkPath string + certFlag string + certSigningFlags string + overrides []string + packageFlag string + renameResources bool + logging_parent string }{ { - name: "foo", - moduleName: "foo", - variantName: "android_common", - apkPath: "out/soong/target/product/test_device/system/app/foo/foo.apk", - certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8", - lineageFlag: "", - overrides: []string{"qux"}, - packageFlag: "", - renameResources: false, - logging_parent: "", + name: "foo", + moduleName: "foo", + variantName: "android_common", + apkPath: "out/soong/target/product/test_device/system/app/foo/foo.apk", + certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8", + certSigningFlags: "", + overrides: []string{"qux"}, + packageFlag: "", + renameResources: false, + logging_parent: "", }, { - name: "foo", - moduleName: "bar", - variantName: "android_common_bar", - apkPath: "out/soong/target/product/test_device/system/app/bar/bar.apk", - certFlag: "cert/new_cert.x509.pem cert/new_cert.pk8", - lineageFlag: "--lineage lineage.bin", - overrides: []string{"qux", "foo"}, - packageFlag: "", - renameResources: false, - logging_parent: "bah", + name: "foo", + moduleName: "bar", + variantName: "android_common_bar", + apkPath: "out/soong/target/product/test_device/system/app/bar/bar.apk", + certFlag: "cert/new_cert.x509.pem cert/new_cert.pk8", + certSigningFlags: "--lineage lineage.bin --rotation-min-sdk-version 32", + overrides: []string{"qux", "foo"}, + packageFlag: "", + renameResources: false, + logging_parent: "bah", }, { - name: "foo", - moduleName: "baz", - variantName: "android_common_baz", - apkPath: "out/soong/target/product/test_device/system/app/baz/baz.apk", - certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8", - lineageFlag: "", - overrides: []string{"qux", "foo"}, - packageFlag: "org.dandroid.bp", - renameResources: true, - logging_parent: "", + name: "foo", + moduleName: "baz", + variantName: "android_common_baz", + apkPath: "out/soong/target/product/test_device/system/app/baz/baz.apk", + certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8", + certSigningFlags: "", + overrides: []string{"qux", "foo"}, + packageFlag: "org.dandroid.bp", + renameResources: true, + logging_parent: "", }, { - name: "foo", - moduleName: "baz_no_rename_resources", - variantName: "android_common_baz_no_rename_resources", - apkPath: "out/soong/target/product/test_device/system/app/baz_no_rename_resources/baz_no_rename_resources.apk", - certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8", - lineageFlag: "", - overrides: []string{"qux", "foo"}, - packageFlag: "org.dandroid.bp", - renameResources: false, - logging_parent: "", + name: "foo", + moduleName: "baz_no_rename_resources", + variantName: "android_common_baz_no_rename_resources", + apkPath: "out/soong/target/product/test_device/system/app/baz_no_rename_resources/baz_no_rename_resources.apk", + certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8", + certSigningFlags: "", + overrides: []string{"qux", "foo"}, + packageFlag: "org.dandroid.bp", + renameResources: false, + logging_parent: "", }, { - name: "foo_no_rename_resources", - moduleName: "baz_base_no_rename_resources", - variantName: "android_common_baz_base_no_rename_resources", - apkPath: "out/soong/target/product/test_device/system/app/baz_base_no_rename_resources/baz_base_no_rename_resources.apk", - certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8", - lineageFlag: "", - overrides: []string{"qux", "foo_no_rename_resources"}, - packageFlag: "org.dandroid.bp", - renameResources: false, - logging_parent: "", + name: "foo_no_rename_resources", + moduleName: "baz_base_no_rename_resources", + variantName: "android_common_baz_base_no_rename_resources", + apkPath: "out/soong/target/product/test_device/system/app/baz_base_no_rename_resources/baz_base_no_rename_resources.apk", + certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8", + certSigningFlags: "", + overrides: []string{"qux", "foo_no_rename_resources"}, + packageFlag: "org.dandroid.bp", + renameResources: false, + logging_parent: "", }, { - name: "foo_no_rename_resources", - moduleName: "baz_override_base_rename_resources", - variantName: "android_common_baz_override_base_rename_resources", - apkPath: "out/soong/target/product/test_device/system/app/baz_override_base_rename_resources/baz_override_base_rename_resources.apk", - certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8", - lineageFlag: "", - overrides: []string{"qux", "foo_no_rename_resources"}, - packageFlag: "org.dandroid.bp", - renameResources: true, - logging_parent: "", + name: "foo_no_rename_resources", + moduleName: "baz_override_base_rename_resources", + variantName: "android_common_baz_override_base_rename_resources", + apkPath: "out/soong/target/product/test_device/system/app/baz_override_base_rename_resources/baz_override_base_rename_resources.apk", + certFlag: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8", + certSigningFlags: "", + overrides: []string{"qux", "foo_no_rename_resources"}, + packageFlag: "org.dandroid.bp", + renameResources: true, + logging_parent: "", }, } for _, expected := range expectedVariants { @@ -1941,9 +1944,9 @@ func TestOverrideAndroidApp(t *testing.T) { certFlag := signapk.Args["certificates"] android.AssertStringEquals(t, "certificates flags", expected.certFlag, certFlag) - // Check the lineage flags - lineageFlag := signapk.Args["flags"] - android.AssertStringEquals(t, "signing flags", expected.lineageFlag, lineageFlag) + // Check the cert signing flags + certSigningFlags := signapk.Args["flags"] + android.AssertStringEquals(t, "cert signing flags", expected.certSigningFlags, certSigningFlags) // Check if the overrides field values are correctly aggregated. mod := variant.Module().(*AndroidApp) diff --git a/java/rro.go b/java/rro.go index 0b4d0916a..1ab7751fd 100644 --- a/java/rro.go +++ b/java/rro.go @@ -51,6 +51,9 @@ type RuntimeResourceOverlayProperties struct { // Name of the signing certificate lineage file. Lineage *string + // For overriding the --rotation-min-sdk-version property of apksig + RotationMinSdkVersion *string + // optional theme name. If specified, the overlay package will be applied // only when the ro.boot.vendor.overlay.theme system property is set to the same value. Theme *string @@ -149,7 +152,10 @@ func (r *RuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleC if lineage := String(r.properties.Lineage); lineage != "" { lineageFile = android.PathForModuleSrc(ctx, lineage) } - SignAppPackage(ctx, signed, r.aapt.exportPackage, certificates, nil, lineageFile) + + rotationMinSdkVersion := String(r.properties.RotationMinSdkVersion) + + SignAppPackage(ctx, signed, r.aapt.exportPackage, certificates, nil, lineageFile, rotationMinSdkVersion) r.certificate = certificates[0] r.outputFile = signed diff --git a/java/rro_test.go b/java/rro_test.go index 27abbe4f3..2d76a4d2f 100644 --- a/java/rro_test.go +++ b/java/rro_test.go @@ -33,6 +33,7 @@ func TestRuntimeResourceOverlay(t *testing.T) { name: "foo", certificate: "platform", lineage: "lineage.bin", + rotationMinSdkVersion: "32", product_specific: true, static_libs: ["bar"], resource_libs: ["baz"], @@ -88,13 +89,14 @@ func TestRuntimeResourceOverlay(t *testing.T) { t.Errorf("Resource lib flag %q missing in aapt2 link flags: %q", resourceLibFlag, aapt2Flags) } - // Check cert signing flag. + // Check cert signing flags. signedApk := m.Output("signed/foo.apk") - lineageFlag := signedApk.Args["flags"] - expectedLineageFlag := "--lineage lineage.bin" - if expectedLineageFlag != lineageFlag { - t.Errorf("Incorrect signing lineage flags, expected: %q, got: %q", expectedLineageFlag, lineageFlag) + actualCertSigningFlags := signedApk.Args["flags"] + expectedCertSigningFlags := "--lineage lineage.bin --rotation-min-sdk-version 32" + if expectedCertSigningFlags != actualCertSigningFlags { + t.Errorf("Incorrect cert signing flags, expected: %q, got: %q", expectedCertSigningFlags, actualCertSigningFlags) } + signingFlag := signedApk.Args["certificates"] expected := "build/make/target/product/security/platform.x509.pem build/make/target/product/security/platform.pk8" if expected != signingFlag { From fb41d46368957ecd2624b506621b3e47108d614d Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Wed, 3 Nov 2021 14:44:12 +0000 Subject: [PATCH 049/148] Make PrebuiltStubsSources support srcjar properly Initially prebuilt stub sources only supported directories as input, but support has been added for packaging them up in srcjar as well. However the build action was not updated accordingly. Add support to determine if our input is a srcjar, and if so just use it directly. Bug: 204978699 Test: m sdk (with prebuilts) Change-Id: I302cd34ebd55414d35c4f936cd563a4af89b22c6 (cherry picked from commit 86758ac94c6807c473dd895622de6efe84c1f87c) --- java/droidstubs.go | 51 +++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/java/droidstubs.go b/java/droidstubs.go index 9d383ce22..a1a8c2e7d 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -16,6 +16,7 @@ package java import ( "fmt" + "path/filepath" "strings" "github.com/google/blueprint/proptools" @@ -772,7 +773,7 @@ type PrebuiltStubsSources struct { properties PrebuiltStubsSourcesProperties - stubsSrcJar android.ModuleOutPath + stubsSrcJar android.Path } func (p *PrebuiltStubsSources) OutputFiles(tag string) (android.Paths, error) { @@ -789,35 +790,39 @@ func (d *PrebuiltStubsSources) StubsSrcJar() android.Path { } func (p *PrebuiltStubsSources) GenerateAndroidBuildActions(ctx android.ModuleContext) { - p.stubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar") - if len(p.properties.Srcs) != 1 { - ctx.PropertyErrorf("srcs", "must only specify one directory path, contains %d paths", len(p.properties.Srcs)) + ctx.PropertyErrorf("srcs", "must only specify one directory path or srcjar, contains %d paths", len(p.properties.Srcs)) return } - localSrcDir := p.properties.Srcs[0] - // Although PathForModuleSrc can return nil if either the path doesn't exist or - // the path components are invalid it won't in this case because no components - // are specified and the module directory must exist in order to get this far. - srcDir := android.PathForModuleSrc(ctx).(android.SourcePath).Join(ctx, localSrcDir) + src := p.properties.Srcs[0] + if filepath.Ext(src) == ".srcjar" { + // This is a srcjar. We can use it directly. + p.stubsSrcJar = android.PathForModuleSrc(ctx, src) + } else { + outPath := android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar") - // Glob the contents of the directory just in case the directory does not exist. - srcGlob := localSrcDir + "/**/*" - srcPaths := android.PathsForModuleSrc(ctx, []string{srcGlob}) + // This is a directory. Glob the contents just in case the directory does not exist. + srcGlob := src + "/**/*" + srcPaths := android.PathsForModuleSrc(ctx, []string{srcGlob}) - rule := android.NewRuleBuilder(pctx, ctx) - rule.Command(). - BuiltTool("soong_zip"). - Flag("-write_if_changed"). - Flag("-jar"). - FlagWithOutput("-o ", p.stubsSrcJar). - FlagWithArg("-C ", srcDir.String()). - FlagWithRspFileInputList("-r ", p.stubsSrcJar.ReplaceExtension(ctx, "rsp"), srcPaths) + // Although PathForModuleSrc can return nil if either the path doesn't exist or + // the path components are invalid it won't in this case because no components + // are specified and the module directory must exist in order to get this far. + srcDir := android.PathForModuleSrc(ctx).(android.SourcePath).Join(ctx, src) - rule.Restat() - - rule.Build("zip src", "Create srcjar from prebuilt source") + rule := android.NewRuleBuilder(pctx, ctx) + rule.Command(). + BuiltTool("soong_zip"). + Flag("-write_if_changed"). + Flag("-jar"). + FlagWithOutput("-o ", outPath). + FlagWithArg("-C ", srcDir.String()). + FlagWithRspFileInputList("-r ", outPath.ReplaceExtension(ctx, "rsp"), srcPaths) + rule.Restat() + rule.Build("zip src", "Create srcjar from prebuilt source") + p.stubsSrcJar = outPath + } } func (p *PrebuiltStubsSources) Prebuilt() *android.Prebuilt { From 79e332c02d99a79599942930f130a4d5d25c3f6d Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Tue, 9 Nov 2021 17:34:39 +0000 Subject: [PATCH 050/148] Add android.safetycenter to permission module permitted_packges Currently the permitted_packages check is per apex and not per jar. Adding android.safetycenter to the allowlist to unblock ag/16182563 Bug: 205289292 Test: TH Change-Id: I9fc315a987af937a527872f24bf73263d2c9c9f2 --- apex/apex.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apex/apex.go b/apex/apex.go index 7ac3bc8d4..b742200e0 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -3138,6 +3138,8 @@ func rModulesPackages() map[string][]string { }, "com.android.permission": []string{ "android.permission", + //TODO(b/205719989): remove, do not cherry-pick anywhere + "android.safetycenter", "android.app.role", "com.android.permission", "com.android.role", From 2c4a96375aef7570076770474b5b73341455570d Mon Sep 17 00:00:00 2001 From: Oriol Prieto Gasco Date: Thu, 14 Oct 2021 15:33:41 -0400 Subject: [PATCH 051/148] Make 'Compressible' an overridable property This is needed to allow the Android Go versions of modules (com.google.android.go.*) to select a different compression toggle than their non-Go (com.google.android.*) conterparts. go/go-updatability Bug: 203024418 Test: Preloaded go variants on wembley, booted Android. Change-Id: Ic96aff5fafb65fbd08e8a69d47c994532e27819e --- apex/apex.go | 14 +++++++------- apex/builder.go | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index eb75eb33e..09fb09687 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -135,12 +135,6 @@ type apexBundleProperties struct { // Default: true. Installable *bool - // Whether this APEX can be compressed or not. Setting this property to false means this - // APEX will never be compressed. When set to true, APEX will be compressed if other - // conditions, e.g, target device needs to support APEX compression, are also fulfilled. - // Default: true. - Compressible *bool - // If set true, VNDK libs are considered as stable libs and are not included in this APEX. // Should be only used in non-system apexes (e.g. vendor: true). Default is false. Use_vndk_as_stable *bool @@ -321,6 +315,12 @@ type overridableProperties struct { // certificate and the private key are provided from the android_app_certificate module // named "module". Certificate *string + + // Whether this APEX can be compressed or not. Setting this property to false means this + // APEX will never be compressed. When set to true, APEX will be compressed if other + // conditions, e.g., target device needs to support APEX compression, are also fulfilled. + // Default: false. + Compressible *bool } type apexBundle struct { @@ -1279,7 +1279,7 @@ func (a *apexBundle) EnableCoverageIfNeeded() {} var _ android.ApexBundleDepsInfoIntf = (*apexBundle)(nil) -// Implements android.ApexBudleDepsInfoIntf +// Implements android.ApexBundleDepsInfoIntf func (a *apexBundle) Updatable() bool { return proptools.BoolDefault(a.properties.Updatable, true) } diff --git a/apex/builder.go b/apex/builder.go index 2e21ddfa1..6ada6ff6b 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -528,8 +528,8 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { outHostBinDir := ctx.Config().HostToolPath(ctx, "").String() prebuiltSdkToolsBinDir := filepath.Join("prebuilts", "sdk", "tools", runtime.GOOS, "bin") - // Figure out if need to compress apex. - compressionEnabled := ctx.Config().CompressedApex() && proptools.BoolDefault(a.properties.Compressible, false) && !a.testApex && !ctx.Config().UnbundledBuildApps() + // Figure out if we need to compress the apex. + compressionEnabled := ctx.Config().CompressedApex() && proptools.BoolDefault(a.overridableProperties.Compressible, false) && !a.testApex && !ctx.Config().UnbundledBuildApps() if apexType == imageApex { //////////////////////////////////////////////////////////////////////////////////// // Step 2: create canned_fs_config which encodes filemode,uid,gid of each files From 655bf076401267f0ed915382075bc835a7a0be40 Mon Sep 17 00:00:00 2001 From: Edwin Date: Thu, 16 Sep 2021 16:26:52 -0700 Subject: [PATCH 052/148] Add android.hardware.drm-V1-ndk/_platform Needed when `vendor=true` and `vndk: {enabled: true,}`. Test: build Bug: 200055138 Bug: 170964303 Change-Id: Ia064edf3ef6d871ef93ead8bb10a970c47d91f5a --- cc/config/vndk.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cc/config/vndk.go b/cc/config/vndk.go index dd1cd1383..964745d80 100644 --- a/cc/config/vndk.go +++ b/cc/config/vndk.go @@ -26,6 +26,7 @@ var VndkMustUseVendorVariantList = []string{ "android.hardware.automotive.occupant_awareness-V1-ndk", "android.hardware.automotive.occupant_awareness-V1-ndk_platform", "android.hardware.automotive.occupant_awareness-ndk_platform", + "android.hardware.drm-V1-ndk", "android.hardware.gnss-V1-ndk", "android.hardware.gnss-V1-ndk_platform", "android.hardware.gnss-ndk_platform", From 2965f45751e3c098a52ccdab649fe18c690525c6 Mon Sep 17 00:00:00 2001 From: sophiez Date: Tue, 2 Nov 2021 17:58:02 -0700 Subject: [PATCH 053/148] Java APIs used by Mainline modules. Add scripts to generate java APIs used by Mainline modules. This is aosp/1879177 with fixed build error that caused by dexdeps analyzing resource only APKs which doesn't contains any .dex files. Now skip the error generates in that case in gen_java_usedby_apex.sh Test: TARGET_BUILD_APPS=com.android.adbd m dist apps_only Change-Id: Id539cbe1b7306ace69c047f95ffc02265a467511 Merged-In: Id539cbe1b7306ace69c047f95ffc02265a467511 --- apex/androidmk.go | 29 +++++++++------------ apex/apex.go | 5 ++-- apex/builder.go | 27 +++++++++++++++---- apex/testing.go | 1 + scripts/OWNERS | 2 +- scripts/gen_java_usedby_apex.sh | 46 +++++++++++++++++++++++++++++++++ 6 files changed, 85 insertions(+), 25 deletions(-) create mode 100755 scripts/gen_java_usedby_apex.sh diff --git a/apex/androidmk.go b/apex/androidmk.go index ebf08330b..ba28e3591 100644 --- a/apex/androidmk.go +++ b/apex/androidmk.go @@ -446,23 +446,18 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { fmt.Fprintf(w, dist) } - if a.apisUsedByModuleFile.String() != "" { - goal := "apps_only" - distFile := a.apisUsedByModuleFile.String() - fmt.Fprintf(w, "ifneq (,$(filter $(my_register_name),$(TARGET_BUILD_APPS)))\n"+ - " $(call dist-for-goals,%s,%s:ndk_apis_usedby_apex/$(notdir %s))\n"+ - "endif\n", - goal, distFile, distFile) - } - - if a.apisBackedByModuleFile.String() != "" { - goal := "apps_only" - distFile := a.apisBackedByModuleFile.String() - fmt.Fprintf(w, "ifneq (,$(filter $(my_register_name),$(TARGET_BUILD_APPS)))\n"+ - " $(call dist-for-goals,%s,%s:ndk_apis_backedby_apex/$(notdir %s))\n"+ - "endif\n", - goal, distFile, distFile) - } + distCoverageFiles(w, "ndk_apis_usedby_apex", a.nativeApisUsedByModuleFile.String()) + distCoverageFiles(w, "ndk_apis_usedby_apex", a.nativeApisBackedByModuleFile.String()) + distCoverageFiles(w, "java_apis_used_by_apex", a.javaApisUsedByModuleFile.String()) } }} } + +func distCoverageFiles(w io.Writer, dir string, distfile string) { + if distfile != "" { + goal := "apps_only" + fmt.Fprintf(w, "ifneq (,$(filter $(my_register_name),$(TARGET_BUILD_APPS)))\n"+ + " $(call dist-for-goals,%s,%s:%s/$(notdir %s))\n"+ + "endif\n", goal, distfile, dir, distfile) + } +} diff --git a/apex/apex.go b/apex/apex.go index a2b16f151..77b2d1300 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -413,8 +413,9 @@ type apexBundle struct { isCompressed bool // Path of API coverage generate file - apisUsedByModuleFile android.ModuleOutPath - apisBackedByModuleFile android.ModuleOutPath + nativeApisUsedByModuleFile android.ModuleOutPath + nativeApisBackedByModuleFile android.ModuleOutPath + javaApisUsedByModuleFile android.ModuleOutPath } // apexFileClass represents a type of file that can be included in APEX. diff --git a/apex/builder.go b/apex/builder.go index d2e6ad8d5..e3e06bbd0 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -67,6 +67,7 @@ func init() { pctx.HostBinToolVariable("make_f2fs", "make_f2fs") pctx.HostBinToolVariable("sload_f2fs", "sload_f2fs") pctx.HostBinToolVariable("apex_compression_tool", "apex_compression_tool") + pctx.HostBinToolVariable("dexdeps", "dexdeps") pctx.SourcePathVariable("genNdkUsedbyApexPath", "build/soong/scripts/gen_ndk_usedby_apex.sh") } @@ -696,12 +697,12 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { "readelf": "${config.ClangBin}/llvm-readelf", }, }) - a.apisUsedByModuleFile = apisUsedbyOutputFile + a.nativeApisUsedByModuleFile = apisUsedbyOutputFile - var libNames []string + var nativeLibNames []string for _, f := range a.filesInfo { if f.class == nativeSharedLib { - libNames = append(libNames, f.stem()) + nativeLibNames = append(nativeLibNames, f.stem()) } } apisBackedbyOutputFile := android.PathForModuleOut(ctx, a.Name()+"_backing.txt") @@ -711,9 +712,25 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { Tool(android.PathForSource(ctx, "build/soong/scripts/gen_ndk_backedby_apex.sh")). Output(apisBackedbyOutputFile). Input(ndkLibraryList). - Flags(libNames) + Flags(nativeLibNames) rule.Build("ndk_backedby_list", "Generate API libraries backed by Apex") - a.apisBackedByModuleFile = apisBackedbyOutputFile + a.nativeApisBackedByModuleFile = apisBackedbyOutputFile + + var javaLibOrApkPath []android.Path + for _, f := range a.filesInfo { + if f.class == javaSharedLib || f.class == app { + javaLibOrApkPath = append(javaLibOrApkPath, f.builtFile) + } + } + javaApiUsedbyOutputFile := android.PathForModuleOut(ctx, a.Name()+"_using.xml") + javaUsedByRule := android.NewRuleBuilder(pctx, ctx) + javaUsedByRule.Command(). + Tool(android.PathForSource(ctx, "build/soong/scripts/gen_java_usedby_apex.sh")). + BuiltTool("dexdeps"). + Output(javaApiUsedbyOutputFile). + Inputs(javaLibOrApkPath) + javaUsedByRule.Build("java_usedby_list", "Generate Java APIs used by Apex") + a.javaApisUsedByModuleFile = javaApiUsedbyOutputFile bundleConfig := a.buildBundleConfig(ctx) diff --git a/apex/testing.go b/apex/testing.go index 69bd73e5d..337c86210 100644 --- a/apex/testing.go +++ b/apex/testing.go @@ -24,6 +24,7 @@ var PrepareForTestWithApexBuildComponents = android.GroupFixturePreparers( android.MockFS{ // Needed by apex. "system/core/rootdir/etc/public.libraries.android.txt": nil, + "build/soong/scripts/gen_java_usedby_apex.sh": nil, "build/soong/scripts/gen_ndk_backedby_apex.sh": nil, // Needed by prebuilt_apex. "build/soong/scripts/unpack-prebuilt-apex.sh": nil, diff --git a/scripts/OWNERS b/scripts/OWNERS index 2b9c2ded9..573134ed8 100644 --- a/scripts/OWNERS +++ b/scripts/OWNERS @@ -3,4 +3,4 @@ per-file build-mainline-modules.sh = ngeoffray@google.com,paulduffin@google.com, per-file build-aml-prebuilts.sh = ngeoffray@google.com,paulduffin@google.com,mast@google.com per-file construct_context.py = ngeoffray@google.com,calin@google.com,mathieuc@google.com,skvadrik@google.com per-file conv_linker_config.py = kiyoungkim@google.com, jiyong@google.com, jooyung@google.com -per-file gen_ndk*.sh = sophiez@google.com, allenhair@google.com +per-file gen_ndk*.sh,gen_java*.sh = sophiez@google.com, allenhair@google.com \ No newline at end of file diff --git a/scripts/gen_java_usedby_apex.sh b/scripts/gen_java_usedby_apex.sh new file mode 100755 index 000000000..251d7aa5f --- /dev/null +++ b/scripts/gen_java_usedby_apex.sh @@ -0,0 +1,46 @@ +#!/bin/bash -e + +# Copyright 2020 Google Inc. All rights reserved. +# +# 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. + +printHelp() { + echo "**************************** Usage Instructions ****************************" + echo "This script is used to generate the Mainline modules used-by Java symbols." + echo "" + echo "To run this script use: ./gen_java_usedby_apex.sh \$BINARY_DEXDEPS_PATH \$OUTPUT_FILE_PATH \$JAR_AND_APK_LIST" + echo "For example: If all jar and apk files are '/myJar.jar /myApk.apk' and output write to /myModule.txt then the command would be:" + echo "./gen_java_usedby_apex.sh \$BINARY_DEXDEPS_PATH /myModule.txt /myJar.jar /myApk.apk" +} + +genUsedByList() { + dexdeps="$1" + shift + out="$1" + shift + rm -f "$out" + touch "$out" + for x in "$@"; do + "$dexdeps" "$x" >> "$out" || true + done +} + +if [[ "$1" == "help" ]] +then + printHelp +elif [[ "$#" -lt 2 ]] +then + echo "Wrong argument length. Expecting at least 2 argument representing dexdeps path, output path, followed by a list of jar or apk files in the Mainline module." +else + genUsedByList "$@" +fi \ No newline at end of file From 3f6bbd9d56dd05dd2699f7ab88455e1f782e0f77 Mon Sep 17 00:00:00 2001 From: satayev Date: Wed, 1 Dec 2021 18:24:09 +0000 Subject: [PATCH 054/148] Use textproto format for classpaths.proto generation. Test: presubmit Change-Id: I3fea94153939f05329f02091ca4fa838ee9df93f Merged-In: I3fea94153939f05329f02091ca4fa838ee9df93f (cherry picked from commit 48dae67a76b82a5da77c762e5a9c1079a15d93f9) --- java/classpath_fragment.go | 46 ++++++++++---------------------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go index 92e01a2df..7eadfe6c3 100644 --- a/java/classpath_fragment.go +++ b/java/classpath_fragment.go @@ -157,15 +157,15 @@ func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.M c.outputFilepath = android.PathForModuleOut(ctx, outputFilename).OutputPath c.installDirPath = android.PathForModuleInstall(ctx, "etc", "classpaths") - generatedJson := android.PathForModuleOut(ctx, outputFilename+".json") - writeClasspathsJson(ctx, generatedJson, jars) + generatedTextproto := android.PathForModuleOut(ctx, outputFilename+".textproto") + writeClasspathsTextproto(ctx, generatedTextproto, jars) rule := android.NewRuleBuilder(pctx, ctx) rule.Command(). BuiltTool("conv_classpaths_proto"). Flag("encode"). - Flag("--format=json"). - FlagWithInput("--input=", generatedJson). + Flag("--format=textproto"). + FlagWithInput("--input=", generatedTextproto). FlagWithOutput("--output=", c.outputFilepath) rule.Build("classpath_fragment", "Compiling "+c.outputFilepath.String()) @@ -180,39 +180,17 @@ func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.M ctx.SetProvider(ClasspathFragmentProtoContentInfoProvider, classpathProtoInfo) } -func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath, jars []classpathJar) { +func writeClasspathsTextproto(ctx android.ModuleContext, output android.WritablePath, jars []classpathJar) { var content strings.Builder - fmt.Fprintf(&content, "{\n") - fmt.Fprintf(&content, "\"jars\": [\n") - for idx, jar := range jars { - fmt.Fprintf(&content, "{\n") - - fmt.Fprintf(&content, "\"path\": \"%s\",\n", jar.path) - fmt.Fprintf(&content, "\"classpath\": \"%s\"\n", jar.classpath) - - if jar.minSdkVersion != "" { - fmt.Fprintf(&content, ",\n") - fmt.Fprintf(&content, "\"minSdkVersion\": \"%s\"\n", jar.minSdkVersion) - } else { - fmt.Fprintf(&content, "\n") - } - - if jar.maxSdkVersion != "" { - fmt.Fprintf(&content, ",\n") - fmt.Fprintf(&content, "\"maxSdkVersion\": \"%s\"\n", jar.maxSdkVersion) - } else { - fmt.Fprintf(&content, "\n") - } - - if idx < len(jars)-1 { - fmt.Fprintf(&content, "},\n") - } else { - fmt.Fprintf(&content, "}\n") - } + for _, jar := range jars { + fmt.Fprintf(&content, "jars {\n") + fmt.Fprintf(&content, "path: \"%s\"\n", jar.path) + fmt.Fprintf(&content, "classpath: %s\n", jar.classpath) + fmt.Fprintf(&content, "min_sdk_version: \"%s\"\n", jar.minSdkVersion) + fmt.Fprintf(&content, "max_sdk_version: \"%s\"\n", jar.maxSdkVersion) + fmt.Fprintf(&content, "}\n") } - fmt.Fprintf(&content, "]\n") - fmt.Fprintf(&content, "}\n") android.WriteFileRule(ctx, output, content.String()) } From 747d1066bdeda46d04a8faec68a0d7d42d412b21 Mon Sep 17 00:00:00 2001 From: satayev Date: Tue, 30 Nov 2021 12:33:55 +0000 Subject: [PATCH 055/148] Propagate min and max sdk versions to classpaths.proto configs. These attributed define a range for dessert releases where the jars should be active, and included in corresponding CLASSPATH varibles by derive_classpath. Bug: 190818041 Test: presubmit Change-Id: Ieb9aef29657ad0694d48a63019f93faca2678252 Merged-In: Ieb9aef29657ad0694d48a63019f93faca2678252 (cherry picked from commit cca4ab762eab320fb9beaad61a51969e16127833) --- android/config.go | 10 +++++++ java/classpath_fragment.go | 49 +++++++++++++++++++++++++++++----- java/platform_bootclasspath.go | 1 - 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/android/config.go b/android/config.go index 61383e762..8e9a0a2e6 100644 --- a/android/config.go +++ b/android/config.go @@ -698,6 +698,16 @@ func (c *config) PreviewApiLevels() []ApiLevel { return levels } +func (c *config) LatestPreviewApiLevel() ApiLevel { + level := NoneApiLevel + for _, l := range c.PreviewApiLevels() { + if l.GreaterThan(level) { + level = l + } + } + return level +} + func (c *config) AllSupportedApiLevels() []ApiLevel { var levels []ApiLevel levels = append(levels, c.FinalApiLevels()...) diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go index f63d81d6e..92e01a2df 100644 --- a/java/classpath_fragment.go +++ b/java/classpath_fragment.go @@ -84,11 +84,10 @@ func initClasspathFragment(c classpathFragment, classpathType classpathType) { // Matches definition of Jar in packages/modules/SdkExtensions/proto/classpaths.proto type classpathJar struct { - path string - classpath classpathType - // TODO(satayev): propagate min/max sdk versions for the jars - minSdkVersion int32 - maxSdkVersion int32 + path string + classpath classpathType + minSdkVersion string + maxSdkVersion string } // gatherPossibleApexModuleNamesAndStems returns a set of module and stem names from the @@ -120,10 +119,32 @@ func configuredJarListToClasspathJars(ctx android.ModuleContext, configuredJars jars := make([]classpathJar, 0, len(paths)*len(classpaths)) for i := 0; i < len(paths); i++ { for _, classpathType := range classpaths { - jars = append(jars, classpathJar{ + jar := classpathJar{ classpath: classpathType, path: paths[i], + } + ctx.VisitDirectDepsIf(func(m android.Module) bool { + return m.Name() == configuredJars.Jar(i) + }, func(m android.Module) { + if s, ok := m.(*SdkLibrary); ok { + // TODO(208456999): instead of mapping "current" to latest, min_sdk_version should never be set to "current" + if s.minSdkVersion.Specified() { + if s.minSdkVersion.ApiLevel.IsCurrent() { + jar.minSdkVersion = ctx.Config().LatestPreviewApiLevel().String() + } else { + jar.minSdkVersion = s.minSdkVersion.ApiLevel.String() + } + } + if s.maxSdkVersion.Specified() { + if s.maxSdkVersion.ApiLevel.IsCurrent() { + jar.maxSdkVersion = ctx.Config().LatestPreviewApiLevel().String() + } else { + jar.maxSdkVersion = s.maxSdkVersion.ApiLevel.String() + } + } + } }) + jars = append(jars, jar) } } return jars @@ -161,6 +182,7 @@ func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.M func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath, jars []classpathJar) { var content strings.Builder + fmt.Fprintf(&content, "{\n") fmt.Fprintf(&content, "\"jars\": [\n") for idx, jar := range jars { @@ -169,6 +191,20 @@ func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath, fmt.Fprintf(&content, "\"path\": \"%s\",\n", jar.path) fmt.Fprintf(&content, "\"classpath\": \"%s\"\n", jar.classpath) + if jar.minSdkVersion != "" { + fmt.Fprintf(&content, ",\n") + fmt.Fprintf(&content, "\"minSdkVersion\": \"%s\"\n", jar.minSdkVersion) + } else { + fmt.Fprintf(&content, "\n") + } + + if jar.maxSdkVersion != "" { + fmt.Fprintf(&content, ",\n") + fmt.Fprintf(&content, "\"maxSdkVersion\": \"%s\"\n", jar.maxSdkVersion) + } else { + fmt.Fprintf(&content, "\n") + } + if idx < len(jars)-1 { fmt.Fprintf(&content, "},\n") } else { @@ -177,6 +213,7 @@ func writeClasspathsJson(ctx android.ModuleContext, output android.WritablePath, } fmt.Fprintf(&content, "]\n") fmt.Fprintf(&content, "}\n") + android.WriteFileRule(ctx, output, content.String()) } diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index cf266b80b..ca87f92fd 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -68,7 +68,6 @@ type platformBootclasspathProperties struct { func platformBootclasspathFactory() android.SingletonModule { m := &platformBootclasspathModule{} m.AddProperties(&m.properties) - // TODO(satayev): split apex jars into separate configs. initClasspathFragment(m, BOOTCLASSPATH) android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) return m From 477a7baa79424c093347ca14f57b606bf540dc14 Mon Sep 17 00:00:00 2001 From: satayev Date: Fri, 3 Dec 2021 18:58:32 +0000 Subject: [PATCH 056/148] Add MinSdkVersion(ctx) method to ModuleWithMinSdkVersionCheck interface. Bug: 205923322 Test: presubmit Change-Id: I469d655823e12a14bc0abaeb544a5dd2a6d3622f Merged-In: I469d655823e12a14bc0abaeb544a5dd2a6d3622f (cherry picked from commit ad99149a629a01f0fda63e3efe282529205cf320) --- android/apex.go | 1 + apex/apex.go | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/android/apex.go b/android/apex.go index aa4b5a0a8..bf1f36b99 100644 --- a/android/apex.go +++ b/android/apex.go @@ -908,6 +908,7 @@ type WalkPayloadDepsFunc func(ctx ModuleContext, do PayloadDepsCallback) // ModuleWithMinSdkVersionCheck represents a module that implements min_sdk_version checks type ModuleWithMinSdkVersionCheck interface { Module + MinSdkVersion(ctx EarlyModuleContext) SdkSpec CheckMinSdkVersion(ctx ModuleContext) } diff --git a/apex/apex.go b/apex/apex.go index 7dec2a156..a0c29ed92 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -2245,6 +2245,8 @@ func overrideApexFactory() android.Module { // // TODO(jiyong): move these checks to a separate go file. +var _ android.ModuleWithMinSdkVersionCheck = (*apexBundle)(nil) + // Entures that min_sdk_version of the included modules are equal or less than the min_sdk_version // of this apexBundle. func (a *apexBundle) CheckMinSdkVersion(ctx android.ModuleContext) { @@ -2256,7 +2258,15 @@ func (a *apexBundle) CheckMinSdkVersion(ctx android.ModuleContext) { android.CheckMinSdkVersion(ctx, minSdkVersion, a.WalkPayloadDeps) } -func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) android.ApiLevel { +func (a *apexBundle) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { + return android.SdkSpec{ + Kind: android.SdkNone, + ApiLevel: a.minSdkVersion(ctx), + Raw: String(a.properties.Min_sdk_version), + } +} + +func (a *apexBundle) minSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel { ver := proptools.String(a.properties.Min_sdk_version) if ver == "" { return android.NoneApiLevel From 531330e5ab354346a416e2bf5bfc6c81e0bdf886 Mon Sep 17 00:00:00 2001 From: satayev Date: Mon, 6 Dec 2021 11:40:46 +0000 Subject: [PATCH 057/148] Perform CheckMinSdkVersion for java_sdk_library. In a follow up, apex would expect that any module that implements ModuleWithMinSdkVersionCheck to have performed appropate checks on min_sdk_version, to allow relaxing some of the existing conditions. This change moves the responsibility of checking min_sdk_version of java_sdk_library to java_sdk_library itself. Bug: 205923322 Test: presubmit Change-Id: I79b5a1fc34098fff60221e416db6e6e69e01f531 Merged-In: I79b5a1fc34098fff60221e416db6e6e69e01f531 (cherry picked from commit 8f088b09d87caf20468750a05351474c7bf72322) --- java/sdk_library.go | 22 ++++++++++- java/sdk_library_test.go | 84 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 2 deletions(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index 751a71d0c..dbb97c8e6 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1122,6 +1122,20 @@ func (module *SdkLibrary) getGeneratedApiScopes(ctx android.EarlyModuleContext) return generatedScopes } +func (module *SdkLibrary) CheckMinSdkVersion(ctx android.ModuleContext) { + android.CheckMinSdkVersion(ctx, module.MinSdkVersion(ctx).ApiLevel, func(c android.ModuleContext, do android.PayloadDepsCallback) { + ctx.WalkDeps(func(child android.Module, parent android.Module) bool { + isExternal := !module.depIsInSameApex(ctx, child) + if am, ok := child.(android.ApexModule); ok { + if !do(ctx, parent, am, isExternal) { + return false + } + } + return !isExternal + }) + }) +} + type sdkLibraryComponentTag struct { blueprint.BaseDependencyTag name string @@ -1207,6 +1221,10 @@ func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) { } func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { + if proptools.String(module.deviceProperties.Min_sdk_version) != "" { + module.CheckMinSdkVersion(ctx) + } + module.generateCommonBuildActions(ctx) // Only build an implementation library if required. @@ -2466,12 +2484,12 @@ func (module *sdkLibraryXml) GenerateAndroidBuildActions(ctx android.ModuleConte func (module *sdkLibraryXml) AndroidMkEntries() []android.AndroidMkEntries { if module.hideApexVariantFromMake { - return []android.AndroidMkEntries{android.AndroidMkEntries{ + return []android.AndroidMkEntries{{ Disabled: true, }} } - return []android.AndroidMkEntries{android.AndroidMkEntries{ + return []android.AndroidMkEntries{{ Class: "ETC", OutputFile: android.OptionalPathForPath(module.outputFilePath), ExtraEntries: []android.AndroidMkExtraEntriesFunc{ diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 3cf4987e1..0c7b79853 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -958,3 +958,87 @@ func TestJavaSdkLibraryDist(t *testing.T) { }) } } + +func TestSdkLibrary_CheckMinSdkVersion(t *testing.T) { + preparer := android.GroupFixturePreparers( + PrepareForTestWithJavaBuildComponents, + PrepareForTestWithJavaDefaultModules, + PrepareForTestWithJavaSdkLibraryFiles, + ) + + preparer.RunTestWithBp(t, ` + java_sdk_library { + name: "sdklib", + srcs: ["a.java"], + static_libs: ["util"], + min_sdk_version: "30", + unsafe_ignore_missing_latest_api: true, + } + + java_library { + name: "util", + srcs: ["a.java"], + min_sdk_version: "30", + } + `) + + preparer. + RunTestWithBp(t, ` + java_sdk_library { + name: "sdklib", + srcs: ["a.java"], + libs: ["util"], + impl_only_libs: ["util"], + stub_only_libs: ["util"], + stub_only_static_libs: ["util"], + min_sdk_version: "30", + unsafe_ignore_missing_latest_api: true, + } + + java_library { + name: "util", + srcs: ["a.java"], + } + `) + + preparer.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "util".*should support min_sdk_version\(30\)`)). + RunTestWithBp(t, ` + java_sdk_library { + name: "sdklib", + srcs: ["a.java"], + static_libs: ["util"], + min_sdk_version: "30", + unsafe_ignore_missing_latest_api: true, + } + + java_library { + name: "util", + srcs: ["a.java"], + min_sdk_version: "31", + } + `) + + preparer.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "another_util".*should support min_sdk_version\(30\)`)). + RunTestWithBp(t, ` + java_sdk_library { + name: "sdklib", + srcs: ["a.java"], + static_libs: ["util"], + min_sdk_version: "30", + unsafe_ignore_missing_latest_api: true, + } + + java_library { + name: "util", + srcs: ["a.java"], + static_libs: ["another_util"], + min_sdk_version: "30", + } + + java_library { + name: "another_util", + srcs: ["a.java"], + min_sdk_version: "31", + } + `) +} From e9b63a8ae0e6bc736dc8f69c264f57491ac28b41 Mon Sep 17 00:00:00 2001 From: satayev Date: Mon, 29 Nov 2021 17:25:52 +0000 Subject: [PATCH 058/148] Introduce max_sdk_version device property. Artifacts that go into apexes should only be active on certain SDK versions. There is now a need to upper bound the range to support expressiong statements like "this jar should only run on platforms 30-31". Bug: 190818041 Test: presubmit Change-Id: I6985ebb671841cdd9f0f37f916267ac5ed76e4f4 Merged-In: I6985ebb671841cdd9f0f37f916267ac5ed76e4f4 (cherry picked from commit 0a420e771a2201c99f570cf48bd09a6bd837cce2) --- java/base.go | 12 ++++++++++++ java/java.go | 1 + 2 files changed, 13 insertions(+) diff --git a/java/base.go b/java/base.go index 5d2927ac9..4caca316d 100644 --- a/java/base.go +++ b/java/base.go @@ -185,6 +185,10 @@ type DeviceProperties struct { // Defaults to sdk_version if not set. Min_sdk_version *string + // if not blank, set the maximum version of the sdk that the compiled artifacts will run against. + // Defaults to empty string "". See sdk_version for possible values. + Max_sdk_version *string + // if not blank, set the targetSdkVersion in the AndroidManifest.xml. // Defaults to sdk_version if not set. Target_sdk_version *string @@ -367,6 +371,7 @@ type Module struct { sdkVersion android.SdkSpec minSdkVersion android.SdkSpec + maxSdkVersion android.SdkSpec } func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error { @@ -524,6 +529,13 @@ func (j *Module) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { return j.SdkVersion(ctx) } +func (j *Module) MaxSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { + maxSdkVersion := proptools.StringDefault(j.deviceProperties.Max_sdk_version, "") + // SdkSpecFrom returns SdkSpecPrivate for this, which may be confusing. + // TODO(b/208456999): ideally MaxSdkVersion should be an ApiLevel and not SdkSpec. + return android.SdkSpecFrom(ctx, maxSdkVersion) +} + func (j *Module) MinSdkVersionString() string { return j.minSdkVersion.Raw } diff --git a/java/java.go b/java/java.go index 02e06e0c0..a61ddf426 100644 --- a/java/java.go +++ b/java/java.go @@ -487,6 +487,7 @@ func shouldUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter) bo func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { j.sdkVersion = j.SdkVersion(ctx) j.minSdkVersion = j.MinSdkVersion(ctx) + j.maxSdkVersion = j.MaxSdkVersion(ctx) apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo) if !apexInfo.IsForPlatform() { From fba70bc07f69554480f2adf9797d586d482f13ce Mon Sep 17 00:00:00 2001 From: satayev Date: Wed, 1 Dec 2021 17:39:48 +0000 Subject: [PATCH 059/148] Test SdkSpecForm. Bug: 190818041 Test: presubmit Change-Id: Ib8cd891f03537712d709ed063dd76dee55221118 Merged-In: Ib8cd891f03537712d709ed063dd76dee55221118 (cherry picked from commit 0ee2f913ef7ab1948e3225adf6ae1befaf0820dd) --- android/Android.bp | 1 + android/api_levels.go | 16 ++++--- android/sdk_version.go | 8 +++- android/sdk_version_test.go | 89 +++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 android/sdk_version_test.go diff --git a/android/Android.bp b/android/Android.bp index 5d0f2b941..36b2670d5 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -110,6 +110,7 @@ bootstrap_go_package { "paths_test.go", "prebuilt_test.go", "rule_builder_test.go", + "sdk_version_test.go", "singleton_module_test.go", "soong_config_modules_test.go", "util_test.go", diff --git a/android/api_levels.go b/android/api_levels.go index 93583bc07..fe3f41753 100644 --- a/android/api_levels.go +++ b/android/api_levels.go @@ -188,8 +188,8 @@ var FirstNonLibAndroidSupportVersion = uncheckedFinalApiLevel(21) // * "30" -> "30" // * "R" -> "30" // * "S" -> "S" -func ReplaceFinalizedCodenames(ctx PathContext, raw string) string { - num, ok := getFinalCodenamesMap(ctx.Config())[raw] +func ReplaceFinalizedCodenames(config Config, raw string) string { + num, ok := getFinalCodenamesMap(config)[raw] if !ok { return raw } @@ -197,7 +197,7 @@ func ReplaceFinalizedCodenames(ctx PathContext, raw string) string { return strconv.Itoa(num) } -// Converts the given string `raw` to an ApiLevel, possibly returning an error. +// ApiLevelFromUser converts the given string `raw` to an ApiLevel, possibly returning an error. // // `raw` must be non-empty. Passing an empty string results in a panic. // @@ -212,6 +212,12 @@ func ReplaceFinalizedCodenames(ctx PathContext, raw string) string { // Inputs that are not "current", known previews, or convertible to an integer // will return an error. func ApiLevelFromUser(ctx PathContext, raw string) (ApiLevel, error) { + return ApiLevelFromUserWithConfig(ctx.Config(), raw) +} + +// ApiLevelFromUserWithConfig implements ApiLevelFromUser, see comments for +// ApiLevelFromUser for more details. +func ApiLevelFromUserWithConfig(config Config, raw string) (ApiLevel, error) { if raw == "" { panic("API level string must be non-empty") } @@ -220,13 +226,13 @@ func ApiLevelFromUser(ctx PathContext, raw string) (ApiLevel, error) { return FutureApiLevel, nil } - for _, preview := range ctx.Config().PreviewApiLevels() { + for _, preview := range config.PreviewApiLevels() { if raw == preview.String() { return preview, nil } } - canonical := ReplaceFinalizedCodenames(ctx, raw) + canonical := ReplaceFinalizedCodenames(config, raw) asInt, err := strconv.Atoi(canonical) if err != nil { return NoneApiLevel, fmt.Errorf("%q could not be parsed as an integer and is not a recognized codename", canonical) diff --git a/android/sdk_version.go b/android/sdk_version.go index c6c75a399..49e607502 100644 --- a/android/sdk_version.go +++ b/android/sdk_version.go @@ -117,7 +117,7 @@ func (s SdkSpec) Stable() bool { return false } -// PrebuiltSdkAvailableForUnbundledBuilt tells whether this SdkSpec can have a prebuilt SDK +// PrebuiltSdkAvailableForUnbundledBuild tells whether this SdkSpec can have a prebuilt SDK // that can be used for unbundled builds. func (s SdkSpec) PrebuiltSdkAvailableForUnbundledBuild() bool { // "", "none", and "core_platform" are not available for unbundled build @@ -212,6 +212,10 @@ var ( ) func SdkSpecFrom(ctx EarlyModuleContext, str string) SdkSpec { + return SdkSpecFromWithConfig(ctx.Config(), str) +} + +func SdkSpecFromWithConfig(config Config, str string) SdkSpec { switch str { // special cases first case "": @@ -252,7 +256,7 @@ func SdkSpecFrom(ctx EarlyModuleContext, str string) SdkSpec { return SdkSpec{SdkInvalid, NoneApiLevel, str} } - apiLevel, err := ApiLevelFromUser(ctx, versionString) + apiLevel, err := ApiLevelFromUserWithConfig(config, versionString) if err != nil { return SdkSpec{SdkInvalid, apiLevel, str} } diff --git a/android/sdk_version_test.go b/android/sdk_version_test.go new file mode 100644 index 000000000..8924fd295 --- /dev/null +++ b/android/sdk_version_test.go @@ -0,0 +1,89 @@ +// Copyright 2015 Google Inc. All rights reserved. +// +// 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. + +package android + +import ( + "testing" +) + +func TestSdkSpecFrom(t *testing.T) { + testCases := []struct { + input string + expected string + }{ + { + input: "", + expected: "private_current", + }, + { + input: "none", + expected: "none_(no version)", + }, + { + input: "core_platform", + expected: "core_platform_current", + }, + { + input: "_", + expected: "invalid_(no version)", + }, + { + input: "_31", + expected: "invalid_(no version)", + }, + { + input: "system_R", + expected: "system_30", + }, + { + input: "test_31", + expected: "test_31", + }, + { + input: "module_current", + expected: "module-lib_current", + }, + { + input: "31", + expected: "public_31", + }, + { + input: "S", + expected: "public_31", + }, + { + input: "current", + expected: "public_current", + }, + { + input: "Tiramisu", + expected: "public_Tiramisu", + }, + } + + config := NullConfig("") + + config.productVariables = productVariables{ + Platform_sdk_version: intPtr(31), + Platform_sdk_codename: stringPtr("Tiramisu"), + Platform_version_active_codenames: []string{"Tiramisu"}, + } + + for _, tc := range testCases { + if got := SdkSpecFromWithConfig(config, tc.input).String(); tc.expected != got { + t.Errorf("Expected %v, got %v", tc.expected, got) + } + } +} From cb0977f67e48f2058a184132a57c7c90954a998e Mon Sep 17 00:00:00 2001 From: satayev Date: Thu, 2 Dec 2021 13:59:35 +0000 Subject: [PATCH 060/148] Add ModuleWithMinSdkVersionCheck type. This is to help following refactor for individual modules to have their own version of checking where needed. For example, apk in apex may want to enforce it's own version of CheckMinSdkVersion. Bug: 205923322 Test: presubmit Change-Id: Ia2fad6c52af39e21f65385bcb283f1e3adab5548 Merged-In: Ia2fad6c52af39e21f65385bcb283f1e3adab5548 (cherry picked from commit b3fd41146571effc446efa2d45b4c737cd694823) --- android/apex.go | 11 ++++++----- apex/apex.go | 6 +++--- java/app.go | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/android/apex.go b/android/apex.go index 4618fe97e..aa4b5a0a8 100644 --- a/android/apex.go +++ b/android/apex.go @@ -903,16 +903,17 @@ var minSdkVersionAllowlist = func(apiMap map[string]int) map[string]ApiLevel { // // Return true if the `to` module should be visited, false otherwise. type PayloadDepsCallback func(ctx ModuleContext, from blueprint.Module, to ApexModule, externalDep bool) bool +type WalkPayloadDepsFunc func(ctx ModuleContext, do PayloadDepsCallback) -// UpdatableModule represents updatable APEX/APK -type UpdatableModule interface { +// ModuleWithMinSdkVersionCheck represents a module that implements min_sdk_version checks +type ModuleWithMinSdkVersionCheck interface { Module - WalkPayloadDeps(ctx ModuleContext, do PayloadDepsCallback) + CheckMinSdkVersion(ctx ModuleContext) } // CheckMinSdkVersion checks if every dependency of an updatable module sets min_sdk_version // accordingly -func CheckMinSdkVersion(m UpdatableModule, ctx ModuleContext, minSdkVersion ApiLevel) { +func CheckMinSdkVersion(ctx ModuleContext, minSdkVersion ApiLevel, walk WalkPayloadDepsFunc) { // do not enforce min_sdk_version for host if ctx.Host() { return @@ -928,7 +929,7 @@ func CheckMinSdkVersion(m UpdatableModule, ctx ModuleContext, minSdkVersion ApiL return } - m.WalkPayloadDeps(ctx, func(ctx ModuleContext, from blueprint.Module, to ApexModule, externalDep bool) bool { + walk(ctx, func(ctx ModuleContext, from blueprint.Module, to ApexModule, externalDep bool) bool { if externalDep { // external deps are outside the payload boundary, which is "stable" // interface. We don't have to check min_sdk_version for external diff --git a/apex/apex.go b/apex/apex.go index a2b16f151..7dec2a156 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1631,7 +1631,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { // 1) do some validity checks such as apex_available, min_sdk_version, etc. a.checkApexAvailability(ctx) a.checkUpdatable(ctx) - a.checkMinSdkVersion(ctx) + a.CheckMinSdkVersion(ctx) a.checkStaticLinkingToStubLibraries(ctx) if len(a.properties.Tests) > 0 && !a.testApex { ctx.PropertyErrorf("tests", "property allowed only in apex_test module type") @@ -2247,13 +2247,13 @@ func overrideApexFactory() android.Module { // Entures that min_sdk_version of the included modules are equal or less than the min_sdk_version // of this apexBundle. -func (a *apexBundle) checkMinSdkVersion(ctx android.ModuleContext) { +func (a *apexBundle) CheckMinSdkVersion(ctx android.ModuleContext) { if a.testApex || a.vndkApex { return } // apexBundle::minSdkVersion reports its own errors. minSdkVersion := a.minSdkVersion(ctx) - android.CheckMinSdkVersion(a, ctx, minSdkVersion) + android.CheckMinSdkVersion(ctx, minSdkVersion, a.WalkPayloadDeps) } func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) android.ApiLevel { diff --git a/java/app.go b/java/app.go index fc1ace07b..06967690b 100755 --- a/java/app.go +++ b/java/app.go @@ -288,7 +288,7 @@ func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) { if minSdkVersion, err := a.MinSdkVersion(ctx).EffectiveVersion(ctx); err == nil { a.checkJniLibsSdkVersion(ctx, minSdkVersion) - android.CheckMinSdkVersion(a, ctx, minSdkVersion) + android.CheckMinSdkVersion(ctx, minSdkVersion, a.WalkPayloadDeps) } else { ctx.PropertyErrorf("min_sdk_version", "%s", err.Error()) } From 812683ec25bfa91c43eb00f551aeed88f97f7b65 Mon Sep 17 00:00:00 2001 From: satayev Date: Mon, 6 Dec 2021 11:42:40 +0000 Subject: [PATCH 061/148] Allow java_sdk_library in an APEX to have higher min_sdk_version. Inidividual boot or system server jars may have higher min_sdk_version than the contianing apex, since the runtime respects the values of min/max_sdk_version; e.g. runtime would not load a boot jar with higher min_sdk_version. This allows shipping new boot jars via apexes that target older platforms. Bug: 190818041 Test: presubmit Change-Id: I08ec0b4463a17bc8265b948fe09da55eb4e52ac3 Merged-In: I08ec0b4463a17bc8265b948fe09da55eb4e52ac3 (cherry picked from commit 758968a70081ee5d299452008e25cd75eead742b) --- android/apex.go | 8 ++ apex/apex_test.go | 178 +++++++++++++++++++++++++++++++++++++++++++ dexpreopt/testing.go | 8 ++ java/base.go | 3 +- java/sdk_library.go | 2 + 5 files changed, 197 insertions(+), 2 deletions(-) diff --git a/android/apex.go b/android/apex.go index bf1f36b99..b5d96e4ae 100644 --- a/android/apex.go +++ b/android/apex.go @@ -940,6 +940,14 @@ func CheckMinSdkVersion(ctx ModuleContext, minSdkVersion ApiLevel, walk WalkPayl if am, ok := from.(DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) { return false } + if m, ok := to.(ModuleWithMinSdkVersionCheck); ok { + // This dependency performs its own min_sdk_version check, just make sure it sets min_sdk_version + // to trigger the check. + if !m.MinSdkVersion(ctx).Specified() { + ctx.OtherModuleErrorf(m, "must set min_sdk_version") + } + return false + } if err := to.ShouldSupportSdkVersion(ctx, minSdkVersion); err != nil { toName := ctx.OtherModuleName(to) if ver, ok := minSdkVersionAllowlist[toName]; !ok || ver.GreaterThan(minSdkVersion) { diff --git a/apex/apex_test.go b/apex/apex_test.go index 12317a275..06d89fd6f 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -7742,6 +7742,184 @@ func TestApexJavaCoverage(t *testing.T) { } } +func TestSdkLibraryCanHaveHigherMinSdkVersion(t *testing.T) { + preparer := android.GroupFixturePreparers( + PrepareForTestWithApexBuildComponents, + prepareForTestWithMyapex, + java.PrepareForTestWithJavaSdkLibraryFiles, + java.PrepareForTestWithJavaDefaultModules, + android.PrepareForTestWithAndroidBuildComponents, + dexpreopt.FixtureSetApexBootJars("myapex:mybootclasspathlib"), + dexpreopt.FixtureSetApexSystemServerJars("myapex:mysystemserverclasspathlib"), + ) + + // Test java_sdk_library in bootclasspath_fragment may define higher min_sdk_version than the apex + t.Run("bootclasspath_fragment jar has higher min_sdk_version than apex", func(t *testing.T) { + preparer.RunTestWithBp(t, ` + apex { + name: "myapex", + key: "myapex.key", + bootclasspath_fragments: ["mybootclasspathfragment"], + min_sdk_version: "30", + updatable: false, + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + bootclasspath_fragment { + name: "mybootclasspathfragment", + contents: ["mybootclasspathlib"], + apex_available: ["myapex"], + } + + java_sdk_library { + name: "mybootclasspathlib", + srcs: ["mybootclasspathlib.java"], + apex_available: ["myapex"], + compile_dex: true, + unsafe_ignore_missing_latest_api: true, + min_sdk_version: "31", + static_libs: ["util"], + } + + java_library { + name: "util", + srcs: ["a.java"], + apex_available: ["myapex"], + min_sdk_version: "31", + static_libs: ["another_util"], + } + + java_library { + name: "another_util", + srcs: ["a.java"], + min_sdk_version: "31", + apex_available: ["myapex"], + } + `) + }) + + // Test java_sdk_library in systemserverclasspath_fragment may define higher min_sdk_version than the apex + t.Run("systemserverclasspath_fragment jar has higher min_sdk_version than apex", func(t *testing.T) { + preparer.RunTestWithBp(t, ` + apex { + name: "myapex", + key: "myapex.key", + systemserverclasspath_fragments: ["mysystemserverclasspathfragment"], + min_sdk_version: "30", + updatable: false, + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + systemserverclasspath_fragment { + name: "mysystemserverclasspathfragment", + contents: ["mysystemserverclasspathlib"], + apex_available: ["myapex"], + } + + java_sdk_library { + name: "mysystemserverclasspathlib", + srcs: ["mysystemserverclasspathlib.java"], + apex_available: ["myapex"], + compile_dex: true, + min_sdk_version: "32", + unsafe_ignore_missing_latest_api: true, + static_libs: ["util"], + } + + java_library { + name: "util", + srcs: ["a.java"], + apex_available: ["myapex"], + min_sdk_version: "31", + static_libs: ["another_util"], + } + + java_library { + name: "another_util", + srcs: ["a.java"], + min_sdk_version: "31", + apex_available: ["myapex"], + } + `) + }) + + t.Run("bootclasspath_fragment jar must set min_sdk_version", func(t *testing.T) { + preparer.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "mybootclasspathlib".*must set min_sdk_version`)). + RunTestWithBp(t, ` + apex { + name: "myapex", + key: "myapex.key", + bootclasspath_fragments: ["mybootclasspathfragment"], + min_sdk_version: "30", + updatable: false, + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + bootclasspath_fragment { + name: "mybootclasspathfragment", + contents: ["mybootclasspathlib"], + apex_available: ["myapex"], + } + + java_sdk_library { + name: "mybootclasspathlib", + srcs: ["mybootclasspathlib.java"], + apex_available: ["myapex"], + compile_dex: true, + unsafe_ignore_missing_latest_api: true, + } + `) + }) + + t.Run("systemserverclasspath_fragment jar must set min_sdk_version", func(t *testing.T) { + preparer.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "mysystemserverclasspathlib".*must set min_sdk_version`)). + RunTestWithBp(t, ` + apex { + name: "myapex", + key: "myapex.key", + systemserverclasspath_fragments: ["mysystemserverclasspathfragment"], + min_sdk_version: "30", + updatable: false, + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + systemserverclasspath_fragment { + name: "mysystemserverclasspathfragment", + contents: ["mysystemserverclasspathlib"], + apex_available: ["myapex"], + } + + java_sdk_library { + name: "mysystemserverclasspathlib", + srcs: ["mysystemserverclasspathlib.java"], + apex_available: ["myapex"], + compile_dex: true, + unsafe_ignore_missing_latest_api: true, + } + `) + }) +} + func TestMain(m *testing.M) { os.Exit(m.Run()) } diff --git a/dexpreopt/testing.go b/dexpreopt/testing.go index 2f996555f..63d5317c5 100644 --- a/dexpreopt/testing.go +++ b/dexpreopt/testing.go @@ -122,6 +122,14 @@ func FixtureSetBootJars(bootJars ...string) android.FixturePreparer { func FixtureSetApexBootJars(bootJars ...string) android.FixturePreparer { return FixtureModifyGlobalConfig(func(dexpreoptConfig *GlobalConfig) { dexpreoptConfig.ApexBootJars = android.CreateTestConfiguredJarList(bootJars) + + }) +} + +// FixtureSetApexSystemServerJars sets the ApexSystemServerJars property in the global config. +func FixtureSetApexSystemServerJars(jars ...string) android.FixturePreparer { + return FixtureModifyGlobalConfig(func(dexpreoptConfig *GlobalConfig) { + dexpreoptConfig.ApexSystemServerJars = android.CreateTestConfiguredJarList(jars) }) } diff --git a/java/base.go b/java/base.go index 4caca316d..4780cc909 100644 --- a/java/base.go +++ b/java/base.go @@ -1500,8 +1500,7 @@ func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu } // Implements android.ApexModule -func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, - sdkVersion android.ApiLevel) error { +func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error { sdkSpec := j.MinSdkVersion(ctx) if !sdkSpec.Specified() { return fmt.Errorf("min_sdk_version is not specified") diff --git a/java/sdk_library.go b/java/sdk_library.go index dbb97c8e6..c6747c730 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1122,6 +1122,8 @@ func (module *SdkLibrary) getGeneratedApiScopes(ctx android.EarlyModuleContext) return generatedScopes } +var _ android.ModuleWithMinSdkVersionCheck = (*SdkLibrary)(nil) + func (module *SdkLibrary) CheckMinSdkVersion(ctx android.ModuleContext) { android.CheckMinSdkVersion(ctx, module.MinSdkVersion(ctx).ApiLevel, func(c android.ModuleContext, do android.PayloadDepsCallback) { ctx.WalkDeps(func(child android.Module, parent android.Module) bool { From efb49afc8a92aec4adad7e8c31136bec1e75297a Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Fri, 10 Dec 2021 00:17:57 +0000 Subject: [PATCH 062/148] Relax apex package restriction for T+ jars The ART AOT exemption only applies to Q/R/S, so module jars that have min_sdk T+ do not need to follow the module package restriction, even if they are part of a Q/R/S module (but not loaded on Q/R/S). Relax the restriction to only apply to jars that have min_sdk before T. (clean cherry-pick) Bug: 208773835 Change-Id: Ib41ab443e36a694e3fac5f2ab0acabb3009f40a9 Test: m (runs apex tests) Merged-In: I2c3ad8984ca05ad763bf6162bd478f93ab4ee650 --- android/neverallow.go | 65 +++++++++++++++++++++-------- android/neverallow_test.go | 49 ++++++++++++++++++++-- apex/apex.go | 7 ++-- apex/apex_test.go | 84 +++++++++++++++++++++++++++++++++++++- 4 files changed, 180 insertions(+), 25 deletions(-) diff --git a/android/neverallow.go b/android/neverallow.go index af072cdbb..f7827f8ef 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -238,7 +238,7 @@ func neverallowMutator(ctx BottomUpMutatorContext) { continue } - if !n.appliesToProperties(properties) { + if !n.appliesToProperties(ctx, properties) { continue } @@ -258,8 +258,12 @@ func neverallowMutator(ctx BottomUpMutatorContext) { } } +type ValueMatcherContext interface { + Config() Config +} + type ValueMatcher interface { - Test(string) bool + Test(ValueMatcherContext, string) bool String() string } @@ -267,7 +271,7 @@ type equalMatcher struct { expected string } -func (m *equalMatcher) Test(value string) bool { +func (m *equalMatcher) Test(ctx ValueMatcherContext, value string) bool { return m.expected == value } @@ -278,7 +282,7 @@ func (m *equalMatcher) String() string { type anyMatcher struct { } -func (m *anyMatcher) Test(value string) bool { +func (m *anyMatcher) Test(ctx ValueMatcherContext, value string) bool { return true } @@ -292,7 +296,7 @@ type startsWithMatcher struct { prefix string } -func (m *startsWithMatcher) Test(value string) bool { +func (m *startsWithMatcher) Test(ctx ValueMatcherContext, value string) bool { return strings.HasPrefix(value, m.prefix) } @@ -304,7 +308,7 @@ type regexMatcher struct { re *regexp.Regexp } -func (m *regexMatcher) Test(value string) bool { +func (m *regexMatcher) Test(ctx ValueMatcherContext, value string) bool { return m.re.MatchString(value) } @@ -316,7 +320,7 @@ type notInListMatcher struct { allowed []string } -func (m *notInListMatcher) Test(value string) bool { +func (m *notInListMatcher) Test(ctx ValueMatcherContext, value string) bool { return !InList(value, m.allowed) } @@ -326,7 +330,7 @@ func (m *notInListMatcher) String() string { type isSetMatcher struct{} -func (m *isSetMatcher) Test(value string) bool { +func (m *isSetMatcher) Test(ctx ValueMatcherContext, value string) bool { return value != "" } @@ -336,6 +340,19 @@ func (m *isSetMatcher) String() string { var isSetMatcherInstance = &isSetMatcher{} +type sdkVersionMatcher struct { + condition func(ctx ValueMatcherContext, spec SdkSpec) bool + description string +} + +func (m *sdkVersionMatcher) Test(ctx ValueMatcherContext, value string) bool { + return m.condition(ctx, SdkSpecFromWithConfig(ctx.Config(), value)) +} + +func (m *sdkVersionMatcher) String() string { + return ".sdk-version(" + m.description + ")" +} + type ruleProperty struct { fields []string // e.x.: Vndk.Enabled matcher ValueMatcher @@ -549,9 +566,10 @@ func (r *rule) appliesToModuleType(moduleType string) bool { return (len(r.moduleTypes) == 0 || InList(moduleType, r.moduleTypes)) && !InList(moduleType, r.unlessModuleTypes) } -func (r *rule) appliesToProperties(properties []interface{}) bool { - includeProps := hasAllProperties(properties, r.props) - excludeProps := hasAnyProperty(properties, r.unlessProps) +func (r *rule) appliesToProperties(ctx ValueMatcherContext, + properties []interface{}) bool { + includeProps := hasAllProperties(ctx, properties, r.props) + excludeProps := hasAnyProperty(ctx, properties, r.unlessProps) return includeProps && !excludeProps } @@ -571,6 +589,16 @@ func NotInList(allowed []string) ValueMatcher { return ¬InListMatcher{allowed} } +func LessThanSdkVersion(sdk string) ValueMatcher { + return &sdkVersionMatcher{ + condition: func(ctx ValueMatcherContext, spec SdkSpec) bool { + return spec.ApiLevel.LessThan( + SdkSpecFromWithConfig(ctx.Config(), sdk).ApiLevel) + }, + description: "lessThan=" + sdk, + } +} + // assorted utils func cleanPaths(paths []string) []string { @@ -589,25 +617,28 @@ func fieldNamesForProperties(propertyNames string) []string { return names } -func hasAnyProperty(properties []interface{}, props []ruleProperty) bool { +func hasAnyProperty(ctx ValueMatcherContext, properties []interface{}, + props []ruleProperty) bool { for _, v := range props { - if hasProperty(properties, v) { + if hasProperty(ctx, properties, v) { return true } } return false } -func hasAllProperties(properties []interface{}, props []ruleProperty) bool { +func hasAllProperties(ctx ValueMatcherContext, properties []interface{}, + props []ruleProperty) bool { for _, v := range props { - if !hasProperty(properties, v) { + if !hasProperty(ctx, properties, v) { return false } } return true } -func hasProperty(properties []interface{}, prop ruleProperty) bool { +func hasProperty(ctx ValueMatcherContext, properties []interface{}, + prop ruleProperty) bool { for _, propertyStruct := range properties { propertiesValue := reflect.ValueOf(propertyStruct).Elem() for _, v := range prop.fields { @@ -621,7 +652,7 @@ func hasProperty(properties []interface{}, prop ruleProperty) bool { } check := func(value string) bool { - return prop.matcher.Test(value) + return prop.matcher.Test(ctx, value) } if matchValue(propertiesValue, check) { diff --git a/android/neverallow_test.go b/android/neverallow_test.go index 35aadd8b8..0b93fcfd7 100644 --- a/android/neverallow_test.go +++ b/android/neverallow_test.go @@ -296,6 +296,48 @@ var neverallowTests = []struct { "Only boot images may be imported as a makefile goal.", }, }, + { + name: "min_sdk too low", + fs: map[string][]byte{ + "Android.bp": []byte(` + java_library { + name: "min_sdk_too_low", + min_sdk_version: "30", + }`), + }, + rules: []Rule{ + NeverAllow().WithMatcher("min_sdk_version", LessThanSdkVersion("31")), + }, + expectedErrors: []string{ + "module \"min_sdk_too_low\": violates neverallow", + }, + }, + { + name: "min_sdk high enough", + fs: map[string][]byte{ + "Android.bp": []byte(` + java_library { + name: "min_sdk_high_enough", + min_sdk_version: "31", + }`), + }, + rules: []Rule{ + NeverAllow().WithMatcher("min_sdk_version", LessThanSdkVersion("31")), + }, + }, + { + name: "current min_sdk high enough", + fs: map[string][]byte{ + "Android.bp": []byte(` + java_library { + name: "current_min_sdk_high_enough", + min_sdk_version: "current", + }`), + }, + rules: []Rule{ + NeverAllow().WithMatcher("min_sdk_version", LessThanSdkVersion("31")), + }, + }, } var prepareForNeverAllowTest = GroupFixturePreparers( @@ -379,9 +421,10 @@ func (p *mockCcLibraryModule) GenerateAndroidBuildActions(ModuleContext) { } type mockJavaLibraryProperties struct { - Libs []string - Sdk_version *string - Uncompress_dex *bool + Libs []string + Min_sdk_version *string + Sdk_version *string + Uncompress_dex *bool } type mockJavaLibraryModule struct { diff --git a/apex/apex.go b/apex/apex.go index 4caf1c058..3b8c51a86 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -3049,15 +3049,16 @@ func createApexPermittedPackagesRules(modules_packages map[string][]string) []an BootclasspathJar(). With("apex_available", module_name). WithMatcher("permitted_packages", android.NotInList(module_packages)). + WithMatcher("min_sdk_version", android.LessThanSdkVersion("Tiramisu")). Because("jars that are part of the " + module_name + " module may only allow these packages: " + strings.Join(module_packages, ",") + - ". Please jarjar or move code around.") + " with min_sdk < T. Please jarjar or move code around.") rules = append(rules, permittedPackagesRule) } return rules } -// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART. +// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART on Q/R/S. // Adding code to the bootclasspath in new packages will cause issues on module update. func qModulesPackages() map[string][]string { return map[string][]string{ @@ -3071,7 +3072,7 @@ func qModulesPackages() map[string][]string { } } -// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART. +// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART on R/S. // Adding code to the bootclasspath in new packages will cause issues on module update. func rModulesPackages() map[string][]string { return map[string][]string{ diff --git a/apex/apex_test.go b/apex/apex_test.go index 06d89fd6f..d0a82d6c1 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -6897,6 +6897,7 @@ func TestApexPermittedPackagesRules(t *testing.T) { apex_available: ["myapex"], sdk_version: "none", system_modules: "none", + min_sdk_version: "30", } java_library { name: "nonbcp_lib2", @@ -6905,9 +6906,11 @@ func TestApexPermittedPackagesRules(t *testing.T) { permitted_packages: ["a.b"], sdk_version: "none", system_modules: "none", + min_sdk_version: "30", } apex { name: "myapex", + min_sdk_version: "30", key: "myapex.key", java_libs: ["bcp_lib1", "nonbcp_lib2"], updatable: false, @@ -6920,8 +6923,8 @@ func TestApexPermittedPackagesRules(t *testing.T) { }, }, { - name: "Bootclasspath apex jar not satisfying allowed module packages.", - expectedError: `module "bcp_lib2" .* which is restricted because jars that are part of the myapex module may only allow these packages: foo.bar. Please jarjar or move code around.`, + name: "Bootclasspath apex jar not satisfying allowed module packages on Q.", + expectedError: `module "bcp_lib2" .* which is restricted because jars that are part of the myapex module may only allow these packages: foo.bar with min_sdk < T. Please jarjar or move code around.`, bp: ` java_library { name: "bcp_lib1", @@ -6930,6 +6933,7 @@ func TestApexPermittedPackagesRules(t *testing.T) { permitted_packages: ["foo.bar"], sdk_version: "none", system_modules: "none", + min_sdk_version: "29", } java_library { name: "bcp_lib2", @@ -6938,9 +6942,85 @@ func TestApexPermittedPackagesRules(t *testing.T) { permitted_packages: ["foo.bar", "bar.baz"], sdk_version: "none", system_modules: "none", + min_sdk_version: "29", } apex { name: "myapex", + min_sdk_version: "29", + key: "myapex.key", + java_libs: ["bcp_lib1", "bcp_lib2"], + updatable: false, + } + `, + bootJars: []string{"bcp_lib1", "bcp_lib2"}, + modulesPackages: map[string][]string{ + "myapex": []string{ + "foo.bar", + }, + }, + }, + { + name: "Bootclasspath apex jar not satisfying allowed module packages on R.", + expectedError: `module "bcp_lib2" .* which is restricted because jars that are part of the myapex module may only allow these packages: foo.bar with min_sdk < T. Please jarjar or move code around.`, + bp: ` + java_library { + name: "bcp_lib1", + srcs: ["lib1/src/*.java"], + apex_available: ["myapex"], + permitted_packages: ["foo.bar"], + sdk_version: "none", + system_modules: "none", + min_sdk_version: "30", + } + java_library { + name: "bcp_lib2", + srcs: ["lib2/src/*.java"], + apex_available: ["myapex"], + permitted_packages: ["foo.bar", "bar.baz"], + sdk_version: "none", + system_modules: "none", + min_sdk_version: "30", + } + apex { + name: "myapex", + min_sdk_version: "30", + key: "myapex.key", + java_libs: ["bcp_lib1", "bcp_lib2"], + updatable: false, + } + `, + bootJars: []string{"bcp_lib1", "bcp_lib2"}, + modulesPackages: map[string][]string{ + "myapex": []string{ + "foo.bar", + }, + }, + }, + { + name: "Bootclasspath apex jar >= T not satisfying Q/R/S allowed module packages.", + expectedError: "", + bp: ` + java_library { + name: "bcp_lib1", + srcs: ["lib1/src/*.java"], + apex_available: ["myapex"], + permitted_packages: ["foo.bar"], + sdk_version: "none", + system_modules: "none", + min_sdk_version: "current", + } + java_library { + name: "bcp_lib2", + srcs: ["lib2/src/*.java"], + apex_available: ["myapex"], + permitted_packages: ["foo.bar", "bar.baz"], + sdk_version: "none", + system_modules: "none", + min_sdk_version: "current", + } + apex { + name: "myapex", + min_sdk_version: "current", key: "myapex.key", java_libs: ["bcp_lib1", "bcp_lib2"], updatable: false, From 8c6937c6baaf100a5448cd475aa0b2d59a88aa2e Mon Sep 17 00:00:00 2001 From: sophiez Date: Mon, 22 Nov 2021 11:49:41 -0800 Subject: [PATCH 063/148] NDK API coverage Fixed typo in dist path for backed by. Test: TARGET_BUILD_APPS=com.android.adbd m dist apps_only Change-Id: Ic67c0bd5644dec11829f0dc2535016fec788a067 Merged-In: Ic67c0bd5644dec11829f0dc2535016fec788a067 Bug: b/210034014 --- apex/androidmk.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apex/androidmk.go b/apex/androidmk.go index ba28e3591..6695a6fea 100644 --- a/apex/androidmk.go +++ b/apex/androidmk.go @@ -447,7 +447,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { } distCoverageFiles(w, "ndk_apis_usedby_apex", a.nativeApisUsedByModuleFile.String()) - distCoverageFiles(w, "ndk_apis_usedby_apex", a.nativeApisBackedByModuleFile.String()) + distCoverageFiles(w, "ndk_apis_backedby_apex", a.nativeApisBackedByModuleFile.String()) distCoverageFiles(w, "java_apis_used_by_apex", a.javaApisUsedByModuleFile.String()) } }} From d1ed1de63aba9031f4280f50a06161fa35d8281d Mon Sep 17 00:00:00 2001 From: Matt Banda Date: Tue, 21 Dec 2021 19:37:23 +0000 Subject: [PATCH 064/148] Java used-by API list generation Wrap the dexdeps output content with "" to simplify backend xml parsing. Test: TARGET_BUILD_APPS=com.android.adbd m dist apps_only Change-Id: I1457eb9558763e50911dc9c689b9bc3fb833a52c Merged-In: I1457eb9558763e50911dc9c689b9bc3fb833a52c (cherry picked from commit 65a981569f77141594bbe82371d3d1d65de28890) --- scripts/gen_java_usedby_apex.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/gen_java_usedby_apex.sh b/scripts/gen_java_usedby_apex.sh index 251d7aa5f..0cadb1a89 100755 --- a/scripts/gen_java_usedby_apex.sh +++ b/scripts/gen_java_usedby_apex.sh @@ -30,9 +30,11 @@ genUsedByList() { shift rm -f "$out" touch "$out" + echo "" >> "$out" for x in "$@"; do "$dexdeps" "$x" >> "$out" || true done + echo "" >> "$out" } if [[ "$1" == "help" ]] From 0493165fde8e23edd3dd3e91f5eb6fc0d62892f6 Mon Sep 17 00:00:00 2001 From: Pedro Loureiro Date: Wed, 22 Dec 2021 19:53:01 +0000 Subject: [PATCH 065/148] Rename updatable-library to apex-library Mostly for consistency with the names used in related changes. Test: m nothing Bug: 191978330 Change-Id: I34637986ead1c671bcc649891aceb3fe0f44b52a --- java/sdk_library.go | 6 +++--- java/sdk_library_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index b8ab69abb..57ab2686f 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -2573,11 +2573,11 @@ func (module *sdkLibraryXml) permissionsContents(ctx android.ModuleContext) stri implicitUntilAttr := formattedOptionalSdkLevelAttribute(ctx, "on-bootclasspath-before", module.properties.On_bootclasspath_before) minSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "min-device-sdk", module.properties.Min_device_sdk) maxSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "max-device-sdk", module.properties.Max_device_sdk) - // is understood in all android versions whereas is only understood from API T (and ignored before that). - // similarly, min_device_sdk is only understood from T. So if a library is using that, we need to use the updatable-library to make sure this library is not loaded before T + // is understood in all android versions whereas is only understood from API T (and ignored before that). + // similarly, min_device_sdk is only understood from T. So if a library is using that, we need to use the apex-library to make sure this library is not loaded before T var libraryTag string if module.properties.Min_device_sdk != nil { - libraryTag = ` Date: Wed, 22 Dec 2021 20:45:42 +0000 Subject: [PATCH 066/148] Java used-by API list generation Update the java used by script to fix the xml format when dexdeps processing resource only APKs Test: TARGET_BUILD_APPS=com.android.adbd m dist apps_only Change-Id: I61a58d7c739e74a571e97166a7c9b4091e6f8da0 Merged-In: I61a58d7c739e74a571e97166a7c9b4091e6f8da0 (cherry picked from commit bc82ba55c50eac5325760ae684745847a0cd9c72) --- scripts/gen_java_usedby_apex.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gen_java_usedby_apex.sh b/scripts/gen_java_usedby_apex.sh index 0cadb1a89..e3985414b 100755 --- a/scripts/gen_java_usedby_apex.sh +++ b/scripts/gen_java_usedby_apex.sh @@ -32,7 +32,7 @@ genUsedByList() { touch "$out" echo "" >> "$out" for x in "$@"; do - "$dexdeps" "$x" >> "$out" || true + "$dexdeps" "$x" >> "$out" || echo "" >> "$out" done echo "" >> "$out" } From 96ad98b40ec0b1298b345bd5fecb3e09f573febf Mon Sep 17 00:00:00 2001 From: Ken Chen Date: Thu, 23 Dec 2021 16:52:18 +0000 Subject: [PATCH 067/148] [NETD-BPF#21] Move a few headers to frameworks/libs/net BPF headers used by both platform and mainline modules should be in frameworks/libs/net. Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1928066 Bug: 202086915 Test: build and boot Test: cd packages/modules/Connectivity/netd; atest Change-Id: I5a86ccd44a673a18138201f186b104f5214fd449 Merged-In: I5a86ccd44a673a18138201f186b104f5214fd449 --- bpf/bpf.go | 1 + 1 file changed, 1 insertion(+) diff --git a/bpf/bpf.go b/bpf/bpf.go index fa1a84d04..0eab88fa9 100644 --- a/bpf/bpf.go +++ b/bpf/bpf.go @@ -83,6 +83,7 @@ func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) { // The architecture doesn't matter here, but asm/types.h is included by linux/types.h. "-isystem bionic/libc/kernel/uapi/asm-arm64", "-isystem bionic/libc/kernel/android/uapi", + "-I frameworks/libs/net/common/native/bpf_headers/include/bpf", // TODO(b/149785767): only give access to specific file with AID_* constants "-I system/core/libcutils/include", "-I system/bpf/progs/include", From 5d8246e2c9c9e0c04c472186e7f78a3938a93c35 Mon Sep 17 00:00:00 2001 From: LaMont Jones Date: Tue, 10 Aug 2021 19:31:33 +0000 Subject: [PATCH 068/148] Merge "Improve handling of errors from zipinfo" am: b02043b84d am: 4b3afb7798 am: 0bbc2d0229 am: ce2624cf88 am: d0cfac1546 Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1790956 Change-Id: Ib60578ead4ccaa7ba09f628a6c9281c0cc70e6ce Merged-In: Ib60578ead4ccaa7ba09f628a6c9281c0cc70e6ce (cherry picked from commit c3fc0cdb16744f52d61a808a0f8884d70c77c272) --- apex/builder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apex/builder.go b/apex/builder.go index e3e06bbd0..6b7707667 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -76,7 +76,7 @@ var ( // by default set to (uid/gid/mode) = (1000/1000/0644) // TODO(b/113082813) make this configurable using config.fs syntax generateFsConfig = pctx.StaticRule("generateFsConfig", blueprint.RuleParams{ - Command: `( echo '/ 1000 1000 0755' ` + + Command: `( set -e; echo '/ 1000 1000 0755' ` + `&& for i in ${ro_paths}; do echo "/$$i 1000 1000 0644"; done ` + `&& for i in ${exec_paths}; do echo "/$$i 0 2000 0755"; done ` + `&& ( tr ' ' '\n' <${out}.apklist | for i in ${apk_paths}; do read apk; echo "/$$i 0 2000 0755"; zipinfo -1 $$apk | sed "s:\(.*\):/$$i/\1 1000 1000 0644:"; done ) ) > ${out}`, From b90099d84e5a3629b7e6a1abeb5dc1544d73de60 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Wed, 15 Dec 2021 11:08:07 +0000 Subject: [PATCH 069/148] Merge changes from topic "canned_fs_config" am: ae9cf26353 am: 33fd601118 am: a214351987 am: 7cc9a75156 Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1918606 Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1918605 Change-Id: I484e46ff819a5266c1e8046dae337e18ef3fefea Merged-In: I484e46ff819a5266c1e8046dae337e18ef3fefea Merged-In: I7f2576ff99c65bdb6c9ce4ace61bc783eea2f0d4 (cherry picked from commit 755e3808b23dcda177cdcf15c162bb25ddf231b6) --- apex/apex.go | 8 +++ apex/apex_test.go | 27 +++++----- apex/builder.go | 123 ++++++++++++++++++++++++---------------------- 3 files changed, 85 insertions(+), 73 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 3b8c51a86..f92e75d3f 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -95,6 +95,14 @@ type apexBundleProperties struct { // /system/sepolicy/apex/_file_contexts. File_contexts *string `android:"path"` + // Path to the canned fs config file for customizing file's uid/gid/mod/capabilities. The + // format is / [capabilities=0x], where path_or_glob is a + // path or glob pattern for a file or set of files, uid/gid are numerial values of user ID + // and group ID, mode is octal value for the file mode, and cap is hexadecimal value for the + // capability. If this property is not set, or a file is missing in the file, default config + // is used. + Canned_fs_config *string `android:"path"` + ApexNativeDependencies Multilib apexMultilibProperties diff --git a/apex/apex_test.go b/apex/apex_test.go index d0a82d6c1..663a9a0b4 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -2293,22 +2293,21 @@ func TestFilesInSubDir(t *testing.T) { `) generateFsRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("generateFsConfig") - dirs := strings.Split(generateFsRule.Args["exec_paths"], " ") + cmd := generateFsRule.RuleParams.Command // Ensure that the subdirectories are all listed - ensureListContains(t, dirs, "etc") - ensureListContains(t, dirs, "etc/foo") - ensureListContains(t, dirs, "etc/foo/bar") - ensureListContains(t, dirs, "lib64") - ensureListContains(t, dirs, "lib64/foo") - ensureListContains(t, dirs, "lib64/foo/bar") - ensureListContains(t, dirs, "lib") - ensureListContains(t, dirs, "lib/foo") - ensureListContains(t, dirs, "lib/foo/bar") - - ensureListContains(t, dirs, "bin") - ensureListContains(t, dirs, "bin/foo") - ensureListContains(t, dirs, "bin/foo/bar") + ensureContains(t, cmd, "/etc ") + ensureContains(t, cmd, "/etc/foo ") + ensureContains(t, cmd, "/etc/foo/bar ") + ensureContains(t, cmd, "/lib64 ") + ensureContains(t, cmd, "/lib64/foo ") + ensureContains(t, cmd, "/lib64/foo/bar ") + ensureContains(t, cmd, "/lib ") + ensureContains(t, cmd, "/lib/foo ") + ensureContains(t, cmd, "/lib/foo/bar ") + ensureContains(t, cmd, "/bin ") + ensureContains(t, cmd, "/bin/foo ") + ensureContains(t, cmd, "/bin/foo/bar ") } func TestFilesInSubDirWhenNativeBridgeEnabled(t *testing.T) { diff --git a/apex/builder.go b/apex/builder.go index 6b7707667..8a94ad7c7 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -72,19 +72,6 @@ func init() { } var ( - // Create a canned fs config file where all files and directories are - // by default set to (uid/gid/mode) = (1000/1000/0644) - // TODO(b/113082813) make this configurable using config.fs syntax - generateFsConfig = pctx.StaticRule("generateFsConfig", blueprint.RuleParams{ - Command: `( set -e; echo '/ 1000 1000 0755' ` + - `&& for i in ${ro_paths}; do echo "/$$i 1000 1000 0644"; done ` + - `&& for i in ${exec_paths}; do echo "/$$i 0 2000 0755"; done ` + - `&& ( tr ' ' '\n' <${out}.apklist | for i in ${apk_paths}; do read apk; echo "/$$i 0 2000 0755"; zipinfo -1 $$apk | sed "s:\(.*\):/$$i/\1 1000 1000 0644:"; done ) ) > ${out}`, - Description: "fs_config ${out}", - Rspfile: "$out.apklist", - RspfileContent: "$in", - }, "ro_paths", "exec_paths", "apk_paths") - apexManifestRule = pctx.StaticRule("apexManifestRule", blueprint.RuleParams{ Command: `rm -f $out && ${jsonmodify} $in ` + `-a provideNativeLibs ${provideNativeLibs} ` + @@ -521,55 +508,11 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { // Figure out if need to compress apex. compressionEnabled := ctx.Config().CompressedApex() && proptools.BoolDefault(a.properties.Compressible, false) && !a.testApex && !ctx.Config().UnbundledBuildApps() if apexType == imageApex { + //////////////////////////////////////////////////////////////////////////////////// // Step 2: create canned_fs_config which encodes filemode,uid,gid of each files // in this APEX. The file will be used by apexer in later steps. - // TODO(jiyong): make this as a function - // TODO(jiyong): use the RuleBuilder - var readOnlyPaths = []string{"apex_manifest.json", "apex_manifest.pb"} - var executablePaths []string // this also includes dirs - var extractedAppSetPaths android.Paths - var extractedAppSetDirs []string - for _, f := range a.filesInfo { - pathInApex := f.path() - if f.installDir == "bin" || strings.HasPrefix(f.installDir, "bin/") { - executablePaths = append(executablePaths, pathInApex) - for _, d := range f.dataPaths { - readOnlyPaths = append(readOnlyPaths, filepath.Join(f.installDir, d.RelativeInstallPath, d.SrcPath.Rel())) - } - for _, s := range f.symlinks { - executablePaths = append(executablePaths, filepath.Join(f.installDir, s)) - } - } else if f.class == appSet { - extractedAppSetPaths = append(extractedAppSetPaths, f.builtFile) - extractedAppSetDirs = append(extractedAppSetDirs, f.installDir) - } else { - readOnlyPaths = append(readOnlyPaths, pathInApex) - } - dir := f.installDir - for !android.InList(dir, executablePaths) && dir != "" { - executablePaths = append(executablePaths, dir) - dir, _ = filepath.Split(dir) // move up to the parent - if len(dir) > 0 { - // remove trailing slash - dir = dir[:len(dir)-1] - } - } - } - sort.Strings(readOnlyPaths) - sort.Strings(executablePaths) - cannedFsConfig := android.PathForModuleOut(ctx, "canned_fs_config") - ctx.Build(pctx, android.BuildParams{ - Rule: generateFsConfig, - Output: cannedFsConfig, - Description: "generate fs config", - Inputs: extractedAppSetPaths, - Args: map[string]string{ - "ro_paths": strings.Join(readOnlyPaths, " "), - "exec_paths": strings.Join(executablePaths, " "), - "apk_paths": strings.Join(extractedAppSetDirs, " "), - }, - }) + cannedFsConfig := a.buildCannedFsConfig(ctx) implicitInputs = append(implicitInputs, cannedFsConfig) //////////////////////////////////////////////////////////////////////////////////// @@ -1005,3 +948,65 @@ func (a *apexBundle) buildLintReports(ctx android.ModuleContext) { a.lintReports = java.BuildModuleLintReportZips(ctx, depSetsBuilder.Build()) } + +func (a *apexBundle) buildCannedFsConfig(ctx android.ModuleContext) android.OutputPath { + var readOnlyPaths = []string{"apex_manifest.json", "apex_manifest.pb"} + var executablePaths []string // this also includes dirs + var appSetDirs []string + appSetFiles := make(map[string]android.Path) + for _, f := range a.filesInfo { + pathInApex := f.path() + if f.installDir == "bin" || strings.HasPrefix(f.installDir, "bin/") { + executablePaths = append(executablePaths, pathInApex) + for _, d := range f.dataPaths { + readOnlyPaths = append(readOnlyPaths, filepath.Join(f.installDir, d.RelativeInstallPath, d.SrcPath.Rel())) + } + for _, s := range f.symlinks { + executablePaths = append(executablePaths, filepath.Join(f.installDir, s)) + } + } else if f.class == appSet { + appSetDirs = append(appSetDirs, f.installDir) + appSetFiles[f.installDir] = f.builtFile + } else { + readOnlyPaths = append(readOnlyPaths, pathInApex) + } + dir := f.installDir + for !android.InList(dir, executablePaths) && dir != "" { + executablePaths = append(executablePaths, dir) + dir, _ = filepath.Split(dir) // move up to the parent + if len(dir) > 0 { + // remove trailing slash + dir = dir[:len(dir)-1] + } + } + } + sort.Strings(readOnlyPaths) + sort.Strings(executablePaths) + sort.Strings(appSetDirs) + + cannedFsConfig := android.PathForModuleOut(ctx, "canned_fs_config") + builder := android.NewRuleBuilder(pctx, ctx) + cmd := builder.Command() + cmd.Text("(") + cmd.Text("echo '/ 1000 1000 0755';") + for _, p := range readOnlyPaths { + cmd.Textf("echo '/%s 1000 1000 0644';", p) + } + for _, p := range executablePaths { + cmd.Textf("echo '/%s 0 2000 0755';", p) + } + for _, dir := range appSetDirs { + cmd.Textf("echo '/%s 0 2000 0755';", dir) + file := appSetFiles[dir] + cmd.Text("zipinfo -1").Input(file).Textf(`| sed "s:\(.*\):/%s/\1 1000 1000 0644:";`, dir) + } + // Custom fs_config is "appended" to the last so that entries from the file are preferred + // over default ones set above. + if a.properties.Canned_fs_config != nil { + cmd.Text("cat").Input(android.PathForModuleSrc(ctx, *a.properties.Canned_fs_config)) + } + cmd.Text(")").FlagWithOutput("> ", cannedFsConfig) + builder.Build("generateFsConfig", fmt.Sprintf("Generating canned fs config for %s", a.BaseModuleName())) + + return cannedFsConfig.OutputPath +} From 0349649423e6209609232167a1bd9c0a2a8ba318 Mon Sep 17 00:00:00 2001 From: Ken Chen Date: Thu, 23 Dec 2021 16:52:40 +0000 Subject: [PATCH 070/148] Remove global bpf include path system/bpf/progs/include Delete it because there is only one user left (system/bpfprogs/time_in_state.c). It can be specified locally. Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1930904 Bug: 202086915 Test: build and boot Change-Id: I1cb0ceb7b8e3fb63af34e11e5fece11fa038b24e Merged-In: I1cb0ceb7b8e3fb63af34e11e5fece11fa038b24e --- bpf/bpf.go | 1 - 1 file changed, 1 deletion(-) diff --git a/bpf/bpf.go b/bpf/bpf.go index 0eab88fa9..9f0c86ce2 100644 --- a/bpf/bpf.go +++ b/bpf/bpf.go @@ -86,7 +86,6 @@ func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) { "-I frameworks/libs/net/common/native/bpf_headers/include/bpf", // TODO(b/149785767): only give access to specific file with AID_* constants "-I system/core/libcutils/include", - "-I system/bpf/progs/include", "-I " + ctx.ModuleDir(), } From 21f7ae0828a1c3135d4d5d5076e497f46c07d39b Mon Sep 17 00:00:00 2001 From: Wei Li Date: Mon, 6 Dec 2021 13:35:11 -0800 Subject: [PATCH 071/148] Add new property "exclude_files_in_output" for excluding files from the output files of Java related modules. Bug: 204888276 Test: m service-permission Change-Id: I9f6113834826358b0e3af22ed1dd63a43c255452 --- java/dex.go | 43 +++++++++++++++++++++++++--------------- java/sdk_library_test.go | 9 +++++++++ 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/java/dex.go b/java/dex.go index 8045b5cc6..e2a76f754 100644 --- a/java/dex.go +++ b/java/dex.go @@ -72,6 +72,9 @@ type DexProperties struct { // This defaults to reasonable value based on module and should not be set. // It exists only to support ART tests. Uncompress_dex *bool + + // Exclude kotlinc generate files: *.kotlin_module, *.kotlin_builtins. Defaults to true. + Exclude_kotlinc_generated_files *bool } type dexer struct { @@ -94,7 +97,7 @@ var d8, d8RE = pctx.MultiCommandRemoteStaticRules("d8", `${config.Zip2ZipCmd} -i $in -o $tmpJar -x '**/*.dex' && ` + `$d8Template${config.D8Cmd} ${config.DexFlags} --output $outDir $d8Flags $tmpJar && ` + `$zipTemplate${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` + - `${config.MergeZipsCmd} -D -stripFile "**/*.class" $out $outDir/classes.dex.jar $in`, + `${config.MergeZipsCmd} -D -stripFile "**/*.class" $mergeZipsFlags $out $outDir/classes.dex.jar $in`, CommandDeps: []string{ "${config.D8Cmd}", "${config.Zip2ZipCmd}", @@ -116,7 +119,7 @@ var d8, d8RE = pctx.MultiCommandRemoteStaticRules("d8", ExecStrategy: "${config.RED8ExecStrategy}", Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"}, }, - }, []string{"outDir", "d8Flags", "zipFlags", "tmpJar"}, nil) + }, []string{"outDir", "d8Flags", "zipFlags", "tmpJar", "mergeZipsFlags"}, nil) var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", blueprint.RuleParams{ @@ -134,7 +137,7 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", `${config.SoongZipCmd} -o ${outUsageZip} -C ${outUsageDir} -f ${outUsage} && ` + `rm -rf ${outUsageDir} && ` + `$zipTemplate${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` + - `${config.MergeZipsCmd} -D -stripFile "**/*.class" $out $outDir/classes.dex.jar $in`, + `${config.MergeZipsCmd} -D -stripFile "**/*.class" $mergeZipsFlags $out $outDir/classes.dex.jar $in`, CommandDeps: []string{ "${config.R8Cmd}", "${config.Zip2ZipCmd}", @@ -165,7 +168,7 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"}, }, }, []string{"outDir", "outDict", "outUsage", "outUsageZip", "outUsageDir", - "r8Flags", "zipFlags", "tmpJar"}, []string{"implicits"}) + "r8Flags", "zipFlags", "tmpJar", "mergeZipsFlags"}, []string{"implicits"}) func (d *dexer) dexCommonFlags(ctx android.ModuleContext, minSdkVersion android.SdkSpec) (flags []string, deps android.Paths) { @@ -298,6 +301,12 @@ func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, mi commonFlags, commonDeps := d.dexCommonFlags(ctx, minSdkVersion) + // Exclude kotlinc generated files by default, or when "exclude_kotlinc_generated_files" is set to true. + mergeZipsFlags := "" + if proptools.BoolDefault(d.dexProperties.Exclude_kotlinc_generated_files, true) { + mergeZipsFlags = "-stripFile META-INF/*.kotlin_module -stripFile **/*.kotlin_builtins" + } + useR8 := d.effectiveOptimizeEnabled() if useR8 { proguardDictionary := android.PathForModuleOut(ctx, "proguard_dictionary") @@ -311,14 +320,15 @@ func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, mi r8Deps = append(r8Deps, commonDeps...) rule := r8 args := map[string]string{ - "r8Flags": strings.Join(append(commonFlags, r8Flags...), " "), - "zipFlags": zipFlags, - "outDict": proguardDictionary.String(), - "outUsageDir": proguardUsageDir.String(), - "outUsage": proguardUsage.String(), - "outUsageZip": proguardUsageZip.String(), - "outDir": outDir.String(), - "tmpJar": tmpJar.String(), + "r8Flags": strings.Join(append(commonFlags, r8Flags...), " "), + "zipFlags": zipFlags, + "outDict": proguardDictionary.String(), + "outUsageDir": proguardUsageDir.String(), + "outUsage": proguardUsage.String(), + "outUsageZip": proguardUsageZip.String(), + "outDir": outDir.String(), + "tmpJar": tmpJar.String(), + "mergeZipsFlags": mergeZipsFlags, } if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_R8") { rule = r8RE @@ -347,10 +357,11 @@ func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, mi Input: classesJar, Implicits: d8Deps, Args: map[string]string{ - "d8Flags": strings.Join(append(commonFlags, d8Flags...), " "), - "zipFlags": zipFlags, - "outDir": outDir.String(), - "tmpJar": tmpJar.String(), + "d8Flags": strings.Join(append(commonFlags, d8Flags...), " "), + "zipFlags": zipFlags, + "outDir": outDir.String(), + "tmpJar": tmpJar.String(), + "mergeZipsFlags": mergeZipsFlags, }, }) } diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index e60ca003e..edb7a48e5 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -48,6 +48,7 @@ func TestJavaSdkLibrary(t *testing.T) { name: "bar", srcs: ["a.java", "b.java"], api_packages: ["bar"], + exclude_kotlinc_generated_files: false, } java_library { name: "baz", @@ -161,6 +162,14 @@ func TestJavaSdkLibrary(t *testing.T) { android.AssertDeepEquals(t, "qux exports (required)", []string{"fred", "quuz", "foo", "bar"}, requiredSdkLibs) android.AssertDeepEquals(t, "qux exports (optional)", []string{}, optionalSdkLibs) } + + fooDexJar := result.ModuleForTests("foo", "android_common").Rule("d8") + // tests if kotlinc generated files are excluded from output of foo. + android.AssertStringDoesContain(t, "foo dex", fooDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module") + + barDexJar := result.ModuleForTests("bar", "android_common").Rule("d8") + // tests if kotlinc generated files are NOT excluded from output of bar. + android.AssertStringDoesNotContain(t, "bar dex", barDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module") } func TestJavaSdkLibrary_UpdatableLibrary(t *testing.T) { From 3964ce02ff4a90d8a7782fac1f89dfe0b07004a2 Mon Sep 17 00:00:00 2001 From: Josh Wu Date: Tue, 11 Jan 2022 05:12:15 +0000 Subject: [PATCH 072/148] Revert "Add new property "exclude_files_in_output" for excluding files from the output files of Java related modules." This reverts commit 21f7ae0828a1c3135d4d5d5076e497f46c07d39b. Reason for revert: b/213966211 Change-Id: I697739697221d6f821eeda33a434cfcae9d651bf --- java/dex.go | 43 +++++++++++++++------------------------- java/sdk_library_test.go | 9 --------- 2 files changed, 16 insertions(+), 36 deletions(-) diff --git a/java/dex.go b/java/dex.go index e2a76f754..8045b5cc6 100644 --- a/java/dex.go +++ b/java/dex.go @@ -72,9 +72,6 @@ type DexProperties struct { // This defaults to reasonable value based on module and should not be set. // It exists only to support ART tests. Uncompress_dex *bool - - // Exclude kotlinc generate files: *.kotlin_module, *.kotlin_builtins. Defaults to true. - Exclude_kotlinc_generated_files *bool } type dexer struct { @@ -97,7 +94,7 @@ var d8, d8RE = pctx.MultiCommandRemoteStaticRules("d8", `${config.Zip2ZipCmd} -i $in -o $tmpJar -x '**/*.dex' && ` + `$d8Template${config.D8Cmd} ${config.DexFlags} --output $outDir $d8Flags $tmpJar && ` + `$zipTemplate${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` + - `${config.MergeZipsCmd} -D -stripFile "**/*.class" $mergeZipsFlags $out $outDir/classes.dex.jar $in`, + `${config.MergeZipsCmd} -D -stripFile "**/*.class" $out $outDir/classes.dex.jar $in`, CommandDeps: []string{ "${config.D8Cmd}", "${config.Zip2ZipCmd}", @@ -119,7 +116,7 @@ var d8, d8RE = pctx.MultiCommandRemoteStaticRules("d8", ExecStrategy: "${config.RED8ExecStrategy}", Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"}, }, - }, []string{"outDir", "d8Flags", "zipFlags", "tmpJar", "mergeZipsFlags"}, nil) + }, []string{"outDir", "d8Flags", "zipFlags", "tmpJar"}, nil) var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", blueprint.RuleParams{ @@ -137,7 +134,7 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", `${config.SoongZipCmd} -o ${outUsageZip} -C ${outUsageDir} -f ${outUsage} && ` + `rm -rf ${outUsageDir} && ` + `$zipTemplate${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` + - `${config.MergeZipsCmd} -D -stripFile "**/*.class" $mergeZipsFlags $out $outDir/classes.dex.jar $in`, + `${config.MergeZipsCmd} -D -stripFile "**/*.class" $out $outDir/classes.dex.jar $in`, CommandDeps: []string{ "${config.R8Cmd}", "${config.Zip2ZipCmd}", @@ -168,7 +165,7 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"}, }, }, []string{"outDir", "outDict", "outUsage", "outUsageZip", "outUsageDir", - "r8Flags", "zipFlags", "tmpJar", "mergeZipsFlags"}, []string{"implicits"}) + "r8Flags", "zipFlags", "tmpJar"}, []string{"implicits"}) func (d *dexer) dexCommonFlags(ctx android.ModuleContext, minSdkVersion android.SdkSpec) (flags []string, deps android.Paths) { @@ -301,12 +298,6 @@ func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, mi commonFlags, commonDeps := d.dexCommonFlags(ctx, minSdkVersion) - // Exclude kotlinc generated files by default, or when "exclude_kotlinc_generated_files" is set to true. - mergeZipsFlags := "" - if proptools.BoolDefault(d.dexProperties.Exclude_kotlinc_generated_files, true) { - mergeZipsFlags = "-stripFile META-INF/*.kotlin_module -stripFile **/*.kotlin_builtins" - } - useR8 := d.effectiveOptimizeEnabled() if useR8 { proguardDictionary := android.PathForModuleOut(ctx, "proguard_dictionary") @@ -320,15 +311,14 @@ func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, mi r8Deps = append(r8Deps, commonDeps...) rule := r8 args := map[string]string{ - "r8Flags": strings.Join(append(commonFlags, r8Flags...), " "), - "zipFlags": zipFlags, - "outDict": proguardDictionary.String(), - "outUsageDir": proguardUsageDir.String(), - "outUsage": proguardUsage.String(), - "outUsageZip": proguardUsageZip.String(), - "outDir": outDir.String(), - "tmpJar": tmpJar.String(), - "mergeZipsFlags": mergeZipsFlags, + "r8Flags": strings.Join(append(commonFlags, r8Flags...), " "), + "zipFlags": zipFlags, + "outDict": proguardDictionary.String(), + "outUsageDir": proguardUsageDir.String(), + "outUsage": proguardUsage.String(), + "outUsageZip": proguardUsageZip.String(), + "outDir": outDir.String(), + "tmpJar": tmpJar.String(), } if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_R8") { rule = r8RE @@ -357,11 +347,10 @@ func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, mi Input: classesJar, Implicits: d8Deps, Args: map[string]string{ - "d8Flags": strings.Join(append(commonFlags, d8Flags...), " "), - "zipFlags": zipFlags, - "outDir": outDir.String(), - "tmpJar": tmpJar.String(), - "mergeZipsFlags": mergeZipsFlags, + "d8Flags": strings.Join(append(commonFlags, d8Flags...), " "), + "zipFlags": zipFlags, + "outDir": outDir.String(), + "tmpJar": tmpJar.String(), }, }) } diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index edb7a48e5..e60ca003e 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -48,7 +48,6 @@ func TestJavaSdkLibrary(t *testing.T) { name: "bar", srcs: ["a.java", "b.java"], api_packages: ["bar"], - exclude_kotlinc_generated_files: false, } java_library { name: "baz", @@ -162,14 +161,6 @@ func TestJavaSdkLibrary(t *testing.T) { android.AssertDeepEquals(t, "qux exports (required)", []string{"fred", "quuz", "foo", "bar"}, requiredSdkLibs) android.AssertDeepEquals(t, "qux exports (optional)", []string{}, optionalSdkLibs) } - - fooDexJar := result.ModuleForTests("foo", "android_common").Rule("d8") - // tests if kotlinc generated files are excluded from output of foo. - android.AssertStringDoesContain(t, "foo dex", fooDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module") - - barDexJar := result.ModuleForTests("bar", "android_common").Rule("d8") - // tests if kotlinc generated files are NOT excluded from output of bar. - android.AssertStringDoesNotContain(t, "bar dex", barDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module") } func TestJavaSdkLibrary_UpdatableLibrary(t *testing.T) { From ca9703c665113350bdcf6d2b162f209a3ba1f129 Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Tue, 11 Jan 2022 12:02:06 -0500 Subject: [PATCH 073/148] rust: Fix exported MinSdkVersion The exported rust.MinSdkVersion always returns an empty string. Instead it should return the Min_sdk_version property like rust.minSdkVersion. This CL renames minSdkVersion to MinSdkVersion so the exported function has the correct behavior. Bug: 211858959 Test: m Change-Id: I4fecfba711c0d3d7a22f4fdf7684924a9457b464 --- rust/rust.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/rust/rust.go b/rust/rust.go index 778000dd5..cba92c33f 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -366,10 +366,6 @@ func (mod *Module) SdkVersion() string { return "" } -func (mod *Module) MinSdkVersion() string { - return "" -} - func (mod *Module) AlwaysSdk() bool { return false } @@ -1497,15 +1493,13 @@ func (mod *Module) HostToolPath() android.OptionalPath { var _ android.ApexModule = (*Module)(nil) -func (mod *Module) minSdkVersion() string { +func (mod *Module) MinSdkVersion() string { return String(mod.Properties.Min_sdk_version) } -var _ android.ApexModule = (*Module)(nil) - // Implements android.ApexModule func (mod *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error { - minSdkVersion := mod.minSdkVersion() + minSdkVersion := mod.MinSdkVersion() if minSdkVersion == "apex_inherit" { return nil } From ab1f1ac6e8e67a4f752620e420763e38dc6ebfec Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Tue, 11 Jan 2022 12:02:06 -0500 Subject: [PATCH 074/148] rust: Fix exported MinSdkVersion The exported rust.MinSdkVersion always returns an empty string. Instead it should return the Min_sdk_version property like rust.minSdkVersion. This CL renames minSdkVersion to MinSdkVersion so the exported function has the correct behavior. Bug: 211858959 Bug: 214625677 Test: m Change-Id: I4fecfba711c0d3d7a22f4fdf7684924a9457b464 Merged-In: I4fecfba711c0d3d7a22f4fdf7684924a9457b464 --- rust/rust.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/rust/rust.go b/rust/rust.go index f068b3d7b..cdeecc191 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -328,10 +328,6 @@ func (mod *Module) SdkVersion() string { return "" } -func (mod *Module) MinSdkVersion() string { - return "" -} - func (mod *Module) AlwaysSdk() bool { return false } @@ -1276,15 +1272,13 @@ func (mod *Module) HostToolPath() android.OptionalPath { var _ android.ApexModule = (*Module)(nil) -func (mod *Module) minSdkVersion() string { +func (mod *Module) MinSdkVersion() string { return String(mod.Properties.Min_sdk_version) } -var _ android.ApexModule = (*Module)(nil) - // Implements android.ApexModule func (mod *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error { - minSdkVersion := mod.minSdkVersion() + minSdkVersion := mod.MinSdkVersion() if minSdkVersion == "apex_inherit" { return nil } From 6320efb56e2254d78cd040ffa78942ff619460ff Mon Sep 17 00:00:00 2001 From: Ken Chen Date: Wed, 10 Nov 2021 22:02:57 +0800 Subject: [PATCH 075/148] [NETD-BPF#34] Add a tag for bpf to specify the install folder Currently, the bpf module netd.o (source system/netd/bpf_progs/netd.c) will be built to /system/etc/bpf/netd.o. In Android T, it will be moved to mainline module com.android.tethering. The expected behavior is: - In T device, it uses the netd.o in mainline module. - In pre-T devices, it uses the original netd, built from platform. However, netd.o will be double loaded if the tethering module is installed in Pre-T devices. Because: 1. bpf in apex is packed into /apex/MAINLINE_MODULE/etc/bpf/ 2. bpf in platform is packed into /system/etc/bpf/ 3. bpfloader in pre-T loads ANY bpf modules under /apex/com.android.tethering/etc/bpf/ and /system/etc/bpf/. We can't change the behavior of bpfloader in pre-T devices. We can't delete the /system/etc/bpf/netd.o from pre-T devices. Both of them are not mainline modules. So the mainlined netd.o needs to be packed into a folder other than /apex/com.android.tethering/etc/bpf/ or /system/etc/bpf/. This commit adds a tag 'sub_dir' for bpf module. The installation path of bpf modules will be: - /system/etc/bpf/SUB_DIR/ (for platform code) - /apex/MAINLINE_MODULE/etc/bpf/SUB_DIR/ (for mainline module) Bug: 202086915 Test: add test in apex_test.go and build Merged-In: Icc6619768ab006de9f86620a7df1bb2853eaba13 Change-Id: Icc6619768ab006de9f86620a7df1bb2853eaba13 --- apex/apex.go | 7 ++++--- apex/apex_test.go | 9 ++++++++- bpf/bpf.go | 14 +++++++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index f92e75d3f..65b9c5461 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1572,8 +1572,8 @@ func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.R return af } -func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, bpfProgram bpf.BpfModule) apexFile { - dirInApex := filepath.Join("etc", "bpf") +func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, apex_sub_dir string, bpfProgram bpf.BpfModule) apexFile { + dirInApex := filepath.Join("etc", "bpf", apex_sub_dir) return newApexFile(ctx, builtFile, builtFile.Base(), dirInApex, etc, bpfProgram) } @@ -1772,8 +1772,9 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { case bpfTag: if bpfProgram, ok := child.(bpf.BpfModule); ok { filesToCopy, _ := bpfProgram.OutputFiles("") + apex_sub_dir := bpfProgram.SubDir() for _, bpfFile := range filesToCopy { - filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, bpfProgram)) + filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, apex_sub_dir, bpfProgram)) } } else { ctx.PropertyErrorf("bpfs", "%q is not a bpf module", depName) diff --git a/apex/apex_test.go b/apex/apex_test.go index 663a9a0b4..f3c3b44c5 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -622,7 +622,7 @@ func TestDefaults(t *testing.T) { java_libs: ["myjar"], apps: ["AppFoo"], rros: ["rro"], - bpfs: ["bpf"], + bpfs: ["bpf", "netd_test"], updatable: false, } @@ -675,6 +675,12 @@ func TestDefaults(t *testing.T) { srcs: ["bpf.c", "bpf2.c"], } + bpf { + name: "netd_test", + srcs: ["netd_test.c"], + sub_dir: "netd", + } + `) ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{ "etc/myetc", @@ -684,6 +690,7 @@ func TestDefaults(t *testing.T) { "overlay/blue/rro.apk", "etc/bpf/bpf.o", "etc/bpf/bpf2.o", + "etc/bpf/netd/netd_test.o", }) } diff --git a/bpf/bpf.go b/bpf/bpf.go index 9f0c86ce2..187b4db61 100644 --- a/bpf/bpf.go +++ b/bpf/bpf.go @@ -54,12 +54,16 @@ type BpfModule interface { android.Module OutputFiles(tag string) (android.Paths, error) + + // Returns the sub install directory if the bpf module is included by apex. + SubDir() string } type BpfProperties struct { Srcs []string `android:"path"` Cflags []string Include_dirs []string + Sub_dir string } type bpf struct { @@ -121,6 +125,10 @@ func (bpf *bpf) AndroidMk() android.AndroidMkData { fmt.Fprintln(w) fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir) fmt.Fprintln(w) + localModulePath := "LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/bpf" + if len(bpf.properties.Sub_dir) > 0 { + localModulePath += "/" + bpf.properties.Sub_dir + } for _, obj := range bpf.objs { objName := name + "_" + obj.Base() names = append(names, objName) @@ -130,7 +138,7 @@ func (bpf *bpf) AndroidMk() android.AndroidMkData { fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", obj.String()) fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", obj.Base()) fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") - fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/bpf") + fmt.Fprintln(w, localModulePath) fmt.Fprintln(w, "include $(BUILD_PREBUILT)") fmt.Fprintln(w) } @@ -154,6 +162,10 @@ func (bpf *bpf) OutputFiles(tag string) (android.Paths, error) { } } +func (bpf *bpf) SubDir() string { + return bpf.properties.Sub_dir +} + var _ android.OutputFileProducer = (*bpf)(nil) func BpfFactory() android.Module { From 9d92964ddde09bbf4e1da33b28ad308878f8dfc0 Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Wed, 19 Jan 2022 19:37:39 +0000 Subject: [PATCH 076/148] Ignore some properties for T and above. As requested by reminv@, their team wants the source code in sc-mainline-prod to be strictly the same as the code in AOSP. Therefore, we need to ignore `standalone_contents` in the `systemserverclasspath_fragment` module and `systemserverclasspath_fragments` in the `sdk` module in order to merge aosp/1925682 into sc-mainline-prod. - `standalone_contents` in the `systemserverclasspath_fragment` module does nothing but adds its contents as dependencies of the APEX. - `systemserverclasspath_fragments` in the `sdk` module does nothing. Bug: 203198541 Test: TARGET_BUILD_APPS=com.android.tethering vendor/google/build/mainline_modules_bundles.sh Change-Id: I56ca22aa91a807cd113dfda2fabaeb49ecabe289 Merged-In: I09a6fd1d3db85c194330da9b751702a9bf069e26 --- apex/apex.go | 6 +++++ java/systemserver_classpath_fragment.go | 26 +++++++++++++++++--- java/systemserver_classpath_fragment_test.go | 2 +- sdk/sdk.go | 8 +++++- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 65b9c5461..e1bc030c5 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -2348,6 +2348,12 @@ func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) { func (a *apexBundle) checkClasspathFragments(ctx android.ModuleContext) { ctx.VisitDirectDeps(func(module android.Module) { if tag := ctx.OtherModuleDependencyTag(module); tag == bcpfTag || tag == sscpfTag { + if tag == sscpfTag { + sscpf := module.(*java.SystemServerClasspathModule) + if sscpf.ShouldIgnore() { + return + } + } info := ctx.OtherModuleProvider(module, java.ClasspathFragmentProtoContentInfoProvider).(java.ClasspathFragmentProtoContentInfo) if !info.ClasspathFragmentProtoGenerated { ctx.OtherModuleErrorf(module, "is included in updatable apex %v, it must not set generate_classpaths_proto to false", ctx.ModuleName()) diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go index 10dbd01e2..be28fe9c2 100644 --- a/java/systemserver_classpath_fragment.go +++ b/java/systemserver_classpath_fragment.go @@ -72,10 +72,15 @@ func (s *SystemServerClasspathModule) ShouldSupportSdkVersion(ctx android.BaseMo } type systemServerClasspathFragmentProperties struct { - // The contents of this systemserverclasspath_fragment, could be either java_library, or java_sdk_library. + // List of system_server classpath jars, could be either java_library, or java_sdk_library. // // The order of this list matters as it is the order that is used in the SYSTEMSERVERCLASSPATH. Contents []string + + // List of jars that system_server loads dynamically using separate classloaders. + // + // The order does not matter. + Standalone_contents []string } func systemServerClasspathFactory() android.Module { @@ -88,8 +93,12 @@ func systemServerClasspathFactory() android.Module { } func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { - if len(s.properties.Contents) == 0 { - ctx.PropertyErrorf("contents", "empty contents are not allowed") + if len(s.properties.Contents) == 0 && len(s.properties.Standalone_contents) == 0 { + ctx.PropertyErrorf("contents", "Either contents or standalone_contents needs to be non-empty") + } + + if s.ShouldIgnore() { + return } configuredJars := s.configuredJars(ctx) @@ -128,8 +137,17 @@ func IsSystemServerClasspathFragmentContentDepTag(tag blueprint.DependencyTag) b func (s *SystemServerClasspathModule) ComponentDepsMutator(ctx android.BottomUpMutatorContext) { module := ctx.Module() + var deps []string + deps = append(deps, s.properties.Contents...) + deps = append(deps, s.properties.Standalone_contents...) - for _, name := range s.properties.Contents { + for _, name := range deps { ctx.AddDependency(module, systemServerClasspathFragmentContentDepTag, name) } } + +func (s *SystemServerClasspathModule) ShouldIgnore() bool { + // Ignore this `systemserverclasspath_fragment` if it only contains `standalone_contents` because + // it is for T and above. + return len(s.properties.Contents) == 0 +} diff --git a/java/systemserver_classpath_fragment_test.go b/java/systemserver_classpath_fragment_test.go index 9ad50dd4a..ba328e7b1 100644 --- a/java/systemserver_classpath_fragment_test.go +++ b/java/systemserver_classpath_fragment_test.go @@ -99,7 +99,7 @@ func TestPlatformSystemServerClasspathModule_AndroidMkEntries(t *testing.T) { func TestSystemServerClasspathFragmentWithoutContents(t *testing.T) { prepareForTestWithSystemServerClasspath. ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern( - `\Qempty contents are not allowed\E`)). + `\QEither contents or standalone_contents needs to be non-empty\E`)). RunTestWithBp(t, ` systemserverclasspath_fragment { name: "systemserverclasspath-fragment", diff --git a/sdk/sdk.go b/sdk/sdk.go index b1c8aebf9..d8196fffc 100644 --- a/sdk/sdk.go +++ b/sdk/sdk.go @@ -257,7 +257,13 @@ func newSdkModule(moduleExports bool) *sdk { // Create an instance of the dynamically created struct that contains all the // properties for the member type specific list properties. s.dynamicMemberTypeListProperties = s.dynamicSdkMemberTypes.createMemberListProperties() - s.AddProperties(&s.properties, s.dynamicMemberTypeListProperties) + + ignoredProperties := struct { + // `systemserverclasspath_fragments` is for T and above. + Systemserverclasspath_fragments []string + }{} + + s.AddProperties(&s.properties, s.dynamicMemberTypeListProperties, &ignoredProperties) // Make sure that the prebuilt visibility property is verified for errors. android.AddVisibilityProperty(s, "prebuilt_visibility", &s.properties.Prebuilt_visibility) From d9100a56e64541c340ffb8c72fe04db95b6fd6a8 Mon Sep 17 00:00:00 2001 From: Wei Li Date: Mon, 6 Dec 2021 13:35:11 -0800 Subject: [PATCH 077/148] Add new property "exclude_kotlinc_generated_files" for excluding files generated by kotlinc from the output files of Java related modules. Bug: 204888276 Test: m service-permission Change-Id: I9f6113834826358b0e3af22ed1dd63a43c255452 Merged-In: I9f6113834826358b0e3af22ed1dd63a43c255452 (cherry picked from commit 1e73c6573ec51d41115a1c0f697ce312b42d8099) --- java/dex.go | 39 +++++++++++++++++++++++++-------------- java/sdk_library_test.go | 9 +++++++++ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/java/dex.go b/java/dex.go index 7898e9dff..1acfebd51 100644 --- a/java/dex.go +++ b/java/dex.go @@ -69,6 +69,9 @@ type DexProperties struct { // This defaults to reasonable value based on module and should not be set. // It exists only to support ART tests. Uncompress_dex *bool + + // Exclude kotlinc generate files: *.kotlin_module, *.kotlin_builtins. Defaults to false. + Exclude_kotlinc_generated_files *bool } type dexer struct { @@ -89,7 +92,7 @@ var d8, d8RE = pctx.MultiCommandRemoteStaticRules("d8", Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` + `$d8Template${config.D8Cmd} ${config.DexFlags} --output $outDir $d8Flags $in && ` + `$zipTemplate${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` + - `${config.MergeZipsCmd} -D -stripFile "**/*.class" $out $outDir/classes.dex.jar $in`, + `${config.MergeZipsCmd} -D -stripFile "**/*.class" $mergeZipsFlags $out $outDir/classes.dex.jar $in`, CommandDeps: []string{ "${config.D8Cmd}", "${config.SoongZipCmd}", @@ -110,7 +113,7 @@ var d8, d8RE = pctx.MultiCommandRemoteStaticRules("d8", ExecStrategy: "${config.RED8ExecStrategy}", Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"}, }, - }, []string{"outDir", "d8Flags", "zipFlags"}, nil) + }, []string{"outDir", "d8Flags", "zipFlags", "mergeZipsFlags"}, nil) var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", blueprint.RuleParams{ @@ -126,7 +129,7 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", `${config.SoongZipCmd} -o ${outUsageZip} -C ${outUsageDir} -f ${outUsage} && ` + `rm -rf ${outUsageDir} && ` + `$zipTemplate${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` + - `${config.MergeZipsCmd} -D -stripFile "**/*.class" $out $outDir/classes.dex.jar $in`, + `${config.MergeZipsCmd} -D -stripFile "**/*.class" $mergeZipsFlags $out $outDir/classes.dex.jar $in`, CommandDeps: []string{ "${config.R8Cmd}", "${config.SoongZipCmd}", @@ -156,7 +159,7 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"}, }, }, []string{"outDir", "outDict", "outUsage", "outUsageZip", "outUsageDir", - "r8Flags", "zipFlags"}, []string{"implicits"}) + "r8Flags", "zipFlags", "mergeZipsFlags"}, []string{"implicits"}) func (d *dexer) dexCommonFlags(ctx android.ModuleContext, minSdkVersion android.SdkSpec) []string { flags := d.dexProperties.Dxflags @@ -281,6 +284,12 @@ func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, mi commonFlags := d.dexCommonFlags(ctx, minSdkVersion) + // Exclude kotlinc generated files when "exclude_kotlinc_generated_files" is set to true. + mergeZipsFlags := "" + if proptools.BoolDefault(d.dexProperties.Exclude_kotlinc_generated_files, false) { + mergeZipsFlags = "-stripFile META-INF/*.kotlin_module -stripFile **/*.kotlin_builtins" + } + useR8 := d.effectiveOptimizeEnabled() if useR8 { proguardDictionary := android.PathForModuleOut(ctx, "proguard_dictionary") @@ -293,13 +302,14 @@ func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, mi r8Flags, r8Deps := d.r8Flags(ctx, flags) rule := r8 args := map[string]string{ - "r8Flags": strings.Join(append(commonFlags, r8Flags...), " "), - "zipFlags": zipFlags, - "outDict": proguardDictionary.String(), - "outUsageDir": proguardUsageDir.String(), - "outUsage": proguardUsage.String(), - "outUsageZip": proguardUsageZip.String(), - "outDir": outDir.String(), + "r8Flags": strings.Join(append(commonFlags, r8Flags...), " "), + "zipFlags": zipFlags, + "outDict": proguardDictionary.String(), + "outUsageDir": proguardUsageDir.String(), + "outUsage": proguardUsage.String(), + "outUsageZip": proguardUsageZip.String(), + "outDir": outDir.String(), + "mergeZipsFlags": mergeZipsFlags, } if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_R8") { rule = r8RE @@ -327,9 +337,10 @@ func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, mi Input: classesJar, Implicits: d8Deps, Args: map[string]string{ - "d8Flags": strings.Join(append(commonFlags, d8Flags...), " "), - "zipFlags": zipFlags, - "outDir": outDir.String(), + "d8Flags": strings.Join(append(commonFlags, d8Flags...), " "), + "zipFlags": zipFlags, + "outDir": outDir.String(), + "mergeZipsFlags": mergeZipsFlags, }, }) } diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 0c7b79853..f8717c066 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -47,6 +47,7 @@ func TestJavaSdkLibrary(t *testing.T) { name: "bar", srcs: ["a.java", "b.java"], api_packages: ["bar"], + exclude_kotlinc_generated_files: true, } java_library { name: "baz", @@ -159,6 +160,14 @@ func TestJavaSdkLibrary(t *testing.T) { sdkLibs := quxLib.ClassLoaderContexts().UsesLibs() android.AssertDeepEquals(t, "qux exports", []string{"foo", "bar", "fred", "quuz"}, sdkLibs) } + + fooDexJar := result.ModuleForTests("foo", "android_common").Rule("d8") + // tests if kotlinc generated files are NOT excluded from output of foo. + android.AssertStringDoesNotContain(t, "foo dex", fooDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module") + + barDexJar := result.ModuleForTests("bar", "android_common").Rule("d8") + // tests if kotlinc generated files are excluded from output of bar. + android.AssertStringDoesContain(t, "bar dex", barDexJar.BuildParams.Args["mergeZipsFlags"], "-stripFile META-INF/*.kotlin_module") } func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) { From 5d240fb8ada9dfa563cb543be680177a244bed09 Mon Sep 17 00:00:00 2001 From: Ray Essick Date: Mon, 7 Feb 2022 11:01:32 -0800 Subject: [PATCH 078/148] Clean auto-allowed modules for media mainline Clean out list of modules automatically allowed to be used in the media mainline modules, now that those modules have explicit apex_available clauses in their Android.bp files. Bug: 215589022 Bug: 147364041 Test: build Change-Id: I2d3f57621796c99a119acc98e1ead358aebedc5d --- apex/apex.go | 232 +-------------------------------------------------- 1 file changed, 1 insertion(+), 231 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 0c8c5be3c..b4f2810f2 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -2661,7 +2661,6 @@ func makeApexAvailableBaseline() map[string][]string { "android.hardware.graphics.common@1.0", "android.hardware.graphics.common@1.1", "android.hardware.graphics.common@1.2", - "android.hardware.media@1.0", "android.hidl.safe_union@1.0", "android.hidl.token@1.0", "android.hidl.token@1.0-utils", @@ -2677,7 +2676,6 @@ func makeApexAvailableBaseline() map[string][]string { "lib-bt-packets", "lib-bt-packets-avrcp", "lib-bt-packets-base", - "libFraunhoferAAC", "libaudio-a2dp-hw-utils", "libaudio-hearing-aid-hw-utils", "libbluetooth", @@ -2705,11 +2703,8 @@ func makeApexAvailableBaseline() map[string][]string { "libfmq", "libg722codec", "libgui_headers", - "libmedia_headers", "libmodpb64", "libosi", - "libstagefright_foundation_headers", - "libstagefright_headers", "libstatslog", "libstatssocket", "libtinyxml2", @@ -2762,134 +2757,15 @@ func makeApexAvailableBaseline() map[string][]string { // Module separator // m["com.android.media"] = []string{ - "android.frameworks.bufferhub@1.0", - "android.hardware.cas.native@1.0", - "android.hardware.cas@1.0", - "android.hardware.configstore-utils", - "android.hardware.configstore@1.0", - "android.hardware.configstore@1.1", - "android.hardware.graphics.allocator@2.0", - "android.hardware.graphics.allocator@3.0", - "android.hardware.graphics.bufferqueue@1.0", - "android.hardware.graphics.bufferqueue@2.0", - "android.hardware.graphics.common@1.0", - "android.hardware.graphics.common@1.1", - "android.hardware.graphics.common@1.2", - "android.hardware.graphics.mapper@2.0", - "android.hardware.graphics.mapper@2.1", - "android.hardware.graphics.mapper@3.0", - "android.hardware.media.omx@1.0", - "android.hardware.media@1.0", - "android.hidl.allocator@1.0", - "android.hidl.memory.token@1.0", - "android.hidl.memory@1.0", - "android.hidl.token@1.0", - "android.hidl.token@1.0-utils", - "bionic_libc_platform_headers", - "exoplayer2-extractor", - "exoplayer2-extractor-annotation-stubs", - "gl_headers", - "jsr305", - "libEGL", - "libEGL_blobCache", - "libEGL_getProcAddress", - "libFLAC", - "libFLAC-config", - "libFLAC-headers", - "libGLESv2", - "libaacextractor", - "libamrextractor", - "libarect", - "libaudio_system_headers", - "libaudioclient", - "libaudioclient_headers", - "libaudiofoundation", - "libaudiofoundation_headers", - "libaudiomanager", - "libaudiopolicy", - "libaudioutils", - "libaudioutils_fixedfft", - "libbluetooth-types-header", - "libbufferhub", - "libbufferhub_headers", - "libbufferhubqueue", - "libc_malloc_debug_backtrace", - "libcamera_client", - "libcamera_metadata", - "libdvr_headers", - "libexpat", - "libfifo", - "libflacextractor", - "libgrallocusage", - "libgraphicsenv", - "libgui", - "libgui_headers", - "libhardware_headers", - "libinput", - "liblzma", - "libmath", - "libmedia", - "libmedia_codeclist", - "libmedia_headers", - "libmedia_helper", - "libmedia_helper_headers", - "libmedia_midiiowrapper", - "libmedia_omx", - "libmediautils", - "libmidiextractor", - "libmkvextractor", - "libmp3extractor", - "libmp4extractor", - "libmpeg2extractor", - "libnativebase_headers", - "libnativewindow_headers", - "libnblog", - "liboggextractor", - "libpackagelistparser", - "libpdx", - "libpdx_default_transport", - "libpdx_headers", - "libpdx_uds", - "libprocinfo", - "libspeexresampler", - "libspeexresampler", - "libstagefright_esds", - "libstagefright_flacdec", - "libstagefright_flacdec", - "libstagefright_foundation", - "libstagefright_foundation_headers", - "libstagefright_foundation_without_imemory", - "libstagefright_headers", - "libstagefright_id3", - "libstagefright_metadatautils", - "libstagefright_mpeg2extractor", - "libstagefright_mpeg2support", - "libui", - "libui_headers", - "libunwindstack", - "libvibrator", - "libvorbisidec", - "libwavextractor", - "libwebm", - "media_ndk_headers", - "media_plugin_headers", - "updatable-media", + // empty } // // Module separator // m["com.android.media.swcodec"] = []string{ - "android.frameworks.bufferhub@1.0", - "android.hardware.common-ndk_platform", - "android.hardware.configstore-utils", - "android.hardware.configstore@1.0", - "android.hardware.configstore@1.1", "android.hardware.graphics.allocator@2.0", "android.hardware.graphics.allocator@3.0", "android.hardware.graphics.allocator@4.0", - "android.hardware.graphics.bufferqueue@1.0", - "android.hardware.graphics.bufferqueue@2.0", - "android.hardware.graphics.common-ndk_platform", "android.hardware.graphics.common@1.0", "android.hardware.graphics.common@1.1", "android.hardware.graphics.common@1.2", @@ -2897,123 +2773,17 @@ func makeApexAvailableBaseline() map[string][]string { "android.hardware.graphics.mapper@2.1", "android.hardware.graphics.mapper@3.0", "android.hardware.graphics.mapper@4.0", - "android.hardware.media.bufferpool@2.0", - "android.hardware.media.c2@1.0", - "android.hardware.media.c2@1.1", - "android.hardware.media.omx@1.0", - "android.hardware.media@1.0", - "android.hardware.media@1.0", - "android.hidl.memory.token@1.0", - "android.hidl.memory@1.0", - "android.hidl.safe_union@1.0", - "android.hidl.token@1.0", - "android.hidl.token@1.0-utils", - "libEGL", - "libFLAC", - "libFLAC-config", - "libFLAC-headers", - "libFraunhoferAAC", "libLibGuiProperties", - "libarect", - "libaudio_system_headers", - "libaudioutils", - "libaudioutils", - "libaudioutils_fixedfft", - "libavcdec", - "libavcenc", - "libavservices_minijail", - "libavservices_minijail", - "libbinderthreadstateutils", - "libbluetooth-types-header", - "libbufferhub_headers", - "libcodec2", - "libcodec2_headers", - "libcodec2_hidl@1.0", - "libcodec2_hidl@1.1", - "libcodec2_internal", - "libcodec2_soft_aacdec", - "libcodec2_soft_aacenc", - "libcodec2_soft_amrnbdec", - "libcodec2_soft_amrnbenc", - "libcodec2_soft_amrwbdec", - "libcodec2_soft_amrwbenc", - "libcodec2_soft_av1dec_gav1", - "libcodec2_soft_avcdec", - "libcodec2_soft_avcenc", - "libcodec2_soft_common", - "libcodec2_soft_flacdec", - "libcodec2_soft_flacenc", - "libcodec2_soft_g711alawdec", - "libcodec2_soft_g711mlawdec", - "libcodec2_soft_gsmdec", - "libcodec2_soft_h263dec", - "libcodec2_soft_h263enc", - "libcodec2_soft_hevcdec", - "libcodec2_soft_hevcenc", - "libcodec2_soft_mp3dec", - "libcodec2_soft_mpeg2dec", - "libcodec2_soft_mpeg4dec", - "libcodec2_soft_mpeg4enc", - "libcodec2_soft_opusdec", - "libcodec2_soft_opusenc", - "libcodec2_soft_rawdec", - "libcodec2_soft_vorbisdec", - "libcodec2_soft_vp8dec", - "libcodec2_soft_vp8enc", - "libcodec2_soft_vp9dec", - "libcodec2_soft_vp9enc", - "libcodec2_vndk", - "libdvr_headers", "libfmq", - "libfmq", - "libgav1", - "libgralloctypes", "libgrallocusage", - "libgraphicsenv", - "libgsm", - "libgui_bufferqueue_static", "libgui_headers", "libhardware", "libhardware_headers", - "libhevcdec", - "libhevcenc", "libion", - "libjpeg", - "liblzma", - "libmath", - "libmedia_codecserviceregistrant", - "libmedia_headers", - "libmpeg2dec", "libnativebase_headers", "libnativewindow_headers", - "libpdx_headers", - "libscudo_wrapper", - "libsfplugin_ccodec_utils", - "libspeexresampler", - "libstagefright_amrnb_common", - "libstagefright_amrnbdec", - "libstagefright_amrnbenc", - "libstagefright_amrwbdec", - "libstagefright_amrwbenc", - "libstagefright_bufferpool@2.0.1", - "libstagefright_enc_common", - "libstagefright_flacdec", - "libstagefright_foundation", - "libstagefright_foundation_headers", - "libstagefright_headers", - "libstagefright_m4vh263dec", - "libstagefright_m4vh263enc", - "libstagefright_mp3dec", "libui", "libui_headers", - "libunwindstack", - "libvorbisidec", - "libvpx", - "libyuv", - "libyuv_static", - "media_ndk_headers", - "media_plugin_headers", - "mediaswcodec", } // // Module separator From c566255300c22d6d05353fd532b1127b5b5a0907 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 9 Sep 2021 16:11:42 +0100 Subject: [PATCH 079/148] Move setting of link type properties to linkPropertyInfo Bug: 195754365 Test: m nothing Merged-In: Ica90a42cd8e4a79251271164f137dcdf60b3bd55 Change-Id: Ica90a42cd8e4a79251271164f137dcdf60b3bd55 (cherry picked from commit f68f85a3cac3214a610ec716cab089ccc5aebf41) --- sdk/update.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sdk/update.go b/sdk/update.go index 84f0e4e2f..0fb2f695f 100644 --- a/sdk/update.go +++ b/sdk/update.go @@ -1492,8 +1492,7 @@ func (archInfo *archTypeSpecificInfo) addToPropertySet(ctx *memberContext, archP addSdkMemberPropertiesToSet(ctx, archInfo.Properties, archTypePropertySet) for _, linkInfo := range archInfo.linkInfos { - linkPropertySet := archTypePropertySet.AddPropertySet(linkInfo.linkType) - addSdkMemberPropertiesToSet(ctx, linkInfo.Properties, linkPropertySet) + linkInfo.addToPropertySet(ctx, archTypePropertySet) } } @@ -1524,6 +1523,11 @@ func newLinkSpecificInfo(ctx android.SdkMemberContext, linkType string, variantP return linkInfo } +func (l *linkTypeSpecificInfo) addToPropertySet(ctx *memberContext, propertySet android.BpPropertySet) { + linkPropertySet := propertySet.AddPropertySet(l.linkType) + addSdkMemberPropertiesToSet(ctx, l.Properties, linkPropertySet) +} + func (l *linkTypeSpecificInfo) String() string { return fmt.Sprintf("LinkType{%s}", l.linkType) } From 3e7d3ca12705d137a96bc25482caccf25207b8d0 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 9 Sep 2021 16:37:49 +0100 Subject: [PATCH 080/148] Insert imageVariantSpecificInfo between arch and link info Previously, the archTypeSpecificInfo included an array of *linkTypeSpecificInfo. This change replaces that array with an array of *imageVariantSpecificInfo which themselves contain an array of *linkTypeSpecificInfo. That allows the sdk snapshot to handle image variants correctly, i.e. collate their properties, optimize their properties and then detect if there are any image variant specific properties for any image variant other than the CoreImageVariant ("") and report it as an error. The latter case is treated as an error because while Soong needs to handle image specific variants there is currently no requirement to handle generating a prebuilt with image specific properties. A follow up change will test the error handling. Image specific variants are needed because the "jni_headers" cc_library_headers module provides a number of image variants (e.g. recovery) that are used outside the ART module. Therefore, the sdk snapshot needs to do the same. At the moment image variants like the recovery variant are supported by copying the property that creates the variant (e.g. recovery_available) through to the prebuilt but that is not safe for a couple of reasons: 1. It ignores any differences between the recovery variant and the other variants which could cause compatibility issues in modules that build against the prebuilts. 2. It marks modules in the snapshot with recovery_available even when they do not need it. This change will allow follow up changes to address both those issues. Bug: 195754365 Test: m nothing Merged-In: I1c187d814f44b2cb7607cd43a6b215134be0faad Change-Id: I1c187d814f44b2cb7607cd43a6b215134be0faad (cherry picked from commit b42fa67a4709efd318ab77bdf8ff1b3ccd2e3e58) --- android/module.go | 11 +++- sdk/update.go | 125 ++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 120 insertions(+), 16 deletions(-) diff --git a/android/module.go b/android/module.go index f745a4ab4..786f79d57 100644 --- a/android/module.go +++ b/android/module.go @@ -15,7 +15,6 @@ package android import ( - "android/soong/bazel" "fmt" "os" "path" @@ -24,6 +23,8 @@ import ( "strings" "text/scanner" + "android/soong/bazel" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) @@ -452,6 +453,14 @@ type Module interface { Enabled() bool Target() Target MultiTargets() []Target + + // ImageVariation returns the image variation of this module. + // + // The returned structure has its Mutator field set to "image" and its Variation field set to the + // image variation, e.g. recovery, ramdisk, etc.. The Variation field is "" for host modules and + // device modules that have no image variation. + ImageVariation() blueprint.Variation + Owner() string InstallInData() bool InstallInTestcases() bool diff --git a/sdk/update.go b/sdk/update.go index 0fb2f695f..cc06c3b1c 100644 --- a/sdk/update.go +++ b/sdk/update.go @@ -22,6 +22,7 @@ import ( "android/soong/apex" "android/soong/cc" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" @@ -1411,7 +1412,7 @@ type archTypeSpecificInfo struct { archType android.ArchType osType android.OsType - linkInfos []*linkTypeSpecificInfo + imageVariantInfos []*imageVariantSpecificInfo } var _ propertiesContainer = (*archTypeSpecificInfo)(nil) @@ -1430,17 +1431,17 @@ func newArchSpecificInfo(ctx android.SdkMemberContext, archType android.ArchType if len(archVariants) == 1 { archInfo.Properties.PopulateFromVariant(ctx, archVariants[0]) } else { - // There is more than one variant for this arch type which must be differentiated - // by link type. - for _, linkVariant := range archVariants { - linkType := getLinkType(linkVariant) - if linkType == "" { - panic(fmt.Errorf("expected one arch specific variant as it is not identified by link type but found %d", len(archVariants))) - } else { - linkInfo := newLinkSpecificInfo(ctx, linkType, variantPropertiesFactory, linkVariant) + // Group the variants by image type. + variantsByImage := make(map[string][]android.Module) + for _, variant := range archVariants { + image := variant.ImageVariation().Variation + variantsByImage[image] = append(variantsByImage[image], variant) + } - archInfo.linkInfos = append(archInfo.linkInfos, linkInfo) - } + // Create the image variant info in a fixed order. + for _, imageVariantName := range android.SortedStringKeys(variantsByImage) { + variants := variantsByImage[imageVariantName] + archInfo.imageVariantInfos = append(archInfo.imageVariantInfos, newImageVariantSpecificInfo(ctx, imageVariantName, variantPropertiesFactory, variants)) } } @@ -1474,11 +1475,16 @@ func getLinkType(variant android.Module) string { // Optimize the properties by extracting common properties from link type specific // properties into arch type specific properties. func (archInfo *archTypeSpecificInfo) optimizeProperties(ctx *memberContext, commonValueExtractor *commonValueExtractor) { - if len(archInfo.linkInfos) == 0 { + if len(archInfo.imageVariantInfos) == 0 { return } - extractCommonProperties(ctx.sdkMemberContext, commonValueExtractor, archInfo.Properties, archInfo.linkInfos) + // Optimize the image variant properties first. + for _, imageVariantInfo := range archInfo.imageVariantInfos { + imageVariantInfo.optimizeProperties(ctx, commonValueExtractor) + } + + extractCommonProperties(ctx.sdkMemberContext, commonValueExtractor, archInfo.Properties, archInfo.imageVariantInfos) } // Add the properties for an arch type to a property set. @@ -1491,15 +1497,104 @@ func (archInfo *archTypeSpecificInfo) addToPropertySet(ctx *memberContext, archP } addSdkMemberPropertiesToSet(ctx, archInfo.Properties, archTypePropertySet) - for _, linkInfo := range archInfo.linkInfos { - linkInfo.addToPropertySet(ctx, archTypePropertySet) + for _, imageVariantInfo := range archInfo.imageVariantInfos { + imageVariantInfo.addToPropertySet(ctx, archTypePropertySet) } } +// getPropertySetContents returns the string representation of the contents of a property set, after +// recursively pruning any empty nested property sets. +func getPropertySetContents(propertySet android.BpPropertySet) string { + set := propertySet.(*bpPropertySet) + set.transformContents(pruneEmptySetTransformer{}) + if len(set.properties) != 0 { + contents := &generatedContents{} + contents.Indent() + outputPropertySet(contents, set) + setAsString := contents.content.String() + return setAsString + } + return "" +} + func (archInfo *archTypeSpecificInfo) String() string { return fmt.Sprintf("ArchType{%s}", archInfo.archType) } +type imageVariantSpecificInfo struct { + baseInfo + + imageVariant string + + linkInfos []*linkTypeSpecificInfo +} + +func newImageVariantSpecificInfo(ctx android.SdkMemberContext, imageVariant string, variantPropertiesFactory variantPropertiesFactoryFunc, imageVariants []android.Module) *imageVariantSpecificInfo { + + // Create an image variant specific info into which the variant properties can be copied. + imageInfo := &imageVariantSpecificInfo{imageVariant: imageVariant} + + // Create the properties into which the image variant specific properties will be added. + imageInfo.Properties = variantPropertiesFactory() + + if len(imageVariants) == 1 { + imageInfo.Properties.PopulateFromVariant(ctx, imageVariants[0]) + } else { + // There is more than one variant for this image variant which must be differentiated by link + // type. + for _, linkVariant := range imageVariants { + linkType := getLinkType(linkVariant) + if linkType == "" { + panic(fmt.Errorf("expected one arch specific variant as it is not identified by link type but found %d", len(imageVariants))) + } else { + linkInfo := newLinkSpecificInfo(ctx, linkType, variantPropertiesFactory, linkVariant) + + imageInfo.linkInfos = append(imageInfo.linkInfos, linkInfo) + } + } + } + + return imageInfo +} + +// Optimize the properties by extracting common properties from link type specific +// properties into arch type specific properties. +func (imageInfo *imageVariantSpecificInfo) optimizeProperties(ctx *memberContext, commonValueExtractor *commonValueExtractor) { + if len(imageInfo.linkInfos) == 0 { + return + } + + extractCommonProperties(ctx.sdkMemberContext, commonValueExtractor, imageInfo.Properties, imageInfo.linkInfos) +} + +// Add the properties for an arch type to a property set. +func (imageInfo *imageVariantSpecificInfo) addToPropertySet(ctx *memberContext, propertySet android.BpPropertySet) { + if imageInfo.imageVariant != android.CoreVariation { + propertySet = propertySet.AddPropertySet(imageInfo.imageVariant) + } + + addSdkMemberPropertiesToSet(ctx, imageInfo.Properties, propertySet) + + for _, linkInfo := range imageInfo.linkInfos { + linkInfo.addToPropertySet(ctx, propertySet) + } + + // If this is for a non-core image variant then make sure that the property set does not contain + // any properties as providing non-core image variant specific properties for prebuilts is not + // currently supported. + if imageInfo.imageVariant != android.CoreVariation { + propertySetContents := getPropertySetContents(propertySet) + if propertySetContents != "" { + ctx.SdkModuleContext().ModuleErrorf("Image variant %q of sdk member %q has properties distinct from other variants; this is not yet supported. The properties are:\n%s", + imageInfo.imageVariant, ctx.name, propertySetContents) + } + } +} + +func (imageInfo *imageVariantSpecificInfo) String() string { + return imageInfo.imageVariant +} + type linkTypeSpecificInfo struct { baseInfo From 49171a4a703a5445481f69d0b558e156a12069ff Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 24 Aug 2021 19:01:25 +0100 Subject: [PATCH 081/148] Support handling build releases in sdk snapshot Adds the following: 1. A buildRelease type to represent a single build release. 2. A buildReleaseSet type to represent a set of build releases. 3. Methods to create parse and use the previous new types. 4. Tests for the above. Bug: 197842263 Test: m nothing Merged-In: Ib0dd4fc32851a4fffde3fa02ea22c8369f8c2995 Change-Id: Ib0dd4fc32851a4fffde3fa02ea22c8369f8c2995 (cherry picked from commit 1812294f32c35ba9a970966af9790d54e19e6f60) --- sdk/Android.bp | 2 + sdk/build_release.go | 160 ++++++++++++++++++++++++++++++++++++++ sdk/build_release_test.go | 100 ++++++++++++++++++++++++ 3 files changed, 262 insertions(+) create mode 100644 sdk/build_release.go create mode 100644 sdk/build_release_test.go diff --git a/sdk/Android.bp b/sdk/Android.bp index 368c03aec..5ba2d9d59 100644 --- a/sdk/Android.bp +++ b/sdk/Android.bp @@ -15,6 +15,7 @@ bootstrap_go_package { ], srcs: [ "bp.go", + "build_release.go", "exports.go", "sdk.go", "update.go", @@ -22,6 +23,7 @@ bootstrap_go_package { testSrcs: [ "bootclasspath_fragment_sdk_test.go", "bp_test.go", + "build_release_test.go", "cc_sdk_test.go", "compat_config_sdk_test.go", "exports_test.go", diff --git a/sdk/build_release.go b/sdk/build_release.go new file mode 100644 index 000000000..f2379ae36 --- /dev/null +++ b/sdk/build_release.go @@ -0,0 +1,160 @@ +// Copyright (C) 2021 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. + +package sdk + +import ( + "fmt" + "strings" +) + +// Supports customizing sdk snapshot output based on target build release. + +// buildRelease represents the version of a build system used to create a specific release. +// +// The name of the release, is the same as the code for the dessert release, e.g. S, T, etc. +type buildRelease struct { + // The name of the release, e.g. S, T, etc. + name string + + // The index of this structure within the buildReleases list. + ordinal int +} + +// String returns the name of the build release. +func (s *buildRelease) String() string { + return s.name +} + +// buildReleaseSet represents a set of buildRelease objects. +type buildReleaseSet struct { + // Set of *buildRelease represented as a map from *buildRelease to struct{}. + contents map[*buildRelease]struct{} +} + +// addItem adds a build release to the set. +func (s *buildReleaseSet) addItem(release *buildRelease) { + s.contents[release] = struct{}{} +} + +// addRange adds all the build releases from start (inclusive) to end (inclusive). +func (s *buildReleaseSet) addRange(start *buildRelease, end *buildRelease) { + for i := start.ordinal; i <= end.ordinal; i += 1 { + s.addItem(buildReleases[i]) + } +} + +// contains returns true if the set contains the specified build release. +func (s *buildReleaseSet) contains(release *buildRelease) bool { + _, ok := s.contents[release] + return ok +} + +// String returns a string representation of the set, sorted from earliest to latest release. +func (s *buildReleaseSet) String() string { + list := []string{} + for _, release := range buildReleases { + if _, ok := s.contents[release]; ok { + list = append(list, release.name) + } + } + return fmt.Sprintf("[%s]", strings.Join(list, ",")) +} + +var ( + // nameToBuildRelease contains a map from name to build release. + nameToBuildRelease = map[string]*buildRelease{} + + // buildReleases lists all the available build releases. + buildReleases = []*buildRelease{} + + // allBuildReleaseSet is the set of all build releases. + allBuildReleaseSet = &buildReleaseSet{contents: map[*buildRelease]struct{}{}} + + // Add the build releases from oldest to newest. + buildReleaseS = initBuildRelease("S") + buildReleaseT = initBuildRelease("T") +) + +// initBuildRelease creates a new build release with the specified name. +func initBuildRelease(name string) *buildRelease { + ordinal := len(nameToBuildRelease) + release := &buildRelease{name: name, ordinal: ordinal} + nameToBuildRelease[name] = release + buildReleases = append(buildReleases, release) + allBuildReleaseSet.addItem(release) + return release +} + +// latestBuildRelease returns the latest build release, i.e. the last one added. +func latestBuildRelease() *buildRelease { + return buildReleases[len(buildReleases)-1] +} + +// nameToRelease maps from build release name to the corresponding build release (if it exists) or +// the error if it does not. +func nameToRelease(name string) (*buildRelease, error) { + if r, ok := nameToBuildRelease[name]; ok { + return r, nil + } + + return nil, fmt.Errorf("unknown release %q, expected one of %s", name, allBuildReleaseSet) +} + +// parseBuildReleaseSet parses a build release set string specification into a build release set. +// +// The specification consists of one of the following: +// * a single build release name, e.g. S, T, etc. +// * a closed range (inclusive to inclusive), e.g. S-T +// * an open range, e.g. T+. +// +// This returns the set if the specification was valid or an error. +func parseBuildReleaseSet(specification string) (*buildReleaseSet, error) { + set := &buildReleaseSet{contents: map[*buildRelease]struct{}{}} + + if strings.HasSuffix(specification, "+") { + rangeStart := strings.TrimSuffix(specification, "+") + start, err := nameToRelease(rangeStart) + if err != nil { + return nil, err + } + end := latestBuildRelease() + set.addRange(start, end) + } else if strings.Contains(specification, "-") { + limits := strings.SplitN(specification, "-", 2) + start, err := nameToRelease(limits[0]) + if err != nil { + return nil, err + } + + end, err := nameToRelease(limits[1]) + if err != nil { + return nil, err + } + + if start.ordinal > end.ordinal { + return nil, fmt.Errorf("invalid closed range, start release %q is later than end release %q", start.name, end.name) + } + + set.addRange(start, end) + } else { + release, err := nameToRelease(specification) + if err != nil { + return nil, err + } + set.addItem(release) + } + + return set, nil +} diff --git a/sdk/build_release_test.go b/sdk/build_release_test.go new file mode 100644 index 000000000..fa6591cb8 --- /dev/null +++ b/sdk/build_release_test.go @@ -0,0 +1,100 @@ +// Copyright (C) 2021 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. + +package sdk + +import ( + "fmt" + "testing" + + "android/soong/android" +) + +// Tests for build_release.go + +var ( + // Some additional test specific releases that are added after the currently supported ones and + // so are treated as being for future releases. + buildReleaseFuture1 = initBuildRelease("F1") + buildReleaseFuture2 = initBuildRelease("F2") +) + +func TestNameToRelease(t *testing.T) { + t.Run("single release", func(t *testing.T) { + release, err := nameToRelease("S") + android.AssertDeepEquals(t, "errors", nil, err) + android.AssertDeepEquals(t, "release", buildReleaseS, release) + }) + t.Run("invalid release", func(t *testing.T) { + release, err := nameToRelease("A") + android.AssertDeepEquals(t, "release", (*buildRelease)(nil), release) + // Uses a wildcard in the error message to allow for additional build releases to be added to + // the supported set without breaking this test. + android.FailIfNoMatchingErrors(t, `unknown release "A", expected one of \[S,T.*,F1,F2\]`, []error{err}) + }) +} + +func TestParseBuildReleaseSet(t *testing.T) { + t.Run("single release", func(t *testing.T) { + set, err := parseBuildReleaseSet("S") + android.AssertDeepEquals(t, "errors", nil, err) + android.AssertStringEquals(t, "set", "[S]", set.String()) + }) + t.Run("open range", func(t *testing.T) { + set, err := parseBuildReleaseSet("F1+") + android.AssertDeepEquals(t, "errors", nil, err) + android.AssertStringEquals(t, "set", "[F1,F2]", set.String()) + }) + t.Run("closed range", func(t *testing.T) { + set, err := parseBuildReleaseSet("S-F1") + android.AssertDeepEquals(t, "errors", nil, err) + android.AssertStringEquals(t, "set", "[S,T,F1]", set.String()) + }) + invalidAReleaseMessage := `unknown release "A", expected one of ` + allBuildReleaseSet.String() + t.Run("invalid release", func(t *testing.T) { + set, err := parseBuildReleaseSet("A") + android.AssertDeepEquals(t, "set", (*buildReleaseSet)(nil), set) + android.AssertStringDoesContain(t, "errors", fmt.Sprint(err), invalidAReleaseMessage) + }) + t.Run("invalid release in open range", func(t *testing.T) { + set, err := parseBuildReleaseSet("A+") + android.AssertDeepEquals(t, "set", (*buildReleaseSet)(nil), set) + android.AssertStringDoesContain(t, "errors", fmt.Sprint(err), invalidAReleaseMessage) + }) + t.Run("invalid release in closed range start", func(t *testing.T) { + set, err := parseBuildReleaseSet("A-S") + android.AssertDeepEquals(t, "set", (*buildReleaseSet)(nil), set) + android.AssertStringDoesContain(t, "errors", fmt.Sprint(err), invalidAReleaseMessage) + }) + t.Run("invalid release in closed range end", func(t *testing.T) { + set, err := parseBuildReleaseSet("T-A") + android.AssertDeepEquals(t, "set", (*buildReleaseSet)(nil), set) + android.AssertStringDoesContain(t, "errors", fmt.Sprint(err), invalidAReleaseMessage) + }) + t.Run("invalid closed range reversed", func(t *testing.T) { + set, err := parseBuildReleaseSet("F1-S") + android.AssertDeepEquals(t, "set", (*buildReleaseSet)(nil), set) + android.AssertStringDoesContain(t, "errors", fmt.Sprint(err), `invalid closed range, start release "F1" is later than end release "S"`) + }) +} + +func TestBuildReleaseSetContains(t *testing.T) { + t.Run("contains", func(t *testing.T) { + set, _ := parseBuildReleaseSet("F1-F2") + android.AssertBoolEquals(t, "set contains F1", true, set.contains(buildReleaseFuture1)) + android.AssertBoolEquals(t, "set does not contain S", false, set.contains(buildReleaseS)) + android.AssertBoolEquals(t, "set contains F2", true, set.contains(buildReleaseFuture2)) + android.AssertBoolEquals(t, "set does not contain T", false, set.contains(buildReleaseT)) + }) +} From 3ea92052854fa7fdd1c4dfd017f85198cff3de2b Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 24 Aug 2021 19:01:25 +0100 Subject: [PATCH 082/148] Support pruning properties by build release Adds a general mechanism for pruning selected sdk member properties (i.e. setting their fields to their zero value) and uses that to prune any properties that do not support a specified target build release. Follow up changes will use that to allow building an sdk snapshot that is compatible with previous release S. Bug: 197842263 Test: m nothing Merged-In: Ib949a9cfe85fff30f86228eeb15d3a45c073b037 Change-Id: Ib949a9cfe85fff30f86228eeb15d3a45c073b037 (cherry picked from commit 0c3acbfd727a88c459fbe97f225f4a115dc48b83) --- sdk/build_release.go | 164 ++++++++++++++++++++++++++++++++++++++ sdk/build_release_test.go | 85 ++++++++++++++++++++ 2 files changed, 249 insertions(+) diff --git a/sdk/build_release.go b/sdk/build_release.go index f2379ae36..a3f089973 100644 --- a/sdk/build_release.go +++ b/sdk/build_release.go @@ -16,6 +16,7 @@ package sdk import ( "fmt" + "reflect" "strings" ) @@ -158,3 +159,166 @@ func parseBuildReleaseSet(specification string) (*buildReleaseSet, error) { return set, nil } + +// Given a set of properties (struct value), set the value of a field within that struct (or one of +// its embedded structs) to its zero value. +type fieldPrunerFunc func(structValue reflect.Value) + +// A property that can be cleared by a propertyPruner. +type prunerProperty struct { + // The name of the field for this property. It is a "."-separated path for fields in non-anonymous + // sub-structs. + name string + + // Sets the associated field to its zero value. + prunerFunc fieldPrunerFunc +} + +// propertyPruner provides support for pruning (i.e. setting to their zero value) properties from +// a properties structure. +type propertyPruner struct { + // The properties that the pruner will clear. + properties []prunerProperty +} + +// gatherFields recursively processes the supplied structure and a nested structures, selecting the +// fields that require pruning and populates the propertyPruner.properties with the information +// needed to prune those fields. +// +// containingStructAccessor is a func that if given an object will return a field whose value is +// of the supplied structType. It is nil on initial entry to this method but when this method is +// called recursively on a field that is a nested structure containingStructAccessor is set to a +// func that provides access to the field's value. +// +// namePrefix is the prefix to the fields that are being visited. It is "" on initial entry to this +// method but when this method is called recursively on a field that is a nested structure +// namePrefix is the result of appending the field name (plus a ".") to the previous name prefix. +// Unless the field is anonymous in which case it is passed through unchanged. +// +// selector is a func that will select whether the supplied field requires pruning or not. If it +// returns true then the field will be added to those to be pruned, otherwise it will not. +func (p *propertyPruner) gatherFields(structType reflect.Type, containingStructAccessor fieldAccessorFunc, namePrefix string, selector fieldSelectorFunc) { + for f := 0; f < structType.NumField(); f++ { + field := structType.Field(f) + if field.PkgPath != "" { + // Ignore unexported fields. + continue + } + + // Save a copy of the field index for use in the function. + fieldIndex := f + + name := namePrefix + field.Name + + fieldGetter := func(container reflect.Value) reflect.Value { + if containingStructAccessor != nil { + // This is an embedded structure so first access the field for the embedded + // structure. + container = containingStructAccessor(container) + } + + // Skip through interface and pointer values to find the structure. + container = getStructValue(container) + + defer func() { + if r := recover(); r != nil { + panic(fmt.Errorf("%s for fieldIndex %d of field %s of container %#v", r, fieldIndex, name, container.Interface())) + } + }() + + // Return the field. + return container.Field(fieldIndex) + } + + zeroValue := reflect.Zero(field.Type) + fieldPruner := func(container reflect.Value) { + if containingStructAccessor != nil { + // This is an embedded structure so first access the field for the embedded + // structure. + container = containingStructAccessor(container) + } + + // Skip through interface and pointer values to find the structure. + container = getStructValue(container) + + defer func() { + if r := recover(); r != nil { + panic(fmt.Errorf("%s for fieldIndex %d of field %s of container %#v", r, fieldIndex, name, container.Interface())) + } + }() + + // Set the field. + container.Field(fieldIndex).Set(zeroValue) + } + + if selector(name, field) { + property := prunerProperty{ + name, + fieldPruner, + } + p.properties = append(p.properties, property) + } else if field.Type.Kind() == reflect.Struct { + // Gather fields from the nested or embedded structure. + var subNamePrefix string + if field.Anonymous { + subNamePrefix = namePrefix + } else { + subNamePrefix = name + "." + } + p.gatherFields(field.Type, fieldGetter, subNamePrefix, selector) + } + } +} + +// pruneProperties will prune (set to zero value) any properties in the supplied struct. +// +// The struct must be of the same type as was originally passed to newPropertyPruner to create this +// propertyPruner. +func (p *propertyPruner) pruneProperties(propertiesStruct interface{}) { + structValue := reflect.ValueOf(propertiesStruct) + for _, property := range p.properties { + property.prunerFunc(structValue) + } +} + +// fieldSelectorFunc is called to select whether a specific field should be pruned or not. +// name is the name of the field, including any prefixes from containing str +type fieldSelectorFunc func(name string, field reflect.StructField) bool + +// newPropertyPruner creates a new property pruner for the structure type for the supplied +// properties struct. +// +// The returned pruner can be used on any properties structure of the same type as the supplied set +// of properties. +func newPropertyPruner(propertiesStruct interface{}, selector fieldSelectorFunc) *propertyPruner { + structType := getStructValue(reflect.ValueOf(propertiesStruct)).Type() + pruner := &propertyPruner{} + pruner.gatherFields(structType, nil, "", selector) + return pruner +} + +// newPropertyPrunerByBuildRelease creates a property pruner that will clear any properties in the +// structure which are not supported by the specified target build release. +// +// A property is pruned if its field has a tag of the form: +// `supported_build_releases:""` +// and the resulting build release set does not contain the target build release. Properties that +// have no such tag are assumed to be supported by all releases. +func newPropertyPrunerByBuildRelease(propertiesStruct interface{}, targetBuildRelease *buildRelease) *propertyPruner { + return newPropertyPruner(propertiesStruct, func(name string, field reflect.StructField) bool { + if supportedBuildReleases, ok := field.Tag.Lookup("supported_build_releases"); ok { + set, err := parseBuildReleaseSet(supportedBuildReleases) + if err != nil { + panic(fmt.Errorf("invalid `supported_build_releases` tag on %s of %T: %s", name, propertiesStruct, err)) + } + + // If the field does not support tha target release then prune it. + return !set.contains(targetBuildRelease) + + } else { + // Any untagged fields are assumed to be supported by all build releases so should never be + // pruned. + return false + } + }) +} diff --git a/sdk/build_release_test.go b/sdk/build_release_test.go index fa6591cb8..dff276d0c 100644 --- a/sdk/build_release_test.go +++ b/sdk/build_release_test.go @@ -98,3 +98,88 @@ func TestBuildReleaseSetContains(t *testing.T) { android.AssertBoolEquals(t, "set does not contain T", false, set.contains(buildReleaseT)) }) } + +func TestPropertyPrunerInvalidTag(t *testing.T) { + type brokenStruct struct { + Broken string `supported_build_releases:"A"` + } + type containingStruct struct { + Nested brokenStruct + } + + t.Run("broken struct", func(t *testing.T) { + android.AssertPanicMessageContains(t, "error", "invalid `supported_build_releases` tag on Broken of *sdk.brokenStruct: unknown release \"A\"", func() { + newPropertyPrunerByBuildRelease(&brokenStruct{}, buildReleaseS) + }) + }) + + t.Run("nested broken struct", func(t *testing.T) { + android.AssertPanicMessageContains(t, "error", "invalid `supported_build_releases` tag on Nested.Broken of *sdk.containingStruct: unknown release \"A\"", func() { + newPropertyPrunerByBuildRelease(&containingStruct{}, buildReleaseS) + }) + }) +} + +func TestPropertyPrunerByBuildRelease(t *testing.T) { + type nested struct { + F1_only string `supported_build_releases:"F1"` + } + + type testBuildReleasePruner struct { + Default string + S_and_T_only string `supported_build_releases:"S-T"` + T_later string `supported_build_releases:"T+"` + Nested nested + } + + input := testBuildReleasePruner{ + Default: "Default", + S_and_T_only: "S_and_T_only", + T_later: "T_later", + Nested: nested{ + F1_only: "F1_only", + }, + } + + t.Run("target S", func(t *testing.T) { + testStruct := input + pruner := newPropertyPrunerByBuildRelease(&testStruct, buildReleaseS) + pruner.pruneProperties(&testStruct) + + expected := input + expected.T_later = "" + expected.Nested.F1_only = "" + android.AssertDeepEquals(t, "test struct", expected, testStruct) + }) + + t.Run("target T", func(t *testing.T) { + testStruct := input + pruner := newPropertyPrunerByBuildRelease(&testStruct, buildReleaseT) + pruner.pruneProperties(&testStruct) + + expected := input + expected.Nested.F1_only = "" + android.AssertDeepEquals(t, "test struct", expected, testStruct) + }) + + t.Run("target F1", func(t *testing.T) { + testStruct := input + pruner := newPropertyPrunerByBuildRelease(&testStruct, buildReleaseFuture1) + pruner.pruneProperties(&testStruct) + + expected := input + expected.S_and_T_only = "" + android.AssertDeepEquals(t, "test struct", expected, testStruct) + }) + + t.Run("target F2", func(t *testing.T) { + testStruct := input + pruner := newPropertyPrunerByBuildRelease(&testStruct, buildReleaseFuture2) + pruner.pruneProperties(&testStruct) + + expected := input + expected.S_and_T_only = "" + expected.Nested.F1_only = "" + android.AssertDeepEquals(t, "test struct", expected, testStruct) + }) +} From 24c545e31760977db95765dda7e840d88497be83 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 24 Sep 2021 14:58:27 +0100 Subject: [PATCH 083/148] Support generating sdk snapshot for specific build release Previously, the sdk snapshot was assumed to be generated for the current build system. This change adds support for the SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE environment variable which can be used to select the target build release in which the generated snapshot will be used. At the moment this will only affect the properties that are output but if/when it becomes necessary it can also be used to control more aspects of the snapshots such as supported member types or even members. This change does not modify any properties that are build release specific. That will come in following changes. However, it does add a test that targets build release S which defines a baseline for properties that will be affected in following changes. That baseline makes it easier to see the effect of those follow up changes. Bug: 197842263 Test: m nothing Change-Id: I5cfde5e9e86af522b0d5030d301e116b0233fd62 Merged-In: I5cfde5e9e86af522b0d5030d301e116b0233fd62 (cherry picked from commit ef2df587be53a1a58fc35f195a4226170df17dbb) --- sdk/sdk_test.go | 86 +++++++++++++++++++++++++++++++++++++++++++- sdk/testing.go | 11 ++++++ sdk/update.go | 75 ++++++++++++++++++++++++++++++++++++-- ui/build/dumpvars.go | 1 + 4 files changed, 170 insertions(+), 3 deletions(-) diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go index a13b0d7d0..969462b04 100644 --- a/sdk/sdk_test.go +++ b/sdk/sdk_test.go @@ -15,11 +15,13 @@ package sdk import ( - "android/soong/android" "log" "os" "testing" + "android/soong/android" + "android/soong/java" + "github.com/google/blueprint/proptools" ) @@ -661,4 +663,86 @@ sdk_snapshot { snapshotTestPreparer(checkSnapshotWithoutSource, android.FixtureWithRootAndroidBp(bp)), ) }) + + t.Run("SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE=S", func(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForSdkTestWithJava, + java.PrepareForTestWithJavaDefaultModules, + java.PrepareForTestWithJavaSdkLibraryFiles, + java.FixtureWithLastReleaseApis("mysdklibrary"), + android.FixtureWithRootAndroidBp(` + sdk { + name: "mysdk", + bootclasspath_fragments: ["mybootclasspathfragment"], + } + + bootclasspath_fragment { + name: "mybootclasspathfragment", + apex_available: ["myapex"], + contents: ["mysdklibrary"], + } + + java_sdk_library { + name: "mysdklibrary", + srcs: ["Test.java"], + compile_dex: true, + public: {enabled: true}, + permitted_packages: ["mysdklibrary"], + } + `), + android.FixtureMergeEnv(map[string]string{ + "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S", + }), + ).RunTest(t) + + CheckSnapshot(t, result, "mysdk", "", + checkUnversionedAndroidBpContents(` +// This is auto-generated. DO NOT EDIT. + +prebuilt_bootclasspath_fragment { + name: "mybootclasspathfragment", + prefer: false, + visibility: ["//visibility:public"], + apex_available: ["myapex"], + contents: ["mysdklibrary"], + hidden_api: { + stub_flags: "hiddenapi/stub-flags.csv", + annotation_flags: "hiddenapi/annotation-flags.csv", + metadata: "hiddenapi/metadata.csv", + index: "hiddenapi/index.csv", + all_flags: "hiddenapi/all-flags.csv", + }, +} + +java_sdk_library_import { + name: "mysdklibrary", + prefer: false, + visibility: ["//visibility:public"], + apex_available: ["//apex_available:platform"], + shared_library: true, + compile_dex: true, + permitted_packages: ["mysdklibrary"], + public: { + jars: ["sdk_library/public/mysdklibrary-stubs.jar"], + stub_srcs: ["sdk_library/public/mysdklibrary_stub_sources"], + current_api: "sdk_library/public/mysdklibrary.txt", + removed_api: "sdk_library/public/mysdklibrary-removed.txt", + sdk_version: "current", + }, +} +`), + + checkAllCopyRules(` +.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/stub-flags.csv -> hiddenapi/stub-flags.csv +.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/annotation-flags.csv -> hiddenapi/annotation-flags.csv +.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/metadata.csv -> hiddenapi/metadata.csv +.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/index.csv -> hiddenapi/index.csv +.intermediates/mybootclasspathfragment/android_common/modular-hiddenapi/all-flags.csv -> hiddenapi/all-flags.csv +.intermediates/mysdklibrary.stubs/android_common/javac/mysdklibrary.stubs.jar -> sdk_library/public/mysdklibrary-stubs.jar +.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_api.txt -> sdk_library/public/mysdklibrary.txt +.intermediates/mysdklibrary.stubs.source/android_common/metalava/mysdklibrary.stubs.source_removed.txt -> sdk_library/public/mysdklibrary-removed.txt +`), + ) + }) + } diff --git a/sdk/testing.go b/sdk/testing.go index 3254cf9f3..294f1a57d 100644 --- a/sdk/testing.go +++ b/sdk/testing.go @@ -136,6 +136,7 @@ func getSdkSnapshotBuildInfo(t *testing.T, result *android.TestResult, sdk *sdk) androidUnversionedBpContents: sdk.GetUnversionedAndroidBpContentsForTests(), androidVersionedBpContents: sdk.GetVersionedAndroidBpContentsForTests(), snapshotTestCustomizations: map[snapshotTest]*snapshotTestCustomization{}, + targetBuildRelease: sdk.builderForTests.targetBuildRelease, } buildParams := sdk.BuildParamsForTests() @@ -253,6 +254,13 @@ func CheckSnapshot(t *testing.T, result *android.TestResult, name string, dir st } fs[filepath.Join(snapshotSubDir, "Android.bp")] = []byte(snapshotBuildInfo.androidBpContents) + // If the generated snapshot builders not for the current release then it cannot be loaded by + // the current release. + currentBuildRelease := latestBuildRelease() + if snapshotBuildInfo.targetBuildRelease != currentBuildRelease { + return + } + // The preparers from the original source fixture. sourcePreparers := result.Preparer() @@ -476,6 +484,9 @@ type snapshotBuildInfo struct { // The final output zip. outputZip string + // The target build release. + targetBuildRelease *buildRelease + // The test specific customizations for each snapshot test. snapshotTestCustomizations map[snapshotTest]*snapshotTestCustomization } diff --git a/sdk/update.go b/sdk/update.go index cc06c3b1c..d9c57c375 100644 --- a/sdk/update.go +++ b/sdk/update.go @@ -50,6 +50,19 @@ import ( // snapshot module only. The zip file containing the generated snapshot will be // -.zip. // +// SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE +// This allows the target build release (i.e. the release version of the build within which +// the snapshot will be used) of the snapshot to be specified. If unspecified then it defaults +// to the current build release version. Otherwise, it must be the name of one of the build +// releases defined in nameToBuildRelease, e.g. S, T, etc.. +// +// The generated snapshot must only be used in the specified target release. If the target +// build release is not the current build release then the generated Android.bp file not be +// checked for compatibility. +// +// e.g. if setting SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE=S will cause the generated snapshot +// to be compatible with S. +// var pctx = android.NewPackageContext("android/soong/sdk") @@ -319,6 +332,14 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro snapshotZipFileSuffix = "-" + version } + currentBuildRelease := latestBuildRelease() + targetBuildReleaseEnv := config.GetenvWithDefault("SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE", currentBuildRelease.name) + targetBuildRelease, err := nameToRelease(targetBuildReleaseEnv) + if err != nil { + ctx.ModuleErrorf("invalid SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE: %s", err) + targetBuildRelease = currentBuildRelease + } + builder := &snapshotBuilder{ ctx: ctx, sdk: s, @@ -330,6 +351,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro prebuiltModules: make(map[string]*bpModule), allMembersByName: allMembersByName, exportedMembersByName: exportedMembersByName, + targetBuildRelease: targetBuildRelease, } s.builderForTests = builder @@ -402,7 +424,11 @@ be unnecessary as every module in the sdk already has its own licenses property. generateBpContents(&bp.generatedContents, bpFile) contents := bp.content.String() - syntaxCheckSnapshotBpFile(ctx, contents) + // If the snapshot is being generated for the current build release then check the syntax to make + // sure that it is compatible. + if targetBuildRelease == currentBuildRelease { + syntaxCheckSnapshotBpFile(ctx, contents) + } bp.build(pctx, ctx, nil) @@ -939,6 +965,9 @@ type snapshotBuilder struct { // The set of exported members by name. exportedMembersByName map[string]struct{} + + // The target build release for which the snapshot is to be generated. + targetBuildRelease *buildRelease } func (s *snapshotBuilder) CopyToSnapshot(src android.Path, dest string) { @@ -1303,6 +1332,16 @@ func newOsTypeSpecificInfo(ctx android.SdkMemberContext, osType android.OsType, return osInfo } +func (osInfo *osTypeSpecificInfo) pruneUnsupportedProperties(pruner *propertyPruner) { + if len(osInfo.archInfos) == 0 { + pruner.pruneProperties(osInfo.Properties) + } else { + for _, archInfo := range osInfo.archInfos { + archInfo.pruneUnsupportedProperties(pruner) + } + } +} + // Optimize the properties by extracting common properties from arch type specific // properties into os type specific properties. func (osInfo *osTypeSpecificInfo) optimizeProperties(ctx *memberContext, commonValueExtractor *commonValueExtractor) { @@ -1472,6 +1511,16 @@ func getLinkType(variant android.Module) string { return linkType } +func (archInfo *archTypeSpecificInfo) pruneUnsupportedProperties(pruner *propertyPruner) { + if len(archInfo.imageVariantInfos) == 0 { + pruner.pruneProperties(archInfo.Properties) + } else { + for _, imageVariantInfo := range archInfo.imageVariantInfos { + imageVariantInfo.pruneUnsupportedProperties(pruner) + } + } +} + // Optimize the properties by extracting common properties from link type specific // properties into arch type specific properties. func (archInfo *archTypeSpecificInfo) optimizeProperties(ctx *memberContext, commonValueExtractor *commonValueExtractor) { @@ -1557,6 +1606,16 @@ func newImageVariantSpecificInfo(ctx android.SdkMemberContext, imageVariant stri return imageInfo } +func (imageInfo *imageVariantSpecificInfo) pruneUnsupportedProperties(pruner *propertyPruner) { + if len(imageInfo.linkInfos) == 0 { + pruner.pruneProperties(imageInfo.Properties) + } else { + for _, linkInfo := range imageInfo.linkInfos { + linkInfo.pruneUnsupportedProperties(pruner) + } + } +} + // Optimize the properties by extracting common properties from link type specific // properties into arch type specific properties. func (imageInfo *imageVariantSpecificInfo) optimizeProperties(ctx *memberContext, commonValueExtractor *commonValueExtractor) { @@ -1623,6 +1682,10 @@ func (l *linkTypeSpecificInfo) addToPropertySet(ctx *memberContext, propertySet addSdkMemberPropertiesToSet(ctx, l.Properties, linkPropertySet) } +func (l *linkTypeSpecificInfo) pruneUnsupportedProperties(pruner *propertyPruner) { + pruner.pruneProperties(l.Properties) +} + func (l *linkTypeSpecificInfo) String() string { return fmt.Sprintf("LinkType{%s}", l.linkType) } @@ -1655,12 +1718,13 @@ func (s *sdk) createMemberSnapshot(ctx *memberContext, member *sdkMember, bpModu memberType := member.memberType // Do not add the prefer property if the member snapshot module is a source module type. + config := ctx.sdkMemberContext.Config() if !memberType.UsesSourceModuleTypeInSnapshot() { // Set the prefer based on the environment variable. This is a temporary work around to allow a // snapshot to be created that sets prefer: true. // TODO(b/174997203): Remove once the ability to select the modules to prefer can be done // dynamically at build time not at snapshot generation time. - prefer := ctx.sdkMemberContext.Config().IsEnvTrue("SOONG_SDK_SNAPSHOT_PREFER") + prefer := config.IsEnvTrue("SOONG_SDK_SNAPSHOT_PREFER") // Set prefer. Setting this to false is not strictly required as that is the default but it does // provide a convenient hook to post-process the generated Android.bp file, e.g. in tests to @@ -1691,6 +1755,11 @@ func (s *sdk) createMemberSnapshot(ctx *memberContext, member *sdkMember, bpModu commonProperties := variantPropertiesFactory() commonProperties.Base().Os = android.CommonOS + // Create a property pruner that will prune any properties unsupported by the target build + // release. + targetBuildRelease := ctx.builder.targetBuildRelease + unsupportedPropertyPruner := newPropertyPrunerByBuildRelease(commonProperties, targetBuildRelease) + // Create common value extractor that can be used to optimize the properties. commonValueExtractor := newCommonValueExtractor(commonProperties) @@ -1705,6 +1774,8 @@ func (s *sdk) createMemberSnapshot(ctx *memberContext, member *sdkMember, bpModu // independent properties structs. osSpecificPropertiesContainers = append(osSpecificPropertiesContainers, osInfo) + osInfo.pruneUnsupportedProperties(unsupportedPropertyPruner) + // Optimize the properties across all the variants for a specific os type. osInfo.optimizeProperties(ctx, commonValueExtractor) } diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go index 54aeda082..248ad50d7 100644 --- a/ui/build/dumpvars.go +++ b/ui/build/dumpvars.go @@ -163,6 +163,7 @@ var BannerVars = []string{ "AUX_OS_VARIANT_LIST", "PRODUCT_SOONG_NAMESPACES", "SOONG_SDK_SNAPSHOT_PREFER", + "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE", "SOONG_SDK_SNAPSHOT_VERSION", } From 2f94ca54755e5e5a8dca35d71a40dc7455804f0f Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 27 Jan 2022 16:51:51 +0000 Subject: [PATCH 084/148] Refactor build_release and test code Minor restructuring of the build_release pruning code to make it easier to add logic for handling fields of maps of structs. That includes: 1. Moving some code that is specific to clearing a selected field inside the associated if block. 2. Replacing an if with a switch. 3. Improving the error handling by separating the reporting of the container that broke from information about which field could not be set. That allows follow up code to provide information about the map key instead. The tests were restructed by: 1. Switching from using AssertDeepEquals to compare the structs to comparing the output of marshalling the structs to JSON. That was for a couple of reasons. Firstly, because JSON will marshal (and so allow comparison of) the contents of pointers to structs whereas AssertDeepEquals will just compare the pointers themselves. Secondly, because JSON can pretty print the output and make it easier to read. 2. Using a func to create a new instance of the input structure for each test. That is to allow the test to modify the input structure, e.g. by clearing a field in a struct that is pointed to by a map. The test previously relied on the input structure being immutable and passed by value but a follow up change will change that by adding a map field that contains pointers to structs. Bug: 204763318 Test: m nothing Merged-In: I84dc99621497b7263e30466895b823eb02cb2b56 Change-Id: I84dc99621497b7263e30466895b823eb02cb2b56 (cherry picked from commit 545c59273de8e741ca8820656d972fbeb03f1ef9) --- sdk/build_release.go | 70 +++++++++++++++++++++++---------------- sdk/build_release_test.go | 58 +++++++++++++++++++++----------- 2 files changed, 80 insertions(+), 48 deletions(-) diff --git a/sdk/build_release.go b/sdk/build_release.go index a3f089973..212582ac6 100644 --- a/sdk/build_release.go +++ b/sdk/build_release.go @@ -230,51 +230,63 @@ func (p *propertyPruner) gatherFields(structType reflect.Type, containingStructA return container.Field(fieldIndex) } - zeroValue := reflect.Zero(field.Type) - fieldPruner := func(container reflect.Value) { - if containingStructAccessor != nil { - // This is an embedded structure so first access the field for the embedded - // structure. - container = containingStructAccessor(container) + fieldType := field.Type + if selector(name, field) { + zeroValue := reflect.Zero(fieldType) + fieldPruner := func(container reflect.Value) { + if containingStructAccessor != nil { + // This is an embedded structure so first access the field for the embedded + // structure. + container = containingStructAccessor(container) + } + + // Skip through interface and pointer values to find the structure. + container = getStructValue(container) + + defer func() { + if r := recover(); r != nil { + panic(fmt.Errorf("%s\n\tfor field (index %d, name %s)", r, fieldIndex, name)) + } + }() + + // Set the field. + container.Field(fieldIndex).Set(zeroValue) } - // Skip through interface and pointer values to find the structure. - container = getStructValue(container) - - defer func() { - if r := recover(); r != nil { - panic(fmt.Errorf("%s for fieldIndex %d of field %s of container %#v", r, fieldIndex, name, container.Interface())) - } - }() - - // Set the field. - container.Field(fieldIndex).Set(zeroValue) - } - - if selector(name, field) { property := prunerProperty{ name, fieldPruner, } p.properties = append(p.properties, property) - } else if field.Type.Kind() == reflect.Struct { - // Gather fields from the nested or embedded structure. - var subNamePrefix string - if field.Anonymous { - subNamePrefix = namePrefix - } else { - subNamePrefix = name + "." + } else { + switch fieldType.Kind() { + case reflect.Struct: + // Gather fields from the nested or embedded structure. + var subNamePrefix string + if field.Anonymous { + subNamePrefix = namePrefix + } else { + subNamePrefix = name + "." + } + p.gatherFields(fieldType, fieldGetter, subNamePrefix, selector) } - p.gatherFields(field.Type, fieldGetter, subNamePrefix, selector) } } } -// pruneProperties will prune (set to zero value) any properties in the supplied struct. +// pruneProperties will prune (set to zero value) any properties in the struct referenced by the +// supplied struct pointer. // // The struct must be of the same type as was originally passed to newPropertyPruner to create this // propertyPruner. func (p *propertyPruner) pruneProperties(propertiesStruct interface{}) { + + defer func() { + if r := recover(); r != nil { + panic(fmt.Errorf("%s\n\tof container %#v", r, propertiesStruct)) + } + }() + structValue := reflect.ValueOf(propertiesStruct) for _, property := range p.properties { property.prunerFunc(structValue) diff --git a/sdk/build_release_test.go b/sdk/build_release_test.go index dff276d0c..0ec10409f 100644 --- a/sdk/build_release_test.go +++ b/sdk/build_release_test.go @@ -15,6 +15,7 @@ package sdk import ( + "encoding/json" "fmt" "testing" @@ -132,54 +133,73 @@ func TestPropertyPrunerByBuildRelease(t *testing.T) { Nested nested } - input := testBuildReleasePruner{ - Default: "Default", - S_and_T_only: "S_and_T_only", - T_later: "T_later", - Nested: nested{ - F1_only: "F1_only", - }, + inputFactory := func() testBuildReleasePruner { + return testBuildReleasePruner{ + Default: "Default", + S_and_T_only: "S_and_T_only", + T_later: "T_later", + Nested: nested{ + F1_only: "F1_only", + }, + } + } + + marshal := func(t interface{}) string { + bytes, err := json.MarshalIndent(t, "", " ") + if err != nil { + panic(err) + } + return string(bytes) + } + + assertJsonEquals := func(t *testing.T, expected, actual interface{}) { + t.Helper() + expectedJson := marshal(expected) + actualJson := marshal(actual) + if actualJson != expectedJson { + t.Errorf("test struct: expected:\n%s\n got:\n%s", expectedJson, actualJson) + } } t.Run("target S", func(t *testing.T) { - testStruct := input + testStruct := inputFactory() pruner := newPropertyPrunerByBuildRelease(&testStruct, buildReleaseS) pruner.pruneProperties(&testStruct) - expected := input + expected := inputFactory() expected.T_later = "" expected.Nested.F1_only = "" - android.AssertDeepEquals(t, "test struct", expected, testStruct) + assertJsonEquals(t, expected, testStruct) }) t.Run("target T", func(t *testing.T) { - testStruct := input + testStruct := inputFactory() pruner := newPropertyPrunerByBuildRelease(&testStruct, buildReleaseT) pruner.pruneProperties(&testStruct) - expected := input + expected := inputFactory() expected.Nested.F1_only = "" - android.AssertDeepEquals(t, "test struct", expected, testStruct) + assertJsonEquals(t, expected, testStruct) }) t.Run("target F1", func(t *testing.T) { - testStruct := input + testStruct := inputFactory() pruner := newPropertyPrunerByBuildRelease(&testStruct, buildReleaseFuture1) pruner.pruneProperties(&testStruct) - expected := input + expected := inputFactory() expected.S_and_T_only = "" - android.AssertDeepEquals(t, "test struct", expected, testStruct) + assertJsonEquals(t, expected, testStruct) }) t.Run("target F2", func(t *testing.T) { - testStruct := input + testStruct := inputFactory() pruner := newPropertyPrunerByBuildRelease(&testStruct, buildReleaseFuture2) pruner.pruneProperties(&testStruct) - expected := input + expected := inputFactory() expected.S_and_T_only = "" expected.Nested.F1_only = "" - android.AssertDeepEquals(t, "test struct", expected, testStruct) + assertJsonEquals(t, expected, testStruct) }) } From 56f266d22c8f3740961ef8c5825d0c2d3419e66e Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 27 Jan 2022 16:39:06 +0000 Subject: [PATCH 085/148] Allow pruning of unsupported fields in structs in maps Adds support for traversing into a field that is of type: map[...]*struct{...} This is needed to allow java_sdk_library to mark scope specific properties, e.g. public.annotations as being target build release specific. It was necessary to change the Scope field from: Scope map[*apiScope]scopeProperties to: Scope map[*apiScope]*scopeProperties That is because there is no way in go to change the field of a struct value of a map. i.e. you cannot do the following, not even using reflection: Scope[apiScopePublic].AnnotationsZip = nil Bug: 204763318 Test: m nothing Merged-In: Id103f70f55d4202971321ef4925cbec4b55f8136 Change-Id: Id103f70f55d4202971321ef4925cbec4b55f8136 (cherry picked from commit 106a3a4bec44f8d1120f72dc52f6d2c797f3a80e) --- java/sdk_library.go | 6 ++--- sdk/build_release.go | 52 +++++++++++++++++++++++++++++++++++++++ sdk/build_release_test.go | 22 +++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index c6747c730..1ae5535da 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -2536,7 +2536,7 @@ type sdkLibrarySdkMemberProperties struct { android.SdkMemberPropertiesBase // Scope to per scope properties. - Scopes map[*apiScope]scopeProperties + Scopes map[*apiScope]*scopeProperties // The Java stubs source files. Stub_srcs []string @@ -2569,7 +2569,7 @@ type scopeProperties struct { func (s *sdkLibrarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) { sdk := variant.(*SdkLibrary) - s.Scopes = make(map[*apiScope]scopeProperties) + s.Scopes = make(map[*apiScope]*scopeProperties) for _, apiScope := range allApiScopes { paths := sdk.findScopePaths(apiScope) if paths == nil { @@ -2592,7 +2592,7 @@ func (s *sdkLibrarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMembe if paths.annotationsZip.Valid() { properties.AnnotationsZip = paths.annotationsZip.Path() } - s.Scopes[apiScope] = properties + s.Scopes[apiScope] = &properties } } diff --git a/sdk/build_release.go b/sdk/build_release.go index 212582ac6..2bcdc6f57 100644 --- a/sdk/build_release.go +++ b/sdk/build_release.go @@ -269,6 +269,51 @@ func (p *propertyPruner) gatherFields(structType reflect.Type, containingStructA subNamePrefix = name + "." } p.gatherFields(fieldType, fieldGetter, subNamePrefix, selector) + + case reflect.Map: + // Get the type of the values stored in the map. + valueType := fieldType.Elem() + // Skip over * types. + if valueType.Kind() == reflect.Ptr { + valueType = valueType.Elem() + } + if valueType.Kind() == reflect.Struct { + // If this is not referenced by a pointer then it is an error as it is impossible to + // modify a struct that is stored directly as a value in a map. + if fieldType.Elem().Kind() != reflect.Ptr { + panic(fmt.Errorf("Cannot prune struct %s stored by value in map %s, map values must"+ + " be pointers to structs", + fieldType.Elem(), name)) + } + + // Create a new pruner for the values of the map. + valuePruner := newPropertyPrunerForStructType(valueType, selector) + + // Create a new fieldPruner that will iterate over all the items in the map and call the + // pruner on them. + fieldPruner := func(container reflect.Value) { + mapValue := fieldGetter(container) + + for _, keyValue := range mapValue.MapKeys() { + itemValue := mapValue.MapIndex(keyValue) + + defer func() { + if r := recover(); r != nil { + panic(fmt.Errorf("%s\n\tfor key %q", r, keyValue)) + } + }() + + valuePruner.pruneProperties(itemValue.Interface()) + } + } + + // Add the map field pruner to the list of property pruners. + property := prunerProperty{ + name + "[*]", + fieldPruner, + } + p.properties = append(p.properties, property) + } } } } @@ -304,6 +349,13 @@ type fieldSelectorFunc func(name string, field reflect.StructField) bool // of properties. func newPropertyPruner(propertiesStruct interface{}, selector fieldSelectorFunc) *propertyPruner { structType := getStructValue(reflect.ValueOf(propertiesStruct)).Type() + return newPropertyPrunerForStructType(structType, selector) +} + +// newPropertyPruner creates a new property pruner for the supplied properties struct type. +// +// The returned pruner can be used on any properties structure of the supplied type. +func newPropertyPrunerForStructType(structType reflect.Type, selector fieldSelectorFunc) *propertyPruner { pruner := &propertyPruner{} pruner.gatherFields(structType, nil, "", selector) return pruner diff --git a/sdk/build_release_test.go b/sdk/build_release_test.go index 0ec10409f..6608be4f8 100644 --- a/sdk/build_release_test.go +++ b/sdk/build_release_test.go @@ -126,11 +126,17 @@ func TestPropertyPrunerByBuildRelease(t *testing.T) { F1_only string `supported_build_releases:"F1"` } + type mapped struct { + Default string + T_only string `supported_build_releases:"T"` + } + type testBuildReleasePruner struct { Default string S_and_T_only string `supported_build_releases:"S-T"` T_later string `supported_build_releases:"T+"` Nested nested + Mapped map[string]*mapped } inputFactory := func() testBuildReleasePruner { @@ -141,6 +147,16 @@ func TestPropertyPrunerByBuildRelease(t *testing.T) { Nested: nested{ F1_only: "F1_only", }, + Mapped: map[string]*mapped{ + "one": { + Default: "one-default", + T_only: "one-t-only", + }, + "two": { + Default: "two-default", + T_only: "two-t-only", + }, + }, } } @@ -169,6 +185,8 @@ func TestPropertyPrunerByBuildRelease(t *testing.T) { expected := inputFactory() expected.T_later = "" expected.Nested.F1_only = "" + expected.Mapped["one"].T_only = "" + expected.Mapped["two"].T_only = "" assertJsonEquals(t, expected, testStruct) }) @@ -189,6 +207,8 @@ func TestPropertyPrunerByBuildRelease(t *testing.T) { expected := inputFactory() expected.S_and_T_only = "" + expected.Mapped["one"].T_only = "" + expected.Mapped["two"].T_only = "" assertJsonEquals(t, expected, testStruct) }) @@ -200,6 +220,8 @@ func TestPropertyPrunerByBuildRelease(t *testing.T) { expected := inputFactory() expected.S_and_T_only = "" expected.Nested.F1_only = "" + expected.Mapped["one"].T_only = "" + expected.Mapped["two"].T_only = "" assertJsonEquals(t, expected, testStruct) }) } From 7a57bb106322b3caaf6395ea2dd2f81aeef35c92 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 27 Jan 2022 16:39:47 +0000 Subject: [PATCH 086/148] Only output annotations properties in snapshots for T+ Marks the `scopeProperties.AnnotationsZip` property as only being supported on T builds and above. Bug: 204763318 Test: m nothing Merged-In: Ie59396287c08da77a6a1f15d4be202429e011e17 Change-Id: Ie59396287c08da77a6a1f15d4be202429e011e17 (cherry picked from commit a54016c3ba5db8efd69d098e0bb4cb8b318d2efa) --- java/sdk_library.go | 2 +- sdk/java_sdk_test.go | 52 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index 1ae5535da..4f0b346fe 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -2562,7 +2562,7 @@ type scopeProperties struct { StubsSrcJar android.Path CurrentApiFile android.Path RemovedApiFile android.Path - AnnotationsZip android.Path + AnnotationsZip android.Path `supported_build_releases:"T+"` SdkVersion string } diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go index 42826b79e..db13e77ac 100644 --- a/sdk/java_sdk_test.go +++ b/sdk/java_sdk_test.go @@ -1253,6 +1253,58 @@ java_sdk_library_import { ) } +func TestSnapshotWithJavaSdkLibrary_AnnotationsZip_PreT(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForSdkTestWithJavaSdkLibrary, + android.FixtureMergeEnv(map[string]string{ + "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S", + }), + ).RunTestWithBp(t, ` + sdk { + name: "mysdk", + java_sdk_libs: ["myjavalib"], + } + + java_sdk_library { + name: "myjavalib", + srcs: ["Test.java"], + sdk_version: "current", + shared_library: false, + annotations_enabled: true, + public: { + enabled: true, + }, + } + `) + + CheckSnapshot(t, result, "mysdk", "", + checkUnversionedAndroidBpContents(` +// This is auto-generated. DO NOT EDIT. + +java_sdk_library_import { + name: "myjavalib", + prefer: false, + visibility: ["//visibility:public"], + apex_available: ["//apex_available:platform"], + shared_library: false, + public: { + jars: ["sdk_library/public/myjavalib-stubs.jar"], + stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], + current_api: "sdk_library/public/myjavalib.txt", + removed_api: "sdk_library/public/myjavalib-removed.txt", + sdk_version: "current", + }, +} + `), + checkAllCopyRules(` +.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar +.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt +.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt + `), + checkMergeZips(".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip"), + ) +} + func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) { result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` sdk { From de1e3008029e847cb8926b178fb9faa6ccfd8756 Mon Sep 17 00:00:00 2001 From: Ray Essick Date: Thu, 10 Feb 2022 17:37:51 -0800 Subject: [PATCH 087/148] Clean auto-allowed modules for media mainline Cleans out the remaining modules that build system auto-allowed for the media mainline modules com.android.media and com.android.media.swcodec. With this change, both lists are empty and all needed modules are documented with explicit apex_available clauses. Bug: 215589022 Bug: 147364041 Test: build Change-Id: I7d809ae72ad21f6b2ed8b05613c44019a974f6fd --- apex/apex.go | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 56656ed1f..b2e4fe96a 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -2772,27 +2772,7 @@ func makeApexAvailableBaseline() map[string][]string { // Module separator // m["com.android.media.swcodec"] = []string{ - "android.hardware.graphics.allocator@2.0", - "android.hardware.graphics.allocator@3.0", - "android.hardware.graphics.allocator@4.0", - "android.hardware.graphics.common@1.0", - "android.hardware.graphics.common@1.1", - "android.hardware.graphics.common@1.2", - "android.hardware.graphics.mapper@2.0", - "android.hardware.graphics.mapper@2.1", - "android.hardware.graphics.mapper@3.0", - "android.hardware.graphics.mapper@4.0", - "libLibGuiProperties", - "libfmq", - "libgrallocusage", - "libgui_headers", - "libhardware", - "libhardware_headers", - "libion", - "libnativebase_headers", - "libnativewindow_headers", - "libui", - "libui_headers", + // empty } // // Module separator From 9b4eab604dd63cd1b99d25d4eff01306d0a6e1b2 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 10 Feb 2022 13:06:54 +0000 Subject: [PATCH 088/148] Use Tiramisu instead of T in supported_build_releases Make this consistent with how code names are used in the rest of Soong. Bug: 204763318 Test: m nothing Change-Id: I1f2f40310df9d619db6aaaad3ed7339bb5e79194 Merged-In: I1f2f40310df9d619db6aaaad3ed7339bb5e79194 (cherry picked from commit e7babdbfe14abb57aacd36f8d92a8af9efaa7a97) --- java/sdk_library.go | 2 +- sdk/build_release.go | 2 +- sdk/build_release_test.go | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index 4f0b346fe..3ecba9ae9 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -2562,7 +2562,7 @@ type scopeProperties struct { StubsSrcJar android.Path CurrentApiFile android.Path RemovedApiFile android.Path - AnnotationsZip android.Path `supported_build_releases:"T+"` + AnnotationsZip android.Path `supported_build_releases:"Tiramisu+"` SdkVersion string } diff --git a/sdk/build_release.go b/sdk/build_release.go index 2bcdc6f57..4c2277e85 100644 --- a/sdk/build_release.go +++ b/sdk/build_release.go @@ -85,7 +85,7 @@ var ( // Add the build releases from oldest to newest. buildReleaseS = initBuildRelease("S") - buildReleaseT = initBuildRelease("T") + buildReleaseT = initBuildRelease("Tiramisu") ) // initBuildRelease creates a new build release with the specified name. diff --git a/sdk/build_release_test.go b/sdk/build_release_test.go index 6608be4f8..6f1ef9e30 100644 --- a/sdk/build_release_test.go +++ b/sdk/build_release_test.go @@ -60,7 +60,7 @@ func TestParseBuildReleaseSet(t *testing.T) { t.Run("closed range", func(t *testing.T) { set, err := parseBuildReleaseSet("S-F1") android.AssertDeepEquals(t, "errors", nil, err) - android.AssertStringEquals(t, "set", "[S,T,F1]", set.String()) + android.AssertStringEquals(t, "set", "[S,Tiramisu,F1]", set.String()) }) invalidAReleaseMessage := `unknown release "A", expected one of ` + allBuildReleaseSet.String() t.Run("invalid release", func(t *testing.T) { @@ -79,7 +79,7 @@ func TestParseBuildReleaseSet(t *testing.T) { android.AssertStringDoesContain(t, "errors", fmt.Sprint(err), invalidAReleaseMessage) }) t.Run("invalid release in closed range end", func(t *testing.T) { - set, err := parseBuildReleaseSet("T-A") + set, err := parseBuildReleaseSet("Tiramisu-A") android.AssertDeepEquals(t, "set", (*buildReleaseSet)(nil), set) android.AssertStringDoesContain(t, "errors", fmt.Sprint(err), invalidAReleaseMessage) }) @@ -128,13 +128,13 @@ func TestPropertyPrunerByBuildRelease(t *testing.T) { type mapped struct { Default string - T_only string `supported_build_releases:"T"` + T_only string `supported_build_releases:"Tiramisu"` } type testBuildReleasePruner struct { Default string - S_and_T_only string `supported_build_releases:"S-T"` - T_later string `supported_build_releases:"T+"` + S_and_T_only string `supported_build_releases:"S-Tiramisu"` + T_later string `supported_build_releases:"Tiramisu+"` Nested nested Mapped map[string]*mapped } From a2ce78f80dd70d4815222a8c10054e8f5d1df0b3 Mon Sep 17 00:00:00 2001 From: zhidou Date: Thu, 17 Feb 2022 02:33:12 +0000 Subject: [PATCH 089/148] Make "overrides" attribute of Android_app overridable Move overrides attribute from appProperties to overridableAppProperties Bug: 220029162 Test: m Change-Id: I6f527df3173f142311734333ad37018c83d5e279 --- java/androidmk.go | 4 +-- java/androidmk_test.go | 46 ++++++++++++++++++++++++++++++ java/app.go | 18 ++++++------ java/app_test.go | 64 ++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 118 insertions(+), 14 deletions(-) diff --git a/java/androidmk.go b/java/androidmk.go index b930441f3..60cd7bc0a 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -430,8 +430,8 @@ func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries { func (a *AndroidApp) getOverriddenPackages() []string { var overridden []string - if len(a.appProperties.Overrides) > 0 { - overridden = append(overridden, a.appProperties.Overrides...) + if len(a.overridableAppProperties.Overrides) > 0 { + overridden = append(overridden, a.overridableAppProperties.Overrides...) } // When APK name is overridden via PRODUCT_PACKAGE_NAME_OVERRIDES // ensure that the original name is overridden. diff --git a/java/androidmk_test.go b/java/androidmk_test.go index 246c0eb07..197da4f38 100644 --- a/java/androidmk_test.go +++ b/java/androidmk_test.go @@ -206,3 +206,49 @@ func TestAndroidTestHelperApp_LocalDisableTestConfig(t *testing.T) { t.Errorf("Unexpected flag value - expected: %q, actual: %q", expected, actual) } } + +func TestGetOverriddenPackages(t *testing.T) { + ctx, _ := testJava( + t, ` + android_app { + name: "foo", + srcs: ["a.java"], + sdk_version: "current", + overrides: ["qux"] + } + + override_android_app { + name: "foo_override", + base: "foo", + overrides: ["bar"] + } + `) + + expectedVariants := []struct { + name string + moduleName string + variantName string + overrides []string + }{ + { + name: "foo", + moduleName: "foo", + variantName: "android_common", + overrides: []string{"qux"}, + }, + { + name: "foo", + moduleName: "foo_override", + variantName: "android_common_foo_override", + overrides: []string{"bar", "foo"}, + }, + } + + for _, expected := range expectedVariants { + mod := ctx.ModuleForTests(expected.name, expected.variantName).Module() + entries := android.AndroidMkEntriesForTest(t, ctx, mod)[0] + actual := entries.EntryMap["LOCAL_OVERRIDES_PACKAGES"] + + android.AssertDeepEquals(t, "overrides property", expected.overrides, actual) + } +} diff --git a/java/app.go b/java/app.go index d0526b988..5ec6408c4 100755 --- a/java/app.go +++ b/java/app.go @@ -64,13 +64,6 @@ type appProperties struct { // list of resource labels to generate individual resource packages Package_splits []string - // Names of modules to be overridden. Listed modules can only be other binaries - // (in Make or Soong). - // This does not completely prevent installation of the overridden binaries, but if both - // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed - // from PRODUCT_PACKAGES. - Overrides []string - // list of native libraries that will be provided in or alongside the resulting jar Jni_libs []string `android:"arch_variant"` @@ -137,6 +130,13 @@ type overridableAppProperties struct { // Whether to rename the package in resources to the override name rather than the base name. Defaults to true. Rename_resources_package *bool + + // Names of modules to be overridden. Listed modules can only be other binaries + // (in Make or Soong). + // This does not completely prevent installation of the overridden binaries, but if both + // binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed + // from PRODUCT_PACKAGES. + Overrides []string } type AndroidApp struct { @@ -947,7 +947,7 @@ func AndroidAppFactory() android.Module { android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon) android.InitDefaultableModule(module) - android.InitOverridableModule(module, &module.appProperties.Overrides) + android.InitOverridableModule(module, &module.overridableAppProperties.Overrides) android.InitApexModule(module) android.InitBazelModule(module) @@ -1070,7 +1070,7 @@ func AndroidTestFactory() android.Module { android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon) android.InitDefaultableModule(module) - android.InitOverridableModule(module, &module.appProperties.Overrides) + android.InitOverridableModule(module, &module.overridableAppProperties.Overrides) return module } diff --git a/java/app_test.go b/java/app_test.go index ceeadaf8d..73cf09227 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -1966,7 +1966,7 @@ func TestOverrideAndroidApp(t *testing.T) { // Check if the overrides field values are correctly aggregated. mod := variant.Module().(*AndroidApp) - android.AssertDeepEquals(t, "overrides property", expected.overrides, mod.appProperties.Overrides) + android.AssertDeepEquals(t, "overrides property", expected.overrides, mod.overridableAppProperties.Overrides) // Test Overridable property: Logging_parent logging_parent := mod.aapt.LoggingParent @@ -1984,6 +1984,64 @@ func TestOverrideAndroidApp(t *testing.T) { } } +func TestOverrideAndroidAppOverrides(t *testing.T) { + ctx, _ := testJava( + t, ` + android_app { + name: "foo", + srcs: ["a.java"], + sdk_version: "current", + overrides: ["qux"] + } + + android_app { + name: "bar", + srcs: ["b.java"], + sdk_version: "current", + overrides: ["foo"] + } + + override_android_app { + name: "foo_override", + base: "foo", + overrides: ["bar"] + } + `) + + expectedVariants := []struct { + name string + moduleName string + variantName string + overrides []string + }{ + { + name: "foo", + moduleName: "foo", + variantName: "android_common", + overrides: []string{"qux"}, + }, + { + name: "bar", + moduleName: "bar", + variantName: "android_common", + overrides: []string{"foo"}, + }, + { + name: "foo", + moduleName: "foo_override", + variantName: "android_common_foo_override", + overrides: []string{"bar", "foo"}, + }, + } + for _, expected := range expectedVariants { + variant := ctx.ModuleForTests(expected.name, expected.variantName) + + // Check if the overrides field values are correctly aggregated. + mod := variant.Module().(*AndroidApp) + android.AssertDeepEquals(t, "overrides property", expected.overrides, mod.overridableAppProperties.Overrides) + } +} + func TestOverrideAndroidAppStem(t *testing.T) { ctx, _ := testJava(t, ` android_app { @@ -2164,9 +2222,9 @@ func TestOverrideAndroidTest(t *testing.T) { // Check if the overrides field values are correctly aggregated. mod := variant.Module().(*AndroidTest) - if !reflect.DeepEqual(expected.overrides, mod.appProperties.Overrides) { + if !reflect.DeepEqual(expected.overrides, mod.overridableAppProperties.Overrides) { t.Errorf("Incorrect overrides property value, expected: %q, got: %q", - expected.overrides, mod.appProperties.Overrides) + expected.overrides, mod.overridableAppProperties.Overrides) } // Check if javac classpath has the correct jar file path. This checks instrumentation_for overrides. From 5e48389e0fb8443d46154a909dede5522037e3cd Mon Sep 17 00:00:00 2001 From: William Escande Date: Wed, 2 Mar 2022 20:23:11 +0100 Subject: [PATCH 090/148] Clear apex.go entries for bluetooth libs Test: Build + TH + boot phone & use bluetooth Bug: 216433795 Change-Id: I53652c4c46bf1019a8062210b2503cf0a34d94cc --- apex/apex.go | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index aaa369c44..85d930bbe 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -2671,31 +2671,8 @@ func makeApexAvailableBaseline() map[string][]string { // Module separator // m["com.android.bluetooth"] = []string{ - "android.hardware.audio.common@5.0", - "android.hardware.bluetooth.a2dp@1.0", - "android.hardware.bluetooth.audio@2.0", - "android.hardware.bluetooth@1.0", - "android.hardware.bluetooth@1.1", - "android.hardware.graphics.bufferqueue@1.0", - "android.hardware.graphics.bufferqueue@2.0", - "android.hardware.graphics.common@1.0", - "android.hardware.graphics.common@1.1", - "android.hardware.graphics.common@1.2", - "android.hidl.safe_union@1.0", - "android.hidl.token@1.0", - "android.hidl.token@1.0-utils", - "avrcp-target-service", - "avrcp_headers", "bluetooth-protos-lite", - "bluetooth.mapsapi", - "com.android.vcard", - "dnsresolver_aidl_interface-V2-java", - "ipmemorystore-aidl-interfaces-V5-java", - "ipmemorystore-aidl-interfaces-java", "internal_include_headers", - "lib-bt-packets", - "lib-bt-packets-avrcp", - "lib-bt-packets-base", "libaudio-a2dp-hw-utils", "libaudio-hearing-aid-hw-utils", "libbluetooth", @@ -2719,25 +2696,6 @@ func makeApexAvailableBaseline() map[string][]string { "libbte", "libbtif", "libchrome", - "libevent", - "libfmq", - "libg722codec", - "libgui_headers", - "libmodpb64", - "libosi", - "libstatslog", - "libstatssocket", - "libtinyxml2", - "libudrv-uipc", - "libz", - "media_plugin_headers", - "net-utils-services-common", - "netd_aidl_interface-unstable-java", - "netd_event_listener_interface-java", - "netlink-client", - "networkstack-client", - "sap-api-java-static", - "services.net", } // // Module separator From 93457734287e785474d21ba07ba6cade3464cb04 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 10 Mar 2022 18:15:42 +0000 Subject: [PATCH 091/148] Add ignored hidden_api.split_packages/package_prefixes properties Allow modules upstream to make use of these properties despite sc-mainline-prod not supporting them. Bug: 194063708 Test: m nothing Merged-In: If2f90cfc41b6fff9fa4ac8b9d4973110938b9392 Change-Id: I85c13c115ffafc797566ced6c3672a9b0dca59b1 --- java/bootclasspath_fragment.go | 72 +++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index 750ed852f..7b4ddc573 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -139,6 +139,74 @@ type bootclasspathFragmentProperties struct { BootclasspathFragmentsDepsProperties } +type SourceOnlyBootclasspathProperties struct { + Hidden_api struct { + // Contains prefixes of a package hierarchy that is provided solely by this + // bootclasspath_fragment. + // + // This affects the signature patterns file that is used to select the subset of monolithic + // hidden API flags. See split_packages property for more details. + Package_prefixes []string + + // The list of split packages provided by this bootclasspath_fragment. + // + // A split package is one that contains classes which are provided by multiple + // bootclasspath_fragment modules. + // + // This defaults to "*" - which treats all packages as being split. A module that has no split + // packages must specify an empty list. + // + // This affects the signature patterns file that is generated by a bootclasspath_fragment and + // used to select the subset of monolithic hidden API flags against which the flags generated + // by the bootclasspath_fragment are compared. + // + // The signature patterns file selects the subset of monolithic hidden API flags using a number + // of patterns, i.e.: + // * The qualified name (including package) of an outermost class, e.g. java/lang/Character. + // This selects all the flags for all the members of this class and any nested classes. + // * A package wildcard, e.g. java/lang/*. This selects all the flags for all the members of all + // the classes in this package (but not in sub-packages). + // * A recursive package wildcard, e.g. java/**. This selects all the flags for all the members + // of all the classes in this package and sub-packages. + // + // The signature patterns file is constructed as follows: + // * All the signatures are retrieved from the all-flags.csv file. + // * The member and inner class names are removed. + // * If a class is in a split package then that is kept, otherwise the class part is removed + // and replaced with a wildcard, i.e. *. + // * If a package matches a package prefix then the package is removed. + // * All the package prefixes are added with a recursive wildcard appended to each, i.e. **. + // * The resulting patterns are sorted. + // + // So, by default (i.e. without specifying any package_prefixes or split_packages) the signature + // patterns is a list of class names, because there are no package packages and all packages are + // assumed to be split. + // + // If any split packages are specified then only those packages are treated as split and all + // other packages are treated as belonging solely to the bootclasspath_fragment and so they use + // wildcard package patterns. + // + // So, if an empty list of split packages is specified then the signature patterns file just + // includes a wildcard package pattern for every package provided by the bootclasspath_fragment. + // + // If split_packages are specified and a package that is split is not listed then it could lead + // to build failures as it will select monolithic flags that are generated by another + // bootclasspath_fragment to compare against the flags provided by this fragment. The latter + // will obviously not contain those flags and that can cause the comparison and build to fail. + // + // If any package prefixes are specified then any matching packages are removed from the + // signature patterns and replaced with a single recursive package pattern. + // + // It is not strictly necessary to specify either package_prefixes or split_packages as the + // defaults will produce a valid set of signature patterns. However, those patterns may include + // implementation details, e.g. names of implementation classes or packages, which will be + // exported to the sdk snapshot in the signature patterns file. That is something that should be + // avoided where possible. Specifying package_prefixes and split_packages allows those + // implementation details to be excluded from the snapshot. + Split_packages []string + } +} + type BootclasspathFragmentModule struct { android.ModuleBase android.ApexModuleBase @@ -146,6 +214,8 @@ type BootclasspathFragmentModule struct { ClasspathFragmentBase properties bootclasspathFragmentProperties + + sourceOnlyProperties SourceOnlyBootclasspathProperties } // commonBootclasspathFragment defines the methods that are implemented by both source and prebuilt @@ -177,7 +247,7 @@ type bootImageFilesByArch map[android.ArchType]android.Paths func bootclasspathFragmentFactory() android.Module { m := &BootclasspathFragmentModule{} - m.AddProperties(&m.properties) + m.AddProperties(&m.properties, &m.sourceOnlyProperties) android.InitApexModule(m) android.InitSdkAwareModule(m) initClasspathFragment(m, BOOTCLASSPATH) From 855222e3895bdc3930744acb5c3a213e5b3ff53b Mon Sep 17 00:00:00 2001 From: Xiao Ma Date: Thu, 27 Jan 2022 08:35:48 +0000 Subject: [PATCH 092/148] Remove ethernet-service jar dependency. ethernet service source code is going to be moved into Connectivity mainline module, and start the ethernet service from the module. The old ethernet-service lib will be deprecated, remove it from soong build rule. Bug: 210586283 Test: m Change-Id: I19697d13f3809d91c83e37c6d0d403e79eb28664 --- java/legacy_core_platform_api_usage.go | 1 - 1 file changed, 1 deletion(-) diff --git a/java/legacy_core_platform_api_usage.go b/java/legacy_core_platform_api_usage.go index e3396c12f..8e224914d 100644 --- a/java/legacy_core_platform_api_usage.go +++ b/java/legacy_core_platform_api_usage.go @@ -81,7 +81,6 @@ var legacyCorePlatformApiModules = []string{ "ds-car-docs", // for AAOS API documentation only "DynamicSystemInstallationService", "EmergencyInfo-lib", - "ethernet-service", "EthernetServiceTests", "ExternalStorageProvider", "face-V1-0-javalib", From ddf8c1bed962225acabe52f004055ea287ad543d Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Thu, 23 Dec 2021 15:05:38 +0000 Subject: [PATCH 093/148] Revert "Relax apex package restriction for T+ jars" This reverts commit 1fdd6ca88a192c61abe31d2f7a7f5721cafca1f8. Reason for revert: b/205289292 tracks the real fix for this Test: presubmit Change-Id: I5a2edaf4f930dafa26659f85d9425e9041c72275 (cherry picked from commit 1d016c50d0ee18ebc81ce7966e616b9936befd5a) --- android/neverallow.go | 65 ++++++++--------------------- android/neverallow_test.go | 49 ++-------------------- apex/apex.go | 7 ++-- apex/apex_test.go | 84 +------------------------------------- 4 files changed, 25 insertions(+), 180 deletions(-) diff --git a/android/neverallow.go b/android/neverallow.go index 6f9ae58d0..7512da792 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -249,7 +249,7 @@ func neverallowMutator(ctx BottomUpMutatorContext) { continue } - if !n.appliesToProperties(ctx, properties) { + if !n.appliesToProperties(properties) { continue } @@ -269,12 +269,8 @@ func neverallowMutator(ctx BottomUpMutatorContext) { } } -type ValueMatcherContext interface { - Config() Config -} - type ValueMatcher interface { - Test(ValueMatcherContext, string) bool + Test(string) bool String() string } @@ -282,7 +278,7 @@ type equalMatcher struct { expected string } -func (m *equalMatcher) Test(ctx ValueMatcherContext, value string) bool { +func (m *equalMatcher) Test(value string) bool { return m.expected == value } @@ -293,7 +289,7 @@ func (m *equalMatcher) String() string { type anyMatcher struct { } -func (m *anyMatcher) Test(ctx ValueMatcherContext, value string) bool { +func (m *anyMatcher) Test(value string) bool { return true } @@ -307,7 +303,7 @@ type startsWithMatcher struct { prefix string } -func (m *startsWithMatcher) Test(ctx ValueMatcherContext, value string) bool { +func (m *startsWithMatcher) Test(value string) bool { return strings.HasPrefix(value, m.prefix) } @@ -319,7 +315,7 @@ type regexMatcher struct { re *regexp.Regexp } -func (m *regexMatcher) Test(ctx ValueMatcherContext, value string) bool { +func (m *regexMatcher) Test(value string) bool { return m.re.MatchString(value) } @@ -331,7 +327,7 @@ type notInListMatcher struct { allowed []string } -func (m *notInListMatcher) Test(ctx ValueMatcherContext, value string) bool { +func (m *notInListMatcher) Test(value string) bool { return !InList(value, m.allowed) } @@ -341,7 +337,7 @@ func (m *notInListMatcher) String() string { type isSetMatcher struct{} -func (m *isSetMatcher) Test(ctx ValueMatcherContext, value string) bool { +func (m *isSetMatcher) Test(value string) bool { return value != "" } @@ -351,19 +347,6 @@ func (m *isSetMatcher) String() string { var isSetMatcherInstance = &isSetMatcher{} -type sdkVersionMatcher struct { - condition func(ctx ValueMatcherContext, spec SdkSpec) bool - description string -} - -func (m *sdkVersionMatcher) Test(ctx ValueMatcherContext, value string) bool { - return m.condition(ctx, SdkSpecFromWithConfig(ctx.Config(), value)) -} - -func (m *sdkVersionMatcher) String() string { - return ".sdk-version(" + m.description + ")" -} - type ruleProperty struct { fields []string // e.x.: Vndk.Enabled matcher ValueMatcher @@ -606,10 +589,9 @@ func (r *rule) appliesToModuleType(moduleType string) bool { return (len(r.moduleTypes) == 0 || InList(moduleType, r.moduleTypes)) && !InList(moduleType, r.unlessModuleTypes) } -func (r *rule) appliesToProperties(ctx ValueMatcherContext, - properties []interface{}) bool { - includeProps := hasAllProperties(ctx, properties, r.props) - excludeProps := hasAnyProperty(ctx, properties, r.unlessProps) +func (r *rule) appliesToProperties(properties []interface{}) bool { + includeProps := hasAllProperties(properties, r.props) + excludeProps := hasAnyProperty(properties, r.unlessProps) return includeProps && !excludeProps } @@ -629,16 +611,6 @@ func NotInList(allowed []string) ValueMatcher { return ¬InListMatcher{allowed} } -func LessThanSdkVersion(sdk string) ValueMatcher { - return &sdkVersionMatcher{ - condition: func(ctx ValueMatcherContext, spec SdkSpec) bool { - return spec.ApiLevel.LessThan( - SdkSpecFromWithConfig(ctx.Config(), sdk).ApiLevel) - }, - description: "lessThan=" + sdk, - } -} - // assorted utils func cleanPaths(paths []string) []string { @@ -657,28 +629,25 @@ func fieldNamesForProperties(propertyNames string) []string { return names } -func hasAnyProperty(ctx ValueMatcherContext, properties []interface{}, - props []ruleProperty) bool { +func hasAnyProperty(properties []interface{}, props []ruleProperty) bool { for _, v := range props { - if hasProperty(ctx, properties, v) { + if hasProperty(properties, v) { return true } } return false } -func hasAllProperties(ctx ValueMatcherContext, properties []interface{}, - props []ruleProperty) bool { +func hasAllProperties(properties []interface{}, props []ruleProperty) bool { for _, v := range props { - if !hasProperty(ctx, properties, v) { + if !hasProperty(properties, v) { return false } } return true } -func hasProperty(ctx ValueMatcherContext, properties []interface{}, - prop ruleProperty) bool { +func hasProperty(properties []interface{}, prop ruleProperty) bool { for _, propertyStruct := range properties { propertiesValue := reflect.ValueOf(propertyStruct).Elem() for _, v := range prop.fields { @@ -692,7 +661,7 @@ func hasProperty(ctx ValueMatcherContext, properties []interface{}, } check := func(value string) bool { - return prop.matcher.Test(ctx, value) + return prop.matcher.Test(value) } if matchValue(propertiesValue, check) { diff --git a/android/neverallow_test.go b/android/neverallow_test.go index 59016d407..8afe9e046 100644 --- a/android/neverallow_test.go +++ b/android/neverallow_test.go @@ -327,48 +327,6 @@ var neverallowTests = []struct { "Only boot images may be imported as a makefile goal.", }, }, - { - name: "min_sdk too low", - fs: map[string][]byte{ - "Android.bp": []byte(` - java_library { - name: "min_sdk_too_low", - min_sdk_version: "30", - }`), - }, - rules: []Rule{ - NeverAllow().WithMatcher("min_sdk_version", LessThanSdkVersion("31")), - }, - expectedErrors: []string{ - "module \"min_sdk_too_low\": violates neverallow", - }, - }, - { - name: "min_sdk high enough", - fs: map[string][]byte{ - "Android.bp": []byte(` - java_library { - name: "min_sdk_high_enough", - min_sdk_version: "31", - }`), - }, - rules: []Rule{ - NeverAllow().WithMatcher("min_sdk_version", LessThanSdkVersion("31")), - }, - }, - { - name: "current min_sdk high enough", - fs: map[string][]byte{ - "Android.bp": []byte(` - java_library { - name: "current_min_sdk_high_enough", - min_sdk_version: "current", - }`), - }, - rules: []Rule{ - NeverAllow().WithMatcher("min_sdk_version", LessThanSdkVersion("31")), - }, - }, } var prepareForNeverAllowTest = GroupFixturePreparers( @@ -452,10 +410,9 @@ func (p *mockCcLibraryModule) GenerateAndroidBuildActions(ModuleContext) { } type mockJavaLibraryProperties struct { - Libs []string - Min_sdk_version *string - Sdk_version *string - Uncompress_dex *bool + Libs []string + Sdk_version *string + Uncompress_dex *bool } type mockJavaLibraryModule struct { diff --git a/apex/apex.go b/apex/apex.go index fef275747..d72bfe660 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -3041,10 +3041,9 @@ func createApexPermittedPackagesRules(modules_packages map[string][]string) []an BootclasspathJar(). With("apex_available", module_name). WithMatcher("permitted_packages", android.NotInList(module_packages)). - WithMatcher("min_sdk_version", android.LessThanSdkVersion("Tiramisu")). Because("jars that are part of the " + module_name + " module may only use these package prefixes: " + strings.Join(module_packages, ",") + - " with min_sdk < T. Please consider the following alternatives:\n" + + ". Please consider the following alternatives:\n" + " 1. If the offending code is from a statically linked library, consider " + "removing that dependency and using an alternative already in the " + "bootclasspath, or perhaps a shared library." + @@ -3057,7 +3056,7 @@ func createApexPermittedPackagesRules(modules_packages map[string][]string) []an return rules } -// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART on Q/R/S. +// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART. // Adding code to the bootclasspath in new packages will cause issues on module update. func qModulesPackages() map[string][]string { return map[string][]string{ @@ -3071,7 +3070,7 @@ func qModulesPackages() map[string][]string { } } -// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART on R/S. +// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART. // Adding code to the bootclasspath in new packages will cause issues on module update. func rModulesPackages() map[string][]string { return map[string][]string{ diff --git a/apex/apex_test.go b/apex/apex_test.go index 85bd59526..c5b2958a4 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -7646,7 +7646,6 @@ func TestApexPermittedPackagesRules(t *testing.T) { apex_available: ["myapex"], sdk_version: "none", system_modules: "none", - min_sdk_version: "30", } java_library { name: "nonbcp_lib2", @@ -7655,11 +7654,9 @@ func TestApexPermittedPackagesRules(t *testing.T) { permitted_packages: ["a.b"], sdk_version: "none", system_modules: "none", - min_sdk_version: "30", } apex { name: "myapex", - min_sdk_version: "30", key: "myapex.key", java_libs: ["bcp_lib1", "nonbcp_lib2"], updatable: false, @@ -7672,8 +7669,8 @@ func TestApexPermittedPackagesRules(t *testing.T) { }, }, { - name: "Bootclasspath apex jar not satisfying allowed module packages on Q.", - expectedError: `(?s)module "bcp_lib2" .* which is restricted because jars that are part of the myapex module may only use these package prefixes: foo.bar with min_sdk < T. Please consider the following alternatives:\n 1. If the offending code is from a statically linked library, consider removing that dependency and using an alternative already in the bootclasspath, or perhaps a shared library. 2. Move the offending code into an allowed package.\n 3. Jarjar the offending code. Please be mindful of the potential system health implications of bundling that code, particularly if the offending jar is part of the bootclasspath.`, + name: "Bootclasspath apex jar not satisfying allowed module packages.", + expectedError: `(?s)module "bcp_lib2" .* which is restricted because jars that are part of the myapex module may only use these package prefixes: foo.bar. Please consider the following alternatives:\n 1. If the offending code is from a statically linked library, consider removing that dependency and using an alternative already in the bootclasspath, or perhaps a shared library. 2. Move the offending code into an allowed package.\n 3. Jarjar the offending code. Please be mindful of the potential system health implications of bundling that code, particularly if the offending jar is part of the bootclasspath.`, bp: ` java_library { name: "bcp_lib1", @@ -7682,7 +7679,6 @@ func TestApexPermittedPackagesRules(t *testing.T) { permitted_packages: ["foo.bar"], sdk_version: "none", system_modules: "none", - min_sdk_version: "29", } java_library { name: "bcp_lib2", @@ -7691,85 +7687,9 @@ func TestApexPermittedPackagesRules(t *testing.T) { permitted_packages: ["foo.bar", "bar.baz"], sdk_version: "none", system_modules: "none", - min_sdk_version: "29", } apex { name: "myapex", - min_sdk_version: "29", - key: "myapex.key", - java_libs: ["bcp_lib1", "bcp_lib2"], - updatable: false, - } - `, - bootJars: []string{"bcp_lib1", "bcp_lib2"}, - modulesPackages: map[string][]string{ - "myapex": []string{ - "foo.bar", - }, - }, - }, - { - name: "Bootclasspath apex jar not satisfying allowed module packages on R.", - expectedError: `(?s)module "bcp_lib2" .* which is restricted because jars that are part of the myapex module may only use these package prefixes: foo.bar with min_sdk < T. Please consider the following alternatives:\n 1. If the offending code is from a statically linked library, consider removing that dependency and using an alternative already in the bootclasspath, or perhaps a shared library. 2. Move the offending code into an allowed package.\n 3. Jarjar the offending code. Please be mindful of the potential system health implications of bundling that code, particularly if the offending jar is part of the bootclasspath.`, - bp: ` - java_library { - name: "bcp_lib1", - srcs: ["lib1/src/*.java"], - apex_available: ["myapex"], - permitted_packages: ["foo.bar"], - sdk_version: "none", - system_modules: "none", - min_sdk_version: "30", - } - java_library { - name: "bcp_lib2", - srcs: ["lib2/src/*.java"], - apex_available: ["myapex"], - permitted_packages: ["foo.bar", "bar.baz"], - sdk_version: "none", - system_modules: "none", - min_sdk_version: "30", - } - apex { - name: "myapex", - min_sdk_version: "30", - key: "myapex.key", - java_libs: ["bcp_lib1", "bcp_lib2"], - updatable: false, - } - `, - bootJars: []string{"bcp_lib1", "bcp_lib2"}, - modulesPackages: map[string][]string{ - "myapex": []string{ - "foo.bar", - }, - }, - }, - { - name: "Bootclasspath apex jar >= T not satisfying Q/R/S allowed module packages.", - expectedError: "", - bp: ` - java_library { - name: "bcp_lib1", - srcs: ["lib1/src/*.java"], - apex_available: ["myapex"], - permitted_packages: ["foo.bar"], - sdk_version: "none", - system_modules: "none", - min_sdk_version: "current", - } - java_library { - name: "bcp_lib2", - srcs: ["lib2/src/*.java"], - apex_available: ["myapex"], - permitted_packages: ["foo.bar", "bar.baz"], - sdk_version: "none", - system_modules: "none", - min_sdk_version: "current", - } - apex { - name: "myapex", - min_sdk_version: "current", key: "myapex.key", java_libs: ["bcp_lib1", "bcp_lib2"], updatable: false, From 440ff9672846ecbc6d607ae65ea6826c49552756 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Fri, 12 Nov 2021 00:01:37 +0000 Subject: [PATCH 094/148] Change permitted_packages check to be per-jar rather than per-apex (This CL has been implemented in master to prevent a merge conflict with ag/16222633. It will be cherry-picked to AOSP) Summary: - updates the Q and R maps, the new keys are the bcp jars and not the apexes. neverallow build rules ensure that these bcp jars have a restricted set of permitted_packages - remove BootclasspathJar from the neverallow rule. This is no longer necessary since the keys in the maps are the bootjars themselves, and not apexes Bug: 205289292 Test: In build/soong, go test ./apex Change-Id: Icb91de934181a8b6f085e03a0ce8c5e08504ff94 --- android/neverallow.go | 23 --------------- apex/apex.go | 40 +++++++++++++------------- apex/apex_test.go | 67 ++++++++++++++++++++++++++++++++++--------- 3 files changed, 74 insertions(+), 56 deletions(-) diff --git a/android/neverallow.go b/android/neverallow.go index 7512da792..f87cebbc9 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -261,10 +261,6 @@ func neverallowMutator(ctx BottomUpMutatorContext) { continue } - if !n.appliesToBootclasspathJar(ctx) { - continue - } - ctx.ModuleErrorf("violates " + n.String()) } } @@ -380,8 +376,6 @@ type Rule interface { NotModuleType(types ...string) Rule - BootclasspathJar() Rule - With(properties, value string) Rule WithMatcher(properties string, matcher ValueMatcher) Rule @@ -497,12 +491,6 @@ func (r *rule) Because(reason string) Rule { return r } -// BootclasspathJar whether this rule only applies to Jars in the Bootclasspath -func (r *rule) BootclasspathJar() Rule { - r.onlyBootclasspathJar = true - return r -} - func (r *rule) String() string { s := []string{"neverallow requirements. Not allowed:"} if len(r.paths) > 0 { @@ -520,9 +508,6 @@ func (r *rule) String() string { if len(r.osClasses) > 0 { s = append(s, fmt.Sprintf("os class(es): %q", r.osClasses)) } - if r.onlyBootclasspathJar { - s = append(s, "in bootclasspath jar") - } if len(r.unlessPaths) > 0 { s = append(s, fmt.Sprintf("EXCEPT in dirs: %q", r.unlessPaths)) } @@ -563,14 +548,6 @@ func (r *rule) appliesToDirectDeps(ctx BottomUpMutatorContext) bool { return matches } -func (r *rule) appliesToBootclasspathJar(ctx BottomUpMutatorContext) bool { - if !r.onlyBootclasspathJar { - return true - } - - return InList(ctx.ModuleName(), ctx.Config().BootJars()) -} - func (r *rule) appliesToOsClass(osClass OsClass) bool { if len(r.osClasses) == 0 { return true diff --git a/apex/apex.go b/apex/apex.go index d72bfe660..654b5d408 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -3030,19 +3030,18 @@ func makeApexAvailableBaseline() map[string][]string { } func init() { - android.AddNeverAllowRules(createApexPermittedPackagesRules(qModulesPackages())...) - android.AddNeverAllowRules(createApexPermittedPackagesRules(rModulesPackages())...) + android.AddNeverAllowRules(createBcpPermittedPackagesRules(qBcpPackages())...) + android.AddNeverAllowRules(createBcpPermittedPackagesRules(rBcpPackages())...) } -func createApexPermittedPackagesRules(modules_packages map[string][]string) []android.Rule { - rules := make([]android.Rule, 0, len(modules_packages)) - for module_name, module_packages := range modules_packages { +func createBcpPermittedPackagesRules(bcpPermittedPackages map[string][]string) []android.Rule { + rules := make([]android.Rule, 0, len(bcpPermittedPackages)) + for jar, permittedPackages := range bcpPermittedPackages { permittedPackagesRule := android.NeverAllow(). - BootclasspathJar(). - With("apex_available", module_name). - WithMatcher("permitted_packages", android.NotInList(module_packages)). - Because("jars that are part of the " + module_name + - " module may only use these package prefixes: " + strings.Join(module_packages, ",") + + With("name", jar). + WithMatcher("permitted_packages", android.NotInList(permittedPackages)). + Because(jar + + " bootjar may only use these package prefixes: " + strings.Join(permittedPackages, ",") + ". Please consider the following alternatives:\n" + " 1. If the offending code is from a statically linked library, consider " + "removing that dependency and using an alternative already in the " + @@ -3051,6 +3050,7 @@ func createApexPermittedPackagesRules(modules_packages map[string][]string) []an " 3. Jarjar the offending code. Please be mindful of the potential system " + "health implications of bundling that code, particularly if the offending jar " + "is part of the bootclasspath.") + rules = append(rules, permittedPackagesRule) } return rules @@ -3058,13 +3058,13 @@ func createApexPermittedPackagesRules(modules_packages map[string][]string) []an // DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART. // Adding code to the bootclasspath in new packages will cause issues on module update. -func qModulesPackages() map[string][]string { +func qBcpPackages() map[string][]string { return map[string][]string{ - "com.android.conscrypt": []string{ + "conscrypt": []string{ "android.net.ssl", "com.android.org.conscrypt", }, - "com.android.media": []string{ + "updatable-media": []string{ "android.media", }, } @@ -3072,12 +3072,12 @@ func qModulesPackages() map[string][]string { // DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART. // Adding code to the bootclasspath in new packages will cause issues on module update. -func rModulesPackages() map[string][]string { +func rBcpPackages() map[string][]string { return map[string][]string{ - "com.android.mediaprovider": []string{ + "framework-mediaprovider": []string{ "android.provider", }, - "com.android.permission": []string{ + "framework-permission": []string{ "android.permission", //TODO(b/205719989): remove, do not cherry-pick anywhere "android.safetycenter", @@ -3085,23 +3085,23 @@ func rModulesPackages() map[string][]string { "com.android.permission", "com.android.role", }, - "com.android.sdkext": []string{ + "framework-sdkextensions": []string{ "android.os.ext", }, - "com.android.os.statsd": []string{ + "framework-statsd": []string{ "android.app", "android.os", "android.util", "com.android.internal.statsd", "com.android.server.stats", }, - "com.android.wifi": []string{ + "framework-wifi": []string{ "com.android.server.wifi", "com.android.wifi.x", "android.hardware.wifi", "android.net.wifi", }, - "com.android.tethering": []string{ + "framework-tethering": []string{ "android.net", }, } diff --git a/apex/apex_test.go b/apex/apex_test.go index c5b2958a4..7d6009f2c 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -7589,7 +7589,7 @@ func TestDexpreoptAccessDexFilesFromPrebuiltApex(t *testing.T) { }) } -func testApexPermittedPackagesRules(t *testing.T, errmsg, bp string, bootJars []string, rules []android.Rule) { +func testBootJarPermittedPackagesRules(t *testing.T, errmsg, bp string, bootJars []string, rules []android.Rule) { t.Helper() bp += ` apex_key { @@ -7628,11 +7628,11 @@ func testApexPermittedPackagesRules(t *testing.T, errmsg, bp string, bootJars [] func TestApexPermittedPackagesRules(t *testing.T) { testcases := []struct { - name string - expectedError string - bp string - bootJars []string - modulesPackages map[string][]string + name string + expectedError string + bp string + bootJars []string + bcpPermittedPackages map[string][]string }{ { @@ -7662,15 +7662,15 @@ func TestApexPermittedPackagesRules(t *testing.T) { updatable: false, }`, bootJars: []string{"bcp_lib1"}, - modulesPackages: map[string][]string{ - "myapex": []string{ + bcpPermittedPackages: map[string][]string{ + "bcp_lib1": []string{ "foo.bar", }, }, }, { name: "Bootclasspath apex jar not satisfying allowed module packages.", - expectedError: `(?s)module "bcp_lib2" .* which is restricted because jars that are part of the myapex module may only use these package prefixes: foo.bar. Please consider the following alternatives:\n 1. If the offending code is from a statically linked library, consider removing that dependency and using an alternative already in the bootclasspath, or perhaps a shared library. 2. Move the offending code into an allowed package.\n 3. Jarjar the offending code. Please be mindful of the potential system health implications of bundling that code, particularly if the offending jar is part of the bootclasspath.`, + expectedError: `(?s)module "bcp_lib2" .* which is restricted because bcp_lib2 bootjar may only use these package prefixes: foo.bar. Please consider the following alternatives:\n 1. If the offending code is from a statically linked library, consider removing that dependency and using an alternative already in the bootclasspath, or perhaps a shared library. 2. Move the offending code into an allowed package.\n 3. Jarjar the offending code. Please be mindful of the potential system health implications of bundling that code, particularly if the offending jar is part of the bootclasspath.`, bp: ` java_library { name: "bcp_lib1", @@ -7696,17 +7696,58 @@ func TestApexPermittedPackagesRules(t *testing.T) { } `, bootJars: []string{"bcp_lib1", "bcp_lib2"}, - modulesPackages: map[string][]string{ - "myapex": []string{ + bcpPermittedPackages: map[string][]string{ + "bcp_lib1": []string{ "foo.bar", }, + "bcp_lib2": []string{ + "foo.bar", + }, + }, + }, + { + name: "Updateable Bootclasspath apex jar not satisfying allowed module packages.", + expectedError: "", + bp: ` + java_library { + name: "bcp_lib_restricted", + srcs: ["lib1/src/*.java"], + apex_available: ["myapex"], + permitted_packages: ["foo.bar"], + sdk_version: "none", + min_sdk_version: "29", + system_modules: "none", + } + java_library { + name: "bcp_lib_unrestricted", + srcs: ["lib2/src/*.java"], + apex_available: ["myapex"], + permitted_packages: ["foo.bar", "bar.baz"], + sdk_version: "none", + min_sdk_version: "29", + system_modules: "none", + } + apex { + name: "myapex", + key: "myapex.key", + java_libs: ["bcp_lib_restricted", "bcp_lib_unrestricted"], + updatable: true, + min_sdk_version: "29", + } + `, + bootJars: []string{"bcp_lib1", "bcp_lib2"}, + bcpPermittedPackages: map[string][]string{ + "bcp_lib1_non_updateable": []string{ + "foo.bar", + }, + // bcp_lib2_updateable has no entry here since updateable bcp can contain new packages - tracking via an allowlist is not necessary }, }, } for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { - rules := createApexPermittedPackagesRules(tc.modulesPackages) - testApexPermittedPackagesRules(t, tc.expectedError, tc.bp, tc.bootJars, rules) + rules := createBcpPermittedPackagesRules(tc.bcpPermittedPackages) + testBootJarPermittedPackagesRules(t, tc.expectedError, tc.bp, tc.bootJars, rules) }) } } From d3fae5f2edbc1c3bfa9c6a9c845e7fcec0e02ab1 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Fri, 7 Jan 2022 18:32:46 +0000 Subject: [PATCH 095/148] Remove android.safetycenter from framework-permission bcp permitted_packges The permitted_packages check is now per jar and not per apex. Remove safetycenter from the map since this package prefix cannot be in framework-permission Bug: 205719989 Bug: 205289292 Test: TH Change-Id: I473731a697fb09319037536dead97f5abf4bd6ea --- apex/apex.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 654b5d408..d5648bb8e 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -3079,8 +3079,6 @@ func rBcpPackages() map[string][]string { }, "framework-permission": []string{ "android.permission", - //TODO(b/205719989): remove, do not cherry-pick anywhere - "android.safetycenter", "android.app.role", "com.android.permission", "com.android.role", From 11cca671ac48b054e90ce06e3df91ef70bb9eb9d Mon Sep 17 00:00:00 2001 From: Jingwen Chen Date: Fri, 25 Mar 2022 02:57:49 +0000 Subject: [PATCH 096/148] Suffix the build ID to the dirname of APK-in-APEX files. This fixes an issue with package manager's cache invalidation. Test: CI Bug: 226559955 Bug: 224589412 Change-Id: I8af49d51ff99cf8184d0e4d1136fff1cdb29c23e Merged-In: I8af49d51ff99cf8184d0e4d1136fff1cdb29c23e --- apex/apex.go | 31 +++++++++++++++++++++++--- apex/apex_test.go | 57 ++++++++++++++++++++++++++++++++++++----------- 2 files changed, 72 insertions(+), 16 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index e1bc030c5..81599027a 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -19,6 +19,7 @@ package apex import ( "fmt" "path/filepath" + "regexp" "sort" "strings" @@ -1537,13 +1538,33 @@ type androidApp interface { var _ androidApp = (*java.AndroidApp)(nil) var _ androidApp = (*java.AndroidAppImport)(nil) +func sanitizedBuildIdForPath(ctx android.BaseModuleContext) string { + buildId := ctx.Config().BuildId() + + // The build ID is used as a suffix for a filename, so ensure that + // the set of characters being used are sanitized. + // - any word character: [a-zA-Z0-9_] + // - dots: . + // - dashes: - + validRegex := regexp.MustCompile(`^[\w\.\-\_]+$`) + if !validRegex.MatchString(buildId) { + ctx.ModuleErrorf("Unable to use build id %s as filename suffix, valid characters are [a-z A-Z 0-9 _ . -].", buildId) + } + return buildId +} + func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp androidApp) apexFile { appDir := "app" if aapp.Privileged() { appDir = "priv-app" } - dirInApex := filepath.Join(appDir, aapp.InstallApkName()) + + // TODO(b/224589412, b/226559955): Ensure that the subdirname is suffixed + // so that PackageManager correctly invalidates the existing installed apk + // in favour of the new APK-in-APEX. See bugs for more information. + dirInApex := filepath.Join(appDir, aapp.InstallApkName()+"@"+sanitizedBuildIdForPath(ctx)) fileToCopy := aapp.OutputFile() + af := newApexFile(ctx, fileToCopy, aapp.BaseModuleName(), dirInApex, app, aapp) af.jacocoReportClassesFile = aapp.JacocoReportClassesFile() af.lintDepSets = aapp.LintDepSets() @@ -1756,8 +1777,12 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { if ap.Privileged() { appDir = "priv-app" } - af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(), - filepath.Join(appDir, ap.BaseModuleName()), appSet, ap) + // TODO(b/224589412, b/226559955): Ensure that the dirname is + // suffixed so that PackageManager correctly invalidates the + // existing installed apk in favour of the new APK-in-APEX. + // See bugs for more information. + appDirName := filepath.Join(appDir, ap.BaseModuleName()+"@"+sanitizedBuildIdForPath(ctx)) + af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(), appDirName, appSet, ap) af.certificate = java.PresignedCertificate filesInfo = append(filesInfo, af) } else { diff --git a/apex/apex_test.go b/apex/apex_test.go index f3c3b44c5..4ded4fd36 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -217,6 +217,7 @@ var prepareForApexTest = android.GroupFixturePreparers( variables.Platform_sdk_final = proptools.BoolPtr(false) variables.Platform_version_active_codenames = []string{"Q"} variables.Platform_vndk_version = proptools.StringPtr("29") + variables.BuildId = proptools.StringPtr("TEST.BUILD_ID") }), ) @@ -686,7 +687,7 @@ func TestDefaults(t *testing.T) { "etc/myetc", "javalib/myjar.jar", "lib64/mylib.so", - "app/AppFoo/AppFoo.apk", + "app/AppFoo@TEST.BUILD_ID/AppFoo.apk", "overlay/blue/rro.apk", "etc/bpf/bpf.o", "etc/bpf/bpf2.o", @@ -5124,8 +5125,8 @@ func TestApexWithApps(t *testing.T) { apexRule := module.Rule("apexRule") copyCmds := apexRule.Args["copy_commands"] - ensureContains(t, copyCmds, "image.apex/app/AppFoo/AppFoo.apk") - ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv/AppFooPriv.apk") + ensureContains(t, copyCmds, "image.apex/app/AppFoo@TEST.BUILD_ID/AppFoo.apk") + ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv@TEST.BUILD_ID/AppFooPriv.apk") appZipRule := ctx.ModuleForTests("AppFoo", "android_common_apex10000").Description("zip jni libs") // JNI libraries are uncompressed @@ -5142,6 +5143,36 @@ func TestApexWithApps(t *testing.T) { } } +func TestApexWithAppImportBuildId(t *testing.T) { + invalidBuildIds := []string{"../", "a b", "a/b", "a/b/../c", "/a"} + for _, id := range invalidBuildIds { + message := fmt.Sprintf("Unable to use build id %s as filename suffix", id) + fixture := android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.BuildId = proptools.StringPtr(id) + }) + testApexError(t, message, `apex { + name: "myapex", + key: "myapex.key", + apps: ["AppFooPrebuilt"], + updatable: false, + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + android_app_import { + name: "AppFooPrebuilt", + apk: "PrebuiltAppFoo.apk", + presigned: true, + apex_available: ["myapex"], + } + `, fixture) + } +} + func TestApexWithAppImports(t *testing.T) { ctx := testApex(t, ` apex { @@ -5187,8 +5218,8 @@ func TestApexWithAppImports(t *testing.T) { apexRule := module.Rule("apexRule") copyCmds := apexRule.Args["copy_commands"] - ensureContains(t, copyCmds, "image.apex/app/AppFooPrebuilt/AppFooPrebuilt.apk") - ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPrivPrebuilt/AwesomePrebuiltAppFooPriv.apk") + ensureContains(t, copyCmds, "image.apex/app/AppFooPrebuilt@TEST.BUILD_ID/AppFooPrebuilt.apk") + ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPrivPrebuilt@TEST.BUILD_ID/AwesomePrebuiltAppFooPriv.apk") } func TestApexWithAppImportsPrefer(t *testing.T) { @@ -5229,7 +5260,7 @@ func TestApexWithAppImportsPrefer(t *testing.T) { })) ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{ - "app/AppFoo/AppFooPrebuilt.apk", + "app/AppFoo@TEST.BUILD_ID/AppFooPrebuilt.apk", }) } @@ -5262,7 +5293,7 @@ func TestApexWithTestHelperApp(t *testing.T) { apexRule := module.Rule("apexRule") copyCmds := apexRule.Args["copy_commands"] - ensureContains(t, copyCmds, "image.apex/app/TesterHelpAppFoo/TesterHelpAppFoo.apk") + ensureContains(t, copyCmds, "image.apex/app/TesterHelpAppFoo@TEST.BUILD_ID/TesterHelpAppFoo.apk") } func TestApexPropertiesShouldBeDefaultable(t *testing.T) { @@ -5609,8 +5640,8 @@ func TestOverrideApex(t *testing.T) { apexRule := module.Rule("apexRule") copyCmds := apexRule.Args["copy_commands"] - ensureNotContains(t, copyCmds, "image.apex/app/app/app.apk") - ensureContains(t, copyCmds, "image.apex/app/override_app/override_app.apk") + ensureNotContains(t, copyCmds, "image.apex/app/app@TEST.BUILD_ID/app.apk") + ensureContains(t, copyCmds, "image.apex/app/override_app@TEST.BUILD_ID/override_app.apk") apexBundle := module.Module().(*apexBundle) name := apexBundle.Name() @@ -6349,7 +6380,7 @@ func TestAppBundle(t *testing.T) { content := bundleConfigRule.Args["content"] ensureContains(t, content, `"compression":{"uncompressed_glob":["apex_payload.img","apex_manifest.*"]}`) - ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.android.foo","path":"app/AppFoo/AppFoo.apk"}]}`) + ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.android.foo","path":"app/AppFoo@TEST.BUILD_ID/AppFoo.apk"}]}`) } func TestAppSetBundle(t *testing.T) { @@ -6380,9 +6411,9 @@ func TestAppSetBundle(t *testing.T) { if len(copyCmds) != 3 { t.Fatalf("Expected 3 commands, got %d in:\n%s", len(copyCmds), s) } - ensureMatches(t, copyCmds[0], "^rm -rf .*/app/AppSet$") - ensureMatches(t, copyCmds[1], "^mkdir -p .*/app/AppSet$") - ensureMatches(t, copyCmds[2], "^unzip .*-d .*/app/AppSet .*/AppSet.zip$") + ensureMatches(t, copyCmds[0], "^rm -rf .*/app/AppSet@TEST.BUILD_ID$") + ensureMatches(t, copyCmds[1], "^mkdir -p .*/app/AppSet@TEST.BUILD_ID$") + ensureMatches(t, copyCmds[2], "^unzip .*-d .*/app/AppSet@TEST.BUILD_ID .*/AppSet.zip$") } func TestAppSetBundlePrebuilt(t *testing.T) { From 8c80126987d760142d9f691288b91dc6ed5e2d81 Mon Sep 17 00:00:00 2001 From: Matt Banda Date: Fri, 1 Apr 2022 17:48:31 +0000 Subject: [PATCH 097/148] Surface Java APIs Used By APK-only Modules. Previously we were only generating used-by API-coverage for APEX modules. This change adds support for APK-only modules such as NetworkStack and DocumentsUI. Bug: b/216313756 Forrest Run: https://android-build.googleplex.com/builds/abtd/run/L10800000953846781 Test: TARGET_BUILD_VARIANT=userdebug PRODUCT=mainline_modules_x86 ./vendor/google/build/build_unbundled_coverage_mainline_module.sh -j16 Change-Id: Id17e4a55c2a52e9903632a654e778f8d54982dfc Merged-In: Id17e4a55c2a52e9903632a654e778f8d54982dfc (cherry picked from commit 56d75785bd52c8a8f684935eed67fceb2c0e6850) --- apex/testing.go | 1 - java/androidmk.go | 10 +++++++++- java/app.go | 3 +++ java/app_builder.go | 12 ++++++++++++ java/testing.go | 2 ++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/apex/testing.go b/apex/testing.go index 337c86210..69bd73e5d 100644 --- a/apex/testing.go +++ b/apex/testing.go @@ -24,7 +24,6 @@ var PrepareForTestWithApexBuildComponents = android.GroupFixturePreparers( android.MockFS{ // Needed by apex. "system/core/rootdir/etc/public.libraries.android.txt": nil, - "build/soong/scripts/gen_java_usedby_apex.sh": nil, "build/soong/scripts/gen_ndk_backedby_apex.sh": nil, // Needed by prebuilt_apex. "build/soong/scripts/unpack-prebuilt-apex.sh": nil, diff --git a/java/androidmk.go b/java/androidmk.go index e3e85a996..f51e072bd 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -409,7 +409,15 @@ func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries { entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", app.linter.reports) }, }, - }} + ExtraFooters: []android.AndroidMkExtraFootersFunc{ + func(w io.Writer, name, prefix, moduleDir string) { + if app.javaApiUsedByOutputFile.String() != "" { + fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s/$(notdir %s))\n", + app.installApkName, app.javaApiUsedByOutputFile.String(), "java_apis_used_by_apex", app.javaApiUsedByOutputFile.String()) + } + }, + }}, + } } func (a *AndroidApp) getOverriddenPackages() []string { diff --git a/java/app.go b/java/app.go index a1a854e50..1b65f33ca 100755 --- a/java/app.go +++ b/java/app.go @@ -169,6 +169,8 @@ type AndroidApp struct { overriddenManifestPackageName string android.ApexBundleDepsInfo + + javaApiUsedByOutputFile android.ModuleOutPath } func (a *AndroidApp) IsInstallable() bool { @@ -277,6 +279,7 @@ func (a *AndroidTestHelperApp) GenerateAndroidBuildActions(ctx android.ModuleCon func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.checkAppSdkVersions(ctx) a.generateAndroidBuildActions(ctx) + a.generateJavaUsedByApex(ctx) } func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) { diff --git a/java/app_builder.go b/java/app_builder.go index 74cd85c08..31023cb9c 100644 --- a/java/app_builder.go +++ b/java/app_builder.go @@ -258,6 +258,18 @@ func TransformJniLibsToJar(ctx android.ModuleContext, outputFile android.Writabl }) } +func (a *AndroidApp) generateJavaUsedByApex(ctx android.ModuleContext) { + javaApiUsedByOutputFile := android.PathForModuleOut(ctx, a.installApkName+"_using.xml") + javaUsedByRule := android.NewRuleBuilder(pctx, ctx) + javaUsedByRule.Command(). + Tool(android.PathForSource(ctx, "build/soong/scripts/gen_java_usedby_apex.sh")). + BuiltTool("dexdeps"). + Output(javaApiUsedByOutputFile). + Input(a.Library.Module.outputFile) + javaUsedByRule.Build("java_usedby_list", "Generate Java APIs used by Apex") + a.javaApiUsedByOutputFile = javaApiUsedByOutputFile +} + func targetToJniDir(target android.Target) string { return filepath.Join("lib", target.Arch.Abi[0]) } diff --git a/java/testing.go b/java/testing.go index 82aa29b61..9178b1653 100644 --- a/java/testing.go +++ b/java/testing.go @@ -54,6 +54,8 @@ var PrepareForTestWithJavaBuildComponents = android.GroupFixturePreparers( "build/soong/java/lint_defaults.txt": nil, // Needed for apps that do not provide their own. "build/make/target/product/security": nil, + // Required to generate Java used-by API coverage + "build/soong/scripts/gen_java_usedby_apex.sh": nil, }.AddToFixture(), ) From 55ccba2f6173d75f50ea87b3d720d0e2bbaed61b Mon Sep 17 00:00:00 2001 From: Albert Martin Date: Mon, 21 Mar 2022 20:11:16 +0000 Subject: [PATCH 098/148] Flag to globally override apexes' min_sdk_version Override all mainline updateable apexes' min_sdk_version to same version to get single shared native libs on DCLA. Test: Run "vendor/google/build/go/mainline_go_modules_arm.sh" and inspect built apexes Bug: 212609891 Change-Id: Ide7d3f2bc772ac6240f1c917b87285d051d6f605 --- android/config.go | 4 ++ android/variable.go | 2 + apex/apex.go | 35 +++++++++++-- apex/apex_test.go | 124 ++++++++++++++++++++++++++++++++++++++++++++ apex/builder.go | 2 +- 5 files changed, 161 insertions(+), 6 deletions(-) diff --git a/android/config.go b/android/config.go index 5c41ee8bf..5dcb95935 100644 --- a/android/config.go +++ b/android/config.go @@ -1360,6 +1360,10 @@ func findOverrideValue(overrides []string, name string, errorMsg string) (newVal return "", false } +func (c *deviceConfig) ApexGlobalMinSdkVersionOverride() string { + return String(c.config.productVariables.ApexGlobalMinSdkVersionOverride) +} + func (c *config) IntegerOverflowDisabledForPath(path string) bool { if len(c.productVariables.IntegerOverflowExcludePaths) == 0 { return false diff --git a/android/variable.go b/android/variable.go index 4ed05070e..077b81097 100644 --- a/android/variable.go +++ b/android/variable.go @@ -389,6 +389,8 @@ type productVariables struct { CertificateOverrides []string `json:",omitempty"` PackageNameOverrides []string `json:",omitempty"` + ApexGlobalMinSdkVersionOverride *string `json:",omitempty"` + EnforceSystemCertificate *bool `json:",omitempty"` EnforceSystemCertificateAllowList []string `json:",omitempty"` diff --git a/apex/apex.go b/apex/apex.go index fef275747..03b8bcc1b 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -2452,20 +2452,43 @@ func (a *apexBundle) CheckMinSdkVersion(ctx android.ModuleContext) { android.CheckMinSdkVersion(ctx, minSdkVersion, a.WalkPayloadDeps) } +// Returns apex's min_sdk_version string value, honoring overrides +func (a *apexBundle) minSdkVersionValue(ctx android.EarlyModuleContext) string { + // Only override the minSdkVersion value on Apexes which already specify + // a min_sdk_version (it's optional for non-updatable apexes), and that its + // min_sdk_version value is lower than the one to override with. + overrideMinSdkValue := ctx.DeviceConfig().ApexGlobalMinSdkVersionOverride() + overrideApiLevel := minSdkVersionFromValue(ctx, overrideMinSdkValue) + originalMinApiLevel := minSdkVersionFromValue(ctx, proptools.String(a.properties.Min_sdk_version)) + isMinSdkSet := a.properties.Min_sdk_version != nil + isOverrideValueHigher := overrideApiLevel.CompareTo(originalMinApiLevel) > 0 + if overrideMinSdkValue != "" && isMinSdkSet && isOverrideValueHigher { + return overrideMinSdkValue + } + + return proptools.String(a.properties.Min_sdk_version) +} + +// Returns apex's min_sdk_version SdkSpec, honoring overrides func (a *apexBundle) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { return android.SdkSpec{ Kind: android.SdkNone, ApiLevel: a.minSdkVersion(ctx), - Raw: String(a.properties.Min_sdk_version), + Raw: a.minSdkVersionValue(ctx), } } +// Returns apex's min_sdk_version ApiLevel, honoring overrides func (a *apexBundle) minSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel { - ver := proptools.String(a.properties.Min_sdk_version) - if ver == "" { + return minSdkVersionFromValue(ctx, a.minSdkVersionValue(ctx)) +} + +// Construct ApiLevel object from min_sdk_version string value +func minSdkVersionFromValue(ctx android.EarlyModuleContext, value string) android.ApiLevel { + if value == "" { return android.NoneApiLevel } - apiLevel, err := android.ApiLevelFromUser(ctx, ver) + apiLevel, err := android.ApiLevelFromUser(ctx, value) if err != nil { ctx.PropertyErrorf("min_sdk_version", "%s", err.Error()) return android.NoneApiLevel @@ -2520,7 +2543,7 @@ func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext // checkUpdatable enforces APEX and its transitive dep properties to have desired values for updatable APEXes. func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) { if a.Updatable() { - if String(a.properties.Min_sdk_version) == "" { + if a.minSdkVersionValue(ctx) == "" { ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well") } if a.UsePlatformApis() { @@ -3153,6 +3176,8 @@ func (a *apexBundle) ConvertWithBp2build(ctx android.TopDownMutatorContext) { fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *a.properties.File_contexts)) } + // TODO(b/219503907) this would need to be set to a.MinSdkVersionValue(ctx) but + // given it's coming via config, we probably don't want to put it in here. var minSdkVersion *string if a.properties.Min_sdk_version != nil { minSdkVersion = a.properties.Min_sdk_version diff --git a/apex/apex_test.go b/apex/apex_test.go index 85bd59526..f53be9229 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -113,6 +113,12 @@ func withManifestPackageNameOverrides(specs []string) android.FixturePreparer { }) } +func withApexGlobalMinSdkVersionOverride(minSdkOverride *string) android.FixturePreparer { + return android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.ApexGlobalMinSdkVersionOverride = minSdkOverride + }) +} + var withBinder32bit = android.FixtureModifyProductVariables( func(variables android.FixtureProductVariables) { variables.Binder32bit = proptools.BoolPtr(true) @@ -6303,6 +6309,124 @@ func TestOverrideApex(t *testing.T) { ensureNotContains(t, androidMk, "LOCAL_MODULE_STEM := myapex.apex") } +func TestMinSdkVersionOverride(t *testing.T) { + // Override from 29 to 31 + minSdkOverride31 := "31" + ctx := testApex(t, ` + apex { + name: "myapex", + key: "myapex.key", + native_shared_libs: ["mylib"], + updatable: true, + min_sdk_version: "29" + } + + override_apex { + name: "override_myapex", + base: "myapex", + logging_parent: "com.foo.bar", + package_name: "test.overridden.package" + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + cc_library { + name: "mylib", + srcs: ["mylib.cpp"], + runtime_libs: ["libbar"], + system_shared_libs: [], + stl: "none", + apex_available: [ "myapex" ], + min_sdk_version: "apex_inherit" + } + + cc_library { + name: "libbar", + srcs: ["mylib.cpp"], + system_shared_libs: [], + stl: "none", + apex_available: [ "myapex" ], + min_sdk_version: "apex_inherit" + } + + `, withApexGlobalMinSdkVersionOverride(&minSdkOverride31)) + + apexRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexRule") + copyCmds := apexRule.Args["copy_commands"] + + // Ensure that direct non-stubs dep is always included + ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") + + // Ensure that runtime_libs dep in included + ensureContains(t, copyCmds, "image.apex/lib64/libbar.so") + + // Ensure libraries target overridden min_sdk_version value + ensureListContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_shared_apex31") +} + +func TestMinSdkVersionOverrideToLowerVersionNoOp(t *testing.T) { + // Attempt to override from 31 to 29, should be a NOOP + minSdkOverride29 := "29" + ctx := testApex(t, ` + apex { + name: "myapex", + key: "myapex.key", + native_shared_libs: ["mylib"], + updatable: true, + min_sdk_version: "31" + } + + override_apex { + name: "override_myapex", + base: "myapex", + logging_parent: "com.foo.bar", + package_name: "test.overridden.package" + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + cc_library { + name: "mylib", + srcs: ["mylib.cpp"], + runtime_libs: ["libbar"], + system_shared_libs: [], + stl: "none", + apex_available: [ "myapex" ], + min_sdk_version: "apex_inherit" + } + + cc_library { + name: "libbar", + srcs: ["mylib.cpp"], + system_shared_libs: [], + stl: "none", + apex_available: [ "myapex" ], + min_sdk_version: "apex_inherit" + } + + `, withApexGlobalMinSdkVersionOverride(&minSdkOverride29)) + + apexRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("apexRule") + copyCmds := apexRule.Args["copy_commands"] + + // Ensure that direct non-stubs dep is always included + ensureContains(t, copyCmds, "image.apex/lib64/mylib.so") + + // Ensure that runtime_libs dep in included + ensureContains(t, copyCmds, "image.apex/lib64/libbar.so") + + // Ensure libraries target the original min_sdk_version value rather than the overridden + ensureListContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_shared_apex31") +} + func TestLegacyAndroid10Support(t *testing.T) { ctx := testApex(t, ` apex { diff --git a/apex/builder.go b/apex/builder.go index 8c5f99bf5..c09646520 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -1015,7 +1015,7 @@ func (a *apexBundle) buildApexDependencyInfo(ctx android.ModuleContext) { return !externalDep }) - a.ApexBundleDepsInfo.BuildDepsInfoLists(ctx, proptools.String(a.properties.Min_sdk_version), depInfos) + a.ApexBundleDepsInfo.BuildDepsInfoLists(ctx, a.MinSdkVersion(ctx).Raw, depInfos) ctx.Build(pctx, android.BuildParams{ Rule: android.Phony, From 5892457a68eeae9477dc32d8c1f9ab654788ead6 Mon Sep 17 00:00:00 2001 From: Matt Banda Date: Fri, 1 Apr 2022 17:48:31 +0000 Subject: [PATCH 099/148] Surface Java APIs Used By APK-only Modules. Previously we were only generating used-by API-coverage for APEX modules. This change adds support for APK-only modules such as NetworkStack and DocumentsUI. Bug: b/216313756 Forrest Run: https://android-build.googleplex.com/builds/abtd/run/L10800000953846781 Test: TARGET_BUILD_VARIANT=userdebug PRODUCT=mainline_modules_x86 ./vendor/google/build/build_unbundled_coverage_mainline_module.sh -j16 Change-Id: Id17e4a55c2a52e9903632a654e778f8d54982dfc Merged-In: Id17e4a55c2a52e9903632a654e778f8d54982dfc (cherry picked from commit 56d75785bd52c8a8f684935eed67fceb2c0e6850) --- apex/testing.go | 1 - java/androidmk.go | 4 ++++ java/app.go | 3 +++ java/app_builder.go | 12 ++++++++++++ java/testing.go | 2 ++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/apex/testing.go b/apex/testing.go index 337c86210..69bd73e5d 100644 --- a/apex/testing.go +++ b/apex/testing.go @@ -24,7 +24,6 @@ var PrepareForTestWithApexBuildComponents = android.GroupFixturePreparers( android.MockFS{ // Needed by apex. "system/core/rootdir/etc/public.libraries.android.txt": nil, - "build/soong/scripts/gen_java_usedby_apex.sh": nil, "build/soong/scripts/gen_ndk_backedby_apex.sh": nil, // Needed by prebuilt_apex. "build/soong/scripts/unpack-prebuilt-apex.sh": nil, diff --git a/java/androidmk.go b/java/androidmk.go index 04357e066..43214e586 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -423,6 +423,10 @@ func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries { fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", app.installApkName, app.noticeOutputs.HtmlOutput.String(), app.installApkName+"_NOTICE.html") } + if app.javaApiUsedByOutputFile.String() != "" { + fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s/$(notdir %s))\n", + app.installApkName, app.javaApiUsedByOutputFile.String(), "java_apis_used_by_apex", app.javaApiUsedByOutputFile.String()) + } }, }, }} diff --git a/java/app.go b/java/app.go index 06967690b..cdbea2e42 100755 --- a/java/app.go +++ b/java/app.go @@ -167,6 +167,8 @@ type AndroidApp struct { overriddenManifestPackageName string android.ApexBundleDepsInfo + + javaApiUsedByOutputFile android.ModuleOutPath } func (a *AndroidApp) IsInstallable() bool { @@ -275,6 +277,7 @@ func (a *AndroidTestHelperApp) GenerateAndroidBuildActions(ctx android.ModuleCon func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.checkAppSdkVersions(ctx) a.generateAndroidBuildActions(ctx) + a.generateJavaUsedByApex(ctx) } func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) { diff --git a/java/app_builder.go b/java/app_builder.go index 4a18dcada..bafc98054 100644 --- a/java/app_builder.go +++ b/java/app_builder.go @@ -254,6 +254,18 @@ func TransformJniLibsToJar(ctx android.ModuleContext, outputFile android.Writabl }) } +func (a *AndroidApp) generateJavaUsedByApex(ctx android.ModuleContext) { + javaApiUsedByOutputFile := android.PathForModuleOut(ctx, a.installApkName+"_using.xml") + javaUsedByRule := android.NewRuleBuilder(pctx, ctx) + javaUsedByRule.Command(). + Tool(android.PathForSource(ctx, "build/soong/scripts/gen_java_usedby_apex.sh")). + BuiltTool("dexdeps"). + Output(javaApiUsedByOutputFile). + Input(a.Library.Module.outputFile) + javaUsedByRule.Build("java_usedby_list", "Generate Java APIs used by Apex") + a.javaApiUsedByOutputFile = javaApiUsedByOutputFile +} + func targetToJniDir(target android.Target) string { return filepath.Join("lib", target.Arch.Abi[0]) } diff --git a/java/testing.go b/java/testing.go index d5c464dd8..243e5e849 100644 --- a/java/testing.go +++ b/java/testing.go @@ -54,6 +54,8 @@ var PrepareForTestWithJavaBuildComponents = android.GroupFixturePreparers( "build/soong/java/lint_defaults.txt": nil, // Needed for apps that do not provide their own. "build/make/target/product/security": nil, + // Required to generate Java used-by API coverage + "build/soong/scripts/gen_java_usedby_apex.sh": nil, }.AddToFixture(), ) From 88a40df94ec6fde6b96865206e656b108dd59532 Mon Sep 17 00:00:00 2001 From: Alex Hong Date: Wed, 30 Mar 2022 00:42:11 +0800 Subject: [PATCH 100/148] Add android.hardware.dumpstate-V1-ndk to vndkMustUseVendorVariantList aidl libs need to be differentiated because they explicitly set different system/vendor stabilities. Test: make Bug: 223118410 Change-Id: I5b6e3de9ae2630fea146d97f3de89edf5545ba50 --- cc/config/vndk.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cc/config/vndk.go b/cc/config/vndk.go index a11ff3140..f2e1a90b9 100644 --- a/cc/config/vndk.go +++ b/cc/config/vndk.go @@ -27,6 +27,7 @@ var VndkMustUseVendorVariantList = []string{ "android.hardware.automotive.occupant_awareness-V1-ndk_platform", "android.hardware.automotive.occupant_awareness-ndk_platform", "android.hardware.drm-V1-ndk", + "android.hardware.dumpstate-V1-ndk", "android.hardware.gnss-V1-ndk", "android.hardware.gnss-V1-ndk_platform", "android.hardware.gnss-ndk_platform", From 9d0f2c1c445c9520c6825b7564e2991e2c566368 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Wed, 6 Apr 2022 12:48:09 +0000 Subject: [PATCH 101/148] Copy the out/soong/build_number.txt file into sdk snapshots This change adds the build_number.txt file into the sdk snapshot to make it easier to debug issues arising in partner builds caused by the snapshots. The file is added to the root of the snapshot and is called: snapshot-creation-build-number.txt Bug: 201295663 Test: m nothing packages/modules/common/build/mainline_modules_sdks.sh # Check the contents of various snapshots. Merged-In: Ib3ac0cea5c9315cad0b9a3c25d88759097e37163 Change-Id: Ib3ac0cea5c9315cad0b9a3c25d88759097e37163 (cherry picked from commit 51509a156bf8fcc5d413459d3edb69a330391e5f) --- sdk/testing.go | 23 +++++++++++++++++++++-- sdk/update.go | 7 +++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/sdk/testing.go b/sdk/testing.go index 294f1a57d..062f2000e 100644 --- a/sdk/testing.go +++ b/sdk/testing.go @@ -25,6 +25,8 @@ import ( "android/soong/cc" "android/soong/genrule" "android/soong/java" + + "github.com/google/blueprint/proptools" ) // Prepare for running an sdk test with an apex. @@ -81,6 +83,11 @@ var prepareForSdkTest = android.GroupFixturePreparers( } }), + // Add a build number file. + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.BuildNumberFile = proptools.StringPtr(BUILD_NUMBER_FILE) + }), + // Make sure that every test provides all the source files. android.PrepareForTestDisallowNonExistentPaths, android.MockFS{ @@ -143,6 +150,8 @@ func getSdkSnapshotBuildInfo(t *testing.T, result *android.TestResult, sdk *sdk) copyRules := &strings.Builder{} otherCopyRules := &strings.Builder{} snapshotDirPrefix := sdk.builderForTests.snapshotDir.String() + "/" + + seenBuildNumberFile := false for _, bp := range buildParams { switch bp.Rule.String() { case android.Cp.String(): @@ -152,8 +161,14 @@ func getSdkSnapshotBuildInfo(t *testing.T, result *android.TestResult, sdk *sdk) src := android.NormalizePathForTesting(bp.Input) // We differentiate between copy rules for the snapshot, and copy rules for the install file. if strings.HasPrefix(output.String(), snapshotDirPrefix) { - // Get source relative to build directory. - _, _ = fmt.Fprintf(copyRules, "%s -> %s\n", src, dest) + // Don't include the build-number.txt file in the copy rules as that would break lots of + // tests, just verify that it is copied here as it should appear in every snapshot. + if output.Base() == BUILD_NUMBER_FILE { + seenBuildNumberFile = true + } else { + // Get source relative to build directory. + _, _ = fmt.Fprintf(copyRules, "%s -> %s\n", src, dest) + } info.snapshotContents = append(info.snapshotContents, dest) } else { _, _ = fmt.Fprintf(otherCopyRules, "%s -> %s\n", src, dest) @@ -189,6 +204,10 @@ func getSdkSnapshotBuildInfo(t *testing.T, result *android.TestResult, sdk *sdk) } } + if !seenBuildNumberFile { + panic(fmt.Sprintf("Every snapshot must include the %s file", BUILD_NUMBER_FILE)) + } + info.copyRules = copyRules.String() info.otherCopyRules = otherCopyRules.String() diff --git a/sdk/update.go b/sdk/update.go index d9c57c375..a3d94ed86 100644 --- a/sdk/update.go +++ b/sdk/update.go @@ -242,6 +242,10 @@ func appendUniqueVariants(variants []android.SdkAware, newVariant android.SdkAwa return append(variants, newVariant) } +// BUILD_NUMBER_FILE is the name of the file in the snapshot zip that will contain the number of +// the build from which the snapshot was produced. +const BUILD_NUMBER_FILE = "snapshot-creation-build-number.txt" + // SDK directory structure // / // Android.bp : definition of a 'sdk' module is here. This is a hand-made one. @@ -432,6 +436,9 @@ be unnecessary as every module in the sdk already has its own licenses property. bp.build(pctx, ctx, nil) + // Copy the build number file into the snapshot. + builder.CopyToSnapshot(ctx.Config().BuildNumberFile(ctx), BUILD_NUMBER_FILE) + filesToZip := builder.filesToZip // zip them all From 6114bd54ebc6d1d4f5eee600a08ee44bc6ee9a94 Mon Sep 17 00:00:00 2001 From: Yurii Zubrytskyi Date: Mon, 4 Apr 2022 21:39:35 -0700 Subject: [PATCH 102/148] platform/build/soong - Tiramisu is now 33 Bug: 225745567 Test: Build Change-Id: I647b3e979ea9df622d86784f84f1155759e9ac0e --- android/api_levels.go | 74 ++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/android/api_levels.go b/android/api_levels.go index 81638940c..201373061 100644 --- a/android/api_levels.go +++ b/android/api_levels.go @@ -307,24 +307,25 @@ var finalCodenamesMapKey = NewOnceKey("FinalCodenamesMap") func getFinalCodenamesMap(config Config) map[string]int { return config.Once(finalCodenamesMapKey, func() interface{} { apiLevelsMap := map[string]int{ - "G": 9, - "I": 14, - "J": 16, - "J-MR1": 17, - "J-MR2": 18, - "K": 19, - "L": 21, - "L-MR1": 22, - "M": 23, - "N": 24, - "N-MR1": 25, - "O": 26, - "O-MR1": 27, - "P": 28, - "Q": 29, - "R": 30, - "S": 31, - "S-V2": 32, + "G": 9, + "I": 14, + "J": 16, + "J-MR1": 17, + "J-MR2": 18, + "K": 19, + "L": 21, + "L-MR1": 22, + "M": 23, + "N": 24, + "N-MR1": 25, + "O": 26, + "O-MR1": 27, + "P": 28, + "Q": 29, + "R": 30, + "S": 31, + "S-V2": 32, + "Tiramisu": 33, } // TODO: Differentiate "current" and "future". @@ -351,24 +352,25 @@ var apiLevelsMapKey = NewOnceKey("ApiLevelsMap") func GetApiLevelsMap(config Config) map[string]int { return config.Once(apiLevelsMapKey, func() interface{} { apiLevelsMap := map[string]int{ - "G": 9, - "I": 14, - "J": 16, - "J-MR1": 17, - "J-MR2": 18, - "K": 19, - "L": 21, - "L-MR1": 22, - "M": 23, - "N": 24, - "N-MR1": 25, - "O": 26, - "O-MR1": 27, - "P": 28, - "Q": 29, - "R": 30, - "S": 31, - "S-V2": 32, + "G": 9, + "I": 14, + "J": 16, + "J-MR1": 17, + "J-MR2": 18, + "K": 19, + "L": 21, + "L-MR1": 22, + "M": 23, + "N": 24, + "N-MR1": 25, + "O": 26, + "O-MR1": 27, + "P": 28, + "Q": 29, + "R": 30, + "S": 31, + "S-V2": 32, + "Tiramisu": 33, } for i, codename := range config.PlatformVersionActiveCodenames() { apiLevelsMap[codename] = previewAPILevelBase + i From 50493f07979fd25c57cc3ae3755c66c04b5aee4a Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 1 Jun 2021 12:12:31 -0600 Subject: [PATCH 103/148] Hacky workaround for half-finalized builds. Metalava increments the SDK level by one when it's not "REL", so we temporarily force the build to be "REL" while we're still in the process of finalizing it. This CL must be reverted as part of actually declaring "REL". Bug: 171506470 Test: Build (cherry picked from commit 05597c0cc44964f11c8e711d2d03b8dea221b7b9) Change-Id: I18405cdd27769598f5e7a6a968f0dd473f936f6c --- java/droidstubs.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/droidstubs.go b/java/droidstubs.go index 3b1f7c041..d444738a6 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -379,7 +379,8 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a cmd.FlagWithOutput("--generate-api-levels ", d.apiVersionsXml) cmd.FlagWithInput("--apply-api-levels ", d.apiVersionsXml) cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion().String()) - cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) + // STOPSHIP: RESTORE THIS LOGIC WHEN DECLARING "REL" BUILD + // cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) filename := proptools.StringDefault(d.properties.Api_levels_jar_filename, "android.jar") From 6580d84f51da3875209a23f163ae5d74d6804f80 Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Thu, 7 Apr 2022 22:08:44 +0800 Subject: [PATCH 104/148] Disable RBE for header-abi-dumper The header-abi-dumper processes do not terminate when USE_RBE_DUMPER=true. To unblock SDK finalization, the RBE rule is disabled until the bug is fixed. Test: make Bug: 226497964 Change-Id: I3fc2357b71d346fcda431077a68c69757981318b --- cc/builder.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cc/builder.go b/cc/builder.go index 525b1a14f..ff4e9b447 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -728,10 +728,8 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs sAbiDumpFile := android.ObjPathWithExt(ctx, subdir, srcFile, "sdump") sAbiDumpFiles = append(sAbiDumpFiles, sAbiDumpFile) + // TODO(b/226497964): dumpRule = sAbiDumpRE if USE_RBE and RBE_ABI_DUMPER are true. dumpRule := sAbiDump - if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_ABI_DUMPER") { - dumpRule = sAbiDumpRE - } ctx.Build(pctx, android.BuildParams{ Rule: dumpRule, Description: "header-abi-dumper " + srcFile.Rel(), From 445a789d3394569badf21d022864cb4c1d6a3ef5 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Wed, 16 Feb 2022 12:58:55 -0500 Subject: [PATCH 105/148] Remove duplicate optional libs Fixes: 219958699 Test: ./update_prebuilts.py -x ######## Change-Id: I2ff0aff78379da84db5711e5d5a47b1253936bce Merged-In: I2ff0aff78379da84db5711e5d5a47b1253936bce (cherry picked from commit 21d7add8cdf117de762d415ce16a8bd263e34b99) --- cmd/pom2bp/pom2bp.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cmd/pom2bp/pom2bp.go b/cmd/pom2bp/pom2bp.go index 1c88bcae6..f8844fc94 100644 --- a/cmd/pom2bp/pom2bp.go +++ b/cmd/pom2bp/pom2bp.go @@ -627,13 +627,6 @@ var bpDepsTemplate = template.Must(template.New("bp").Parse(` {{- end}} ], {{- end}} - {{- if .BpOptionalUsesLibs}} - optional_uses_libs: [ - {{- range .BpOptionalUsesLibs}} - "{{.}}", - {{- end}} - ], - {{- end}} java_version: "1.7", } `)) From ee1c1998d3a69d008ee5ba6b850155ddc25c89ce Mon Sep 17 00:00:00 2001 From: Rahul Sabnis Date: Tue, 19 Apr 2022 18:00:10 -0700 Subject: [PATCH 106/148] Updates test_config_fixer to also work for SuiteApkInstaller Bug: 228385580 Test: atest BluetoothInstrumentationTests Change-Id: I878309354c4aa5a492fb3d2bcecf8b1410e011ee --- scripts/test_config_fixer.py | 4 +++- scripts/test_config_fixer_test.py | 31 +++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/scripts/test_config_fixer.py b/scripts/test_config_fixer.py index c150e8cfd..3dbc22ec2 100644 --- a/scripts/test_config_fixer.py +++ b/scripts/test_config_fixer.py @@ -28,6 +28,8 @@ from manifest import parse_manifest from manifest import parse_test_config from manifest import write_xml +KNOWN_PREPARERS = ['com.android.tradefed.targetprep.TestAppInstallSetup', + 'com.android.tradefed.targetprep.suite.SuiteApkInstaller'] def parse_args(): """Parse commandline arguments.""" @@ -64,7 +66,7 @@ def overwrite_test_file_name(test_config_doc, test_file_name): tests = get_children_with_tag(test_config, 'target_preparer') for test in tests: - if test.getAttribute('class') == "com.android.tradefed.targetprep.TestAppInstallSetup": + if test.getAttribute('class') in KNOWN_PREPARERS: options = get_children_with_tag(test, 'option') for option in options: if option.getAttribute('name') == "test-file-name": diff --git a/scripts/test_config_fixer_test.py b/scripts/test_config_fixer_test.py index d00a59315..39ce5b3c3 100644 --- a/scripts/test_config_fixer_test.py +++ b/scripts/test_config_fixer_test.py @@ -70,7 +70,7 @@ class OverwritePackageNameTest(unittest.TestCase): class OverwriteTestFileNameTest(unittest.TestCase): """ Unit tests for overwrite_test_file_name function """ - test_config = ( + test_config_test_app_install_setup = ( '\n' '\n' ' \n' @@ -82,15 +82,38 @@ class OverwriteTestFileNameTest(unittest.TestCase): ' \n' '\n') - def test_all(self): - doc = minidom.parseString(self.test_config % ("foo.apk")) + test_config_suite_apk_installer = ( + '\n' + '\n' + ' \n' + ' \n' + ' \n' + ' \n' + '\n') + + def test_testappinstallsetup(self): + doc = minidom.parseString(self.test_config_test_app_install_setup % ("foo.apk")) test_config_fixer.overwrite_test_file_name(doc, "bar.apk") output = io.StringIO() test_config_fixer.write_xml(output, doc) # Only the matching package name in a test node should be updated. - expected = self.test_config % ("bar.apk") + expected = self.test_config_test_app_install_setup % ("bar.apk") + self.assertEqual(expected, output.getvalue()) + + def test_suiteapkinstaller(self): + doc = minidom.parseString(self.test_config_suite_apk_installer % ("foo.apk")) + + test_config_fixer.overwrite_test_file_name(doc, "bar.apk") + output = io.StringIO() + test_config_fixer.write_xml(output, doc) + + # Only the matching package name in a test node should be updated. + expected = self.test_config_suite_apk_installer % ("bar.apk") self.assertEqual(expected, output.getvalue()) From fa652e32a612e0a87e6e1a6348903b63a0c5ffb0 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 20 Apr 2022 22:54:42 +0000 Subject: [PATCH 107/148] Bump minimum minSdkVersion to 19. We need to land an update to the NDK prebuilts and the NDK no longer supports APIs 16-18. Bug: http://b/222341313 Test: treehugger Change-Id: I996b0eb65a7d1ae4cc0687b7ed8f533fbbba295d --- android/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/config.go b/android/config.go index cb2fc6160..9f1fd6a1b 100644 --- a/android/config.go +++ b/android/config.go @@ -778,7 +778,7 @@ func (c *config) PlatformBaseOS() string { } func (c *config) MinSupportedSdkVersion() ApiLevel { - return uncheckedFinalApiLevel(16) + return uncheckedFinalApiLevel(19) } func (c *config) FinalApiLevels() []ApiLevel { From 3b1dcf4f46f169f64d26fa60ae7a15eda78f4750 Mon Sep 17 00:00:00 2001 From: Jingwen Chen Date: Tue, 19 Apr 2022 13:58:58 +0000 Subject: [PATCH 108/148] Append APEX version instead of build ID for APK-in-APEX paths. This CL removes the build_id.mk suffix and replaces it with a hardcoded placeholder string that will be replaced with the actual version in apex_manifest.json by apexer at apex construction time. This means that as long as the apex version is incremented, the APK-in-APEX will be installed to a new directory path from the package manager's perspective. Fixes: 229574810 Bug: 229625490 Bug: 226559955 Bug: 224589412 Bug: 227417611 Bug: 228157333 Bug: 228803590 Bug: 229136249 Test: atest StrictJavaPackagesTest Test: soong tests Test: deapexer list out/dist/com.google.android.permission.apex Ignore-AOSP-First: this is an cherrypick Change-Id: I9cef1418c3fc7e0970d96995b8398f5e82f479e0 Merged-In: I9cef1418c3fc7e0970d96995b8398f5e82f479e0 --- apex/apex.go | 20 +++-------------- apex/apex_test.go | 57 +++++++++++------------------------------------ apex/builder.go | 35 ++++++++++++++++------------- 3 files changed, 36 insertions(+), 76 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index ef1eb8408..92cf53aa2 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -19,7 +19,6 @@ package apex import ( "fmt" "path/filepath" - "regexp" "sort" "strings" @@ -1657,20 +1656,7 @@ type androidApp interface { var _ androidApp = (*java.AndroidApp)(nil) var _ androidApp = (*java.AndroidAppImport)(nil) -func sanitizedBuildIdForPath(ctx android.BaseModuleContext) string { - buildId := ctx.Config().BuildId() - - // The build ID is used as a suffix for a filename, so ensure that - // the set of characters being used are sanitized. - // - any word character: [a-zA-Z0-9_] - // - dots: . - // - dashes: - - validRegex := regexp.MustCompile(`^[\w\.\-\_]+$`) - if !validRegex.MatchString(buildId) { - ctx.ModuleErrorf("Unable to use build id %s as filename suffix, valid characters are [a-z A-Z 0-9 _ . -].", buildId) - } - return buildId -} +const APEX_VERSION_PLACEHOLDER = "__APEX_VERSION_PLACEHOLDER__" func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp androidApp) apexFile { appDir := "app" @@ -1681,7 +1667,7 @@ func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp androidApp) apexF // TODO(b/224589412, b/226559955): Ensure that the subdirname is suffixed // so that PackageManager correctly invalidates the existing installed apk // in favour of the new APK-in-APEX. See bugs for more information. - dirInApex := filepath.Join(appDir, aapp.InstallApkName()+"@"+sanitizedBuildIdForPath(ctx)) + dirInApex := filepath.Join(appDir, aapp.InstallApkName()+"@"+APEX_VERSION_PLACEHOLDER) fileToCopy := aapp.OutputFile() af := newApexFile(ctx, fileToCopy, aapp.BaseModuleName(), dirInApex, app, aapp) @@ -1920,7 +1906,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { // suffixed so that PackageManager correctly invalidates the // existing installed apk in favour of the new APK-in-APEX. // See bugs for more information. - appDirName := filepath.Join(appDir, ap.BaseModuleName()+"@"+sanitizedBuildIdForPath(ctx)) + appDirName := filepath.Join(appDir, ap.BaseModuleName()+"@"+APEX_VERSION_PLACEHOLDER) af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(), appDirName, appSet, ap) af.certificate = java.PresignedCertificate filesInfo = append(filesInfo, af) diff --git a/apex/apex_test.go b/apex/apex_test.go index 7b2905884..4a52115db 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -223,7 +223,6 @@ var prepareForApexTest = android.GroupFixturePreparers( // not because of these tests specifically (it's not used by the tests) variables.Platform_version_active_codenames = []string{"Q", "Tiramisu"} variables.Platform_vndk_version = proptools.StringPtr("29") - variables.BuildId = proptools.StringPtr("TEST.BUILD_ID") }), ) @@ -683,7 +682,7 @@ func TestDefaults(t *testing.T) { "etc/myetc", "javalib/myjar.jar", "lib64/mylib.so", - "app/AppFoo@TEST.BUILD_ID/AppFoo.apk", + "app/AppFoo@__APEX_VERSION_PLACEHOLDER__/AppFoo.apk", "overlay/blue/rro.apk", "etc/bpf/bpf.o", "etc/bpf/bpf2.o", @@ -5683,8 +5682,8 @@ func TestApexWithApps(t *testing.T) { apexRule := module.Rule("apexRule") copyCmds := apexRule.Args["copy_commands"] - ensureContains(t, copyCmds, "image.apex/app/AppFoo@TEST.BUILD_ID/AppFoo.apk") - ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv@TEST.BUILD_ID/AppFooPriv.apk") + ensureContains(t, copyCmds, "image.apex/app/AppFoo@__APEX_VERSION_PLACEHOLDER__/AppFoo.apk") + ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv@__APEX_VERSION_PLACEHOLDER__/AppFooPriv.apk") appZipRule := ctx.ModuleForTests("AppFoo", "android_common_apex10000").Description("zip jni libs") // JNI libraries are uncompressed @@ -5701,36 +5700,6 @@ func TestApexWithApps(t *testing.T) { } } -func TestApexWithAppImportBuildId(t *testing.T) { - invalidBuildIds := []string{"../", "a b", "a/b", "a/b/../c", "/a"} - for _, id := range invalidBuildIds { - message := fmt.Sprintf("Unable to use build id %s as filename suffix", id) - fixture := android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.BuildId = proptools.StringPtr(id) - }) - testApexError(t, message, `apex { - name: "myapex", - key: "myapex.key", - apps: ["AppFooPrebuilt"], - updatable: false, - } - - apex_key { - name: "myapex.key", - public_key: "testkey.avbpubkey", - private_key: "testkey.pem", - } - - android_app_import { - name: "AppFooPrebuilt", - apk: "PrebuiltAppFoo.apk", - presigned: true, - apex_available: ["myapex"], - } - `, fixture) - } -} - func TestApexWithAppImports(t *testing.T) { ctx := testApex(t, ` apex { @@ -5776,8 +5745,8 @@ func TestApexWithAppImports(t *testing.T) { apexRule := module.Rule("apexRule") copyCmds := apexRule.Args["copy_commands"] - ensureContains(t, copyCmds, "image.apex/app/AppFooPrebuilt@TEST.BUILD_ID/AppFooPrebuilt.apk") - ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPrivPrebuilt@TEST.BUILD_ID/AwesomePrebuiltAppFooPriv.apk") + ensureContains(t, copyCmds, "image.apex/app/AppFooPrebuilt@__APEX_VERSION_PLACEHOLDER__/AppFooPrebuilt.apk") + ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPrivPrebuilt@__APEX_VERSION_PLACEHOLDER__/AwesomePrebuiltAppFooPriv.apk") } func TestApexWithAppImportsPrefer(t *testing.T) { @@ -5818,7 +5787,7 @@ func TestApexWithAppImportsPrefer(t *testing.T) { })) ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{ - "app/AppFoo@TEST.BUILD_ID/AppFooPrebuilt.apk", + "app/AppFoo@__APEX_VERSION_PLACEHOLDER__/AppFooPrebuilt.apk", }) } @@ -5851,7 +5820,7 @@ func TestApexWithTestHelperApp(t *testing.T) { apexRule := module.Rule("apexRule") copyCmds := apexRule.Args["copy_commands"] - ensureContains(t, copyCmds, "image.apex/app/TesterHelpAppFoo@TEST.BUILD_ID/TesterHelpAppFoo.apk") + ensureContains(t, copyCmds, "image.apex/app/TesterHelpAppFoo@__APEX_VERSION_PLACEHOLDER__/TesterHelpAppFoo.apk") } func TestApexPropertiesShouldBeDefaultable(t *testing.T) { @@ -6294,8 +6263,8 @@ func TestOverrideApex(t *testing.T) { apexRule := module.Rule("apexRule") copyCmds := apexRule.Args["copy_commands"] - ensureNotContains(t, copyCmds, "image.apex/app/app@TEST.BUILD_ID/app.apk") - ensureContains(t, copyCmds, "image.apex/app/override_app@TEST.BUILD_ID/override_app.apk") + ensureNotContains(t, copyCmds, "image.apex/app/app@__APEX_VERSION_PLACEHOLDER__/app.apk") + ensureContains(t, copyCmds, "image.apex/app/override_app@__APEX_VERSION_PLACEHOLDER__/override_app.apk") ensureNotContains(t, copyCmds, "image.apex/etc/bpf/bpf.o") ensureContains(t, copyCmds, "image.apex/etc/bpf/override_bpf.o") @@ -7199,7 +7168,7 @@ func TestAppBundle(t *testing.T) { content := bundleConfigRule.Args["content"] ensureContains(t, content, `"compression":{"uncompressed_glob":["apex_payload.img","apex_manifest.*"]}`) - ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.android.foo","path":"app/AppFoo@TEST.BUILD_ID/AppFoo.apk"}]}`) + ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.android.foo","path":"app/AppFoo@__APEX_VERSION_PLACEHOLDER__/AppFoo.apk"}]}`) } func TestAppSetBundle(t *testing.T) { @@ -7230,9 +7199,9 @@ func TestAppSetBundle(t *testing.T) { if len(copyCmds) != 3 { t.Fatalf("Expected 3 commands, got %d in:\n%s", len(copyCmds), s) } - ensureMatches(t, copyCmds[0], "^rm -rf .*/app/AppSet@TEST.BUILD_ID$") - ensureMatches(t, copyCmds[1], "^mkdir -p .*/app/AppSet@TEST.BUILD_ID$") - ensureMatches(t, copyCmds[2], "^unzip .*-d .*/app/AppSet@TEST.BUILD_ID .*/AppSet.zip$") + ensureMatches(t, copyCmds[0], "^rm -rf .*/app/AppSet@__APEX_VERSION_PLACEHOLDER__$") + ensureMatches(t, copyCmds[1], "^mkdir -p .*/app/AppSet@__APEX_VERSION_PLACEHOLDER__$") + ensureMatches(t, copyCmds[2], "^unzip .*-d .*/app/AppSet@__APEX_VERSION_PLACEHOLDER__ .*/AppSet.zip$") } func TestAppSetBundlePrebuilt(t *testing.T) { diff --git a/apex/builder.go b/apex/builder.go index abbf8ad25..d4765d022 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -107,14 +107,16 @@ var ( `--canned_fs_config ${canned_fs_config} ` + `--include_build_info ` + `--payload_type image ` + - `--key ${key} ${opt_flags} ${image_dir} ${out} `, + `--key ${key} ` + + `--apex_version_placeholder ${apex_version_placeholder} ` + + `${opt_flags} ${image_dir} ${out} `, CommandDeps: []string{"${apexer}", "${avbtool}", "${e2fsdroid}", "${merge_zips}", "${mke2fs}", "${resize2fs}", "${sefcontext_compile}", "${make_f2fs}", "${sload_f2fs}", "${make_erofs}", "${soong_zip}", "${zipalign}", "${aapt2}", "prebuilts/sdk/current/public/android.jar"}, Rspfile: "${out}.copy_commands", RspfileContent: "${copy_commands}", Description: "APEX ${image_dir} => ${out}", - }, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key", "opt_flags", "manifest", "payload_fs_type") + }, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key", "opt_flags", "manifest", "payload_fs_type", "apex_version_placeholder") zipApexRule = pctx.StaticRule("zipApexRule", blueprint.RuleParams{ Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` + @@ -122,12 +124,13 @@ var ( `APEXER_TOOL_PATH=${tool_path} ` + `${apexer} --force --manifest ${manifest} ` + `--payload_type zip ` + + `--apex_version_placeholder ${apex_version_placeholder} ` + `${image_dir} ${out} `, CommandDeps: []string{"${apexer}", "${merge_zips}", "${soong_zip}", "${zipalign}", "${aapt2}"}, Rspfile: "${out}.copy_commands", RspfileContent: "${copy_commands}", Description: "ZipAPEX ${image_dir} => ${out}", - }, "tool_path", "image_dir", "copy_commands", "manifest") + }, "tool_path", "image_dir", "copy_commands", "manifest", "apex_version_placeholder") apexProtoConvertRule = pctx.AndroidStaticRule("apexProtoConvertRule", blueprint.RuleParams{ @@ -658,14 +661,15 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { Output: unsignedOutputFile, Description: "apex (" + apexType.name() + ")", Args: map[string]string{ - "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir, - "image_dir": imageDir.String(), - "copy_commands": strings.Join(copyCommands, " && "), - "manifest": a.manifestPbOut.String(), - "file_contexts": fileContexts.String(), - "canned_fs_config": cannedFsConfig.String(), - "key": a.privateKeyFile.String(), - "opt_flags": strings.Join(optFlags, " "), + "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir, + "image_dir": imageDir.String(), + "copy_commands": strings.Join(copyCommands, " && "), + "manifest": a.manifestPbOut.String(), + "file_contexts": fileContexts.String(), + "canned_fs_config": cannedFsConfig.String(), + "key": a.privateKeyFile.String(), + "opt_flags": strings.Join(optFlags, " "), + "apex_version_placeholder": APEX_VERSION_PLACEHOLDER, }, }) @@ -757,10 +761,11 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { Output: unsignedOutputFile, Description: "apex (" + apexType.name() + ")", Args: map[string]string{ - "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir, - "image_dir": imageDir.String(), - "copy_commands": strings.Join(copyCommands, " && "), - "manifest": a.manifestPbOut.String(), + "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir, + "image_dir": imageDir.String(), + "copy_commands": strings.Join(copyCommands, " && "), + "manifest": a.manifestPbOut.String(), + "apex_version_placeholder": APEX_VERSION_PLACEHOLDER, }, }) } From db7e0ceb2f34d02f7471e7b39ea4592ccdfccc1e Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Sun, 24 Apr 2022 12:38:30 +0800 Subject: [PATCH 109/148] Update to clang-r450784d This respin contains performance improvements to clang-tidy and lld, and fp16 cost fixes. Test: presubmit Bug: 219872481 Change-Id: I322a680cdc6ebc0f1fe3735ed087477e7f2508fe (cherry picked from commit a126c630428d4f3264a9fac3e8b58514a6171cc7) Merged-In: I322a680cdc6ebc0f1fe3735ed087477e7f2508fe --- cc/config/global.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cc/config/global.go b/cc/config/global.go index 65bfbf0f9..3caf32792 100644 --- a/cc/config/global.go +++ b/cc/config/global.go @@ -286,8 +286,8 @@ var ( // prebuilts/clang default settings. ClangDefaultBase = "prebuilts/clang/host" - ClangDefaultVersion = "clang-r450784c" - ClangDefaultShortVersion = "14.0.5" + ClangDefaultVersion = "clang-r450784d" + ClangDefaultShortVersion = "14.0.6" // Directories with warnings from Android.bp files. WarningAllowedProjects = []string{ From 92e3e4fbf6e7e15415c819a3b9cc50f45692810e Mon Sep 17 00:00:00 2001 From: Oriol Prieto Gasco Date: Wed, 27 Apr 2022 15:21:27 +0000 Subject: [PATCH 110/148] Set the dist dir for musl targets of build_version_test Bug: 230604501 Test: build/soong/soong_ui.bash --make-mode apexer_tools static_apexer_tools dist BUILD_HOST_static=1 USE_HOST_MUSL=true Change-Id: I29b7f4c16346e39b89f099eecf816d9811a7b587 --- cc/libbuildversion/tests/Android.bp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cc/libbuildversion/tests/Android.bp b/cc/libbuildversion/tests/Android.bp index 0e97fedff..c616a3351 100644 --- a/cc/libbuildversion/tests/Android.bp +++ b/cc/libbuildversion/tests/Android.bp @@ -35,6 +35,16 @@ cc_defaults { dir: "host/", }, }, + linux_musl_x86: { + dist: { + dir: "host32/", + }, + }, + linux_musl_x86_64: { + dist: { + dir: "host/", + }, + }, linux_glibc_x86: { dist: { dir: "host32/", From a083ec4acf53bd65676df31a5d99db2574a6b0aa Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 28 Apr 2022 14:13:30 +0000 Subject: [PATCH 111/148] Allow framework-media to build the framework-media.impl (cherry picked from commit 77590a82638fdd3d1d9e12cd57270e1a9cb2eaa7) The framework-media java_sdk_library is currently api_only for legacy reasons. This change allows it to also build the framework-media.impl library by making the following changes: * Adds impl_only_static_libs to allow the implementation to statically include other libraries, something no other java_sdk_library has needed to do. * Passes the apex_availability property through to the impl library so it can be statically included in the updatable-media which is what is included in the apex, again for legacy reasons. Bug: 190807367 Bug: 229932396 Test: m com.android.media media-module-sdk # Compare before and after this change (and corresponding change # to updatable-media/framework-media. Merged-In: I9e1837edcca6f5fa84fc611274cf8fbba8a896b8 Change-Id: I9e1837edcca6f5fa84fc611274cf8fbba8a896b8 --- java/sdk_library.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index c37ed1a27..fb032559e 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -377,6 +377,9 @@ type sdkLibraryProperties struct { // List of Java libraries that will be in the classpath when building the implementation lib Impl_only_libs []string `android:"arch_variant"` + // List of Java libraries that will included in the implementation lib. + Impl_only_static_libs []string `android:"arch_variant"` + // List of Java libraries that will be in the classpath when building stubs Stub_only_libs []string `android:"arch_variant"` @@ -1346,10 +1349,12 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) visibility := childModuleVisibility(module.sdkLibraryProperties.Impl_library_visibility) props := struct { - Name *string - Visibility []string - Instrument bool - Libs []string + Name *string + Visibility []string + Instrument bool + Libs []string + Static_libs []string + Apex_available []string }{ Name: proptools.StringPtr(module.implLibraryModuleName()), Visibility: visibility, @@ -1358,6 +1363,12 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) // Set the impl_only libs. Note that the module's "Libs" get appended as well, via the // addition of &module.properties below. Libs: module.sdkLibraryProperties.Impl_only_libs, + // Set the impl_only static libs. Note that the module's "static_libs" get appended as well, via the + // addition of &module.properties below. + Static_libs: module.sdkLibraryProperties.Impl_only_static_libs, + // Pass the apex_available settings down so that the impl library can be statically + // embedded within a library that is added to an APEX. Needed for updatable-media. + Apex_available: module.ApexAvailable(), } properties := []interface{}{ @@ -1814,8 +1825,9 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookCont *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName()) } - // Add the impl_only_libs *after* we're done using the Libs prop in submodules. + // Add the impl_only_libs and impl_only_static_libs *after* we're done using them in submodules. module.properties.Libs = append(module.properties.Libs, module.sdkLibraryProperties.Impl_only_libs...) + module.properties.Static_libs = append(module.properties.Static_libs, module.sdkLibraryProperties.Impl_only_static_libs...) } func (module *SdkLibrary) InitSdkLibraryProperties() { From 3cf140fe98baf01cfc35a52a551d5e6d41159ed7 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 29 Apr 2022 14:21:25 +0100 Subject: [PATCH 112/148] java_sdk_library_import: Delegate OutputFiles to impl library if needed Bug: 230846030 Test: m nothing # Cherry pick into build with prebuilts enabled to verify. Merged-In: I5ac9b1cdd2fc61efbc988e84556202ff6cd57146 Change-Id: I5ac9b1cdd2fc61efbc988e84556202ff6cd57146 (cherry picked from commit 1e940d5b449148105e33d75cbef4bbde307bf1f9) --- java/sdk_library.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index fb032559e..2c67767bf 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -2224,7 +2224,15 @@ func (module *SdkLibraryImport) UniqueApexVariations() bool { } func (module *SdkLibraryImport) OutputFiles(tag string) (android.Paths, error) { - return module.commonOutputFiles(tag) + paths, err := module.commonOutputFiles(tag) + if paths != nil || err != nil { + return paths, err + } + if module.implLibraryModule != nil { + return module.implLibraryModule.OutputFiles(tag) + } else { + return nil, nil + } } func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { From a80cc174a2b56b53c8fed1cf6c868f760404b3c1 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 28 Apr 2022 17:45:11 +0100 Subject: [PATCH 113/148] hiddenapi: Prevent libraries for Q/R from include S+ flags. The Q and R runtimes can handle Q/R flags but not S flags. So, this change verifies that any library that can run on Q/R (min_sdk_version <= R) by adding --max-hiddenapi-level=max-target-r to the "hiddenapi encode" command. That will cause a failure if any S+ flags are found in the flags to encode. Bug: 172453495 Test: m droid && launch_cvd Cherry pick changes in https://r.android.com/q/topic:max-target-s Add @UnsupportedAppUsage maxTargetSdk=S in classes in framework-permission (for r/q) and framework-permission-s (nominally for S+). I had to incresed the min_sdk_version in the latter to 31 (S) as it was still set at 30 (R). Merged-In: Ie0f68482603adc7b4e3d7a5c81bf203d81a84a9e Change-Id: Ie0f68482603adc7b4e3d7a5c81bf203d81a84a9e (cherry picked from commit 09817d66dea3639528b35a5b61ddce78766d198c) --- java/hiddenapi.go | 15 +++++++++++++-- java/hiddenapi_modular.go | 6 +++++- java/sdk_library.go | 7 +++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/java/hiddenapi.go b/java/hiddenapi.go index 3af5f1c7b..cf9c7ad7a 100644 --- a/java/hiddenapi.go +++ b/java/hiddenapi.go @@ -65,6 +65,8 @@ func (h *hiddenAPI) uncompressDex() *bool { type hiddenAPIModule interface { android.Module hiddenAPIIntf + + MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec } type hiddenAPIIntf interface { @@ -148,7 +150,7 @@ func (h *hiddenAPI) hiddenAPIEncodeDex(ctx android.ModuleContext, dexJar android // Create a copy of the dex jar which has been encoded with hiddenapi flags. flagsCSV := hiddenAPISingletonPaths(ctx).flags outputDir := android.PathForModuleOut(ctx, "hiddenapi").OutputPath - encodedDex := hiddenAPIEncodeDex(ctx, dexJar, flagsCSV, uncompressDex, outputDir) + encodedDex := hiddenAPIEncodeDex(ctx, dexJar, flagsCSV, uncompressDex, android.SdkSpecNone, outputDir) // Use the encoded dex jar from here onwards. return encodedDex @@ -246,7 +248,7 @@ var hiddenAPIEncodeDexRule = pctx.AndroidStaticRule("hiddenAPIEncodeDex", bluepr // The encode dex rule requires unzipping, encoding and rezipping the classes.dex files along with // all the resources from the input jar. It also ensures that if it was uncompressed in the input // it stays uncompressed in the output. -func hiddenAPIEncodeDex(ctx android.ModuleContext, dexInput, flagsCSV android.Path, uncompressDex bool, outputDir android.OutputPath) android.OutputPath { +func hiddenAPIEncodeDex(ctx android.ModuleContext, dexInput, flagsCSV android.Path, uncompressDex bool, minSdkVersion android.SdkSpec, outputDir android.OutputPath) android.OutputPath { // The output file has the same name as the input file and is in the output directory. output := outputDir.Join(ctx, dexInput.Base()) @@ -274,6 +276,15 @@ func hiddenAPIEncodeDex(ctx android.ModuleContext, dexInput, flagsCSV android.Pa hiddenapiFlags = "--no-force-assign-all" } + // If the library is targeted for Q and/or R then make sure that they do not + // have any S+ flags encoded as that will break the runtime. + minApiLevel := minSdkVersion.ApiLevel + if !minApiLevel.IsNone() { + if minApiLevel.LessThanOrEqualTo(android.ApiLevelOrPanic(ctx, "R")) { + hiddenapiFlags = hiddenapiFlags + " --max-hiddenapi-level=max-target-r" + } + } + ctx.Build(pctx, android.BuildParams{ Rule: hiddenAPIEncodeDexRule, Description: "hiddenapi encode dex", diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go index 534a8145f..c90b2ff97 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go @@ -1104,7 +1104,7 @@ func hiddenAPIRulesForBootclasspathFragment(ctx android.ModuleContext, contents for _, name := range android.SortedStringKeys(bootDexInfoByModule) { bootDexInfo := bootDexInfoByModule[name] unencodedDex := bootDexInfo.path - encodedDex := hiddenAPIEncodeDex(ctx, unencodedDex, allFlagsCSV, bootDexInfo.uncompressDex, outputDir) + encodedDex := hiddenAPIEncodeDex(ctx, unencodedDex, allFlagsCSV, bootDexInfo.uncompressDex, bootDexInfo.minSdkVersion, outputDir) encodedBootDexJarsByModule[name] = encodedDex } @@ -1188,6 +1188,9 @@ type bootDexInfo struct { // Indicates whether the dex jar needs uncompressing before encoding. uncompressDex bool + + // The minimum sdk version that the dex jar will be used on. + minSdkVersion android.SdkSpec } // bootDexInfoByModule is a map from module name (as returned by module.Name()) to the boot dex @@ -1213,6 +1216,7 @@ func extractBootDexInfoFromModules(ctx android.ModuleContext, contents []android bootDexJarsByModule[module.Name()] = bootDexInfo{ path: bootDexJar, uncompressDex: *hiddenAPIModule.uncompressDex(), + minSdkVersion: hiddenAPIModule.MinSdkVersion(ctx), } } diff --git a/java/sdk_library.go b/java/sdk_library.go index fb032559e..031848e36 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -2223,6 +2223,13 @@ func (module *SdkLibraryImport) UniqueApexVariations() bool { return module.uniqueApexVariations() } +// MinSdkVersion - Implements hiddenAPIModule +func (module *SdkLibraryImport) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { + return android.SdkSpecNone +} + +var _ hiddenAPIModule = (*SdkLibraryImport)(nil) + func (module *SdkLibraryImport) OutputFiles(tag string) (android.Paths, error) { return module.commonOutputFiles(tag) } From a3264efb42ffb03470b48cf070025055b34ca5d7 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Fri, 22 Apr 2022 17:28:25 +0000 Subject: [PATCH 114/148] Enforce newapi check only if min_sdk_version < compile_sdk_version - NewApi check should be enforced only if min_sdk_version is less than the compile_sdk_version (the opposite direction should be a different build-time error) - Change the datatype of *sdkVersion to android.ApiLevel (from string) to support version comparisons Test: go build ./java Test: no changes in ninja file Bug: 228956345 Merged-In: Ic408857db7760d912ef4694d2ed72c0b7106eb04 Change-Id: Ic408857db7760d912ef4694d2ed72c0b7106eb04 (cherry picked from commit ba7e532a117a64710bdd0493b21b671cf94033d8) --- java/base.go | 12 ++++++------ java/lint.go | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/java/base.go b/java/base.go index b925350a0..a0767183d 100644 --- a/java/base.go +++ b/java/base.go @@ -1481,11 +1481,11 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { } if ctx.Device() { - lintSDKVersionString := func(sdkSpec android.SdkSpec) string { + lintSDKVersion := func(sdkSpec android.SdkSpec) android.ApiLevel { if v := sdkSpec.ApiLevel; !v.IsPreview() { - return v.String() + return v } else { - return ctx.Config().DefaultAppTargetSdk(ctx).String() + return ctx.Config().DefaultAppTargetSdk(ctx) } } @@ -1494,9 +1494,9 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { j.linter.srcJars = srcJars j.linter.classpath = append(append(android.Paths(nil), flags.bootClasspath...), flags.classpath...) j.linter.classes = j.implementationJarFile - j.linter.minSdkVersion = lintSDKVersionString(j.MinSdkVersion(ctx)) - j.linter.targetSdkVersion = lintSDKVersionString(j.TargetSdkVersion(ctx)) - j.linter.compileSdkVersion = lintSDKVersionString(j.SdkVersion(ctx)) + j.linter.minSdkVersion = lintSDKVersion(j.MinSdkVersion(ctx)) + j.linter.targetSdkVersion = lintSDKVersion(j.TargetSdkVersion(ctx)) + j.linter.compileSdkVersion = lintSDKVersion(j.SdkVersion(ctx)) j.linter.compileSdkKind = j.SdkVersion(ctx).Kind j.linter.javaLanguageLevel = flags.javaVersion.String() j.linter.kotlinLanguageLevel = "1.3" diff --git a/java/lint.go b/java/lint.go index e97c9c225..426a2af25 100644 --- a/java/lint.go +++ b/java/lint.go @@ -75,9 +75,9 @@ type linter struct { extraLintCheckJars android.Paths test bool library bool - minSdkVersion string - targetSdkVersion string - compileSdkVersion string + minSdkVersion android.ApiLevel + targetSdkVersion android.ApiLevel + compileSdkVersion android.ApiLevel compileSdkKind android.SdkKind javaLanguageLevel string kotlinLanguageLevel string @@ -300,7 +300,7 @@ func (l *linter) generateManifest(ctx android.ModuleContext, rule *android.RuleB Text(`echo "" &&`). Textf(`echo " " &&`, - l.minSdkVersion, l.targetSdkVersion). + l.minSdkVersion.String(), l.targetSdkVersion.String()). Text(`echo ""`). Text(") >").Output(manifestPath) @@ -325,7 +325,7 @@ func (l *linter) lint(ctx android.ModuleContext) { return } - if l.minSdkVersion != l.compileSdkVersion { + if l.minSdkVersion.CompareTo(l.compileSdkVersion) == -1 { l.extraMainlineLintErrors = append(l.extraMainlineLintErrors, updatabilityChecks...) _, filtered := android.FilterList(l.properties.Lint.Warning_checks, updatabilityChecks) if len(filtered) != 0 { @@ -427,7 +427,7 @@ func (l *linter) lint(ctx android.ModuleContext) { FlagWithOutput("--html ", html). FlagWithOutput("--text ", text). FlagWithOutput("--xml ", xml). - FlagWithArg("--compile-sdk-version ", l.compileSdkVersion). + FlagWithArg("--compile-sdk-version ", l.compileSdkVersion.String()). FlagWithArg("--java-language-level ", l.javaLanguageLevel). FlagWithArg("--kotlin-language-level ", l.kotlinLanguageLevel). FlagWithArg("--url ", fmt.Sprintf(".=.,%s=out", android.PathForOutput(ctx).String())). From 2a42e554570546075acf464ad376d09fbdc31762 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Fri, 22 Apr 2022 17:28:57 +0000 Subject: [PATCH 115/148] Disable newapi check in defaults - Making newapi disabled by default will ensure that this lint check does not run on the platform. This prevents noisy lint warnings like b/228956345#1 - This lint check will continue to be enforced on the transitive deps of apexes, since lint.strict_updatability_linting will be true for those Soong modules Test: TH Test: m out/soong/.intermediates/frameworks/base/services/core/services.core.unboosted/android_common/lint/lint-report.xml // file no longer contains "Call requires API level ..." warning Bug: 228956345 Merged-In: I8ef3137394011fb679a1129f80f6351fb05a4eff Change-Id: I8ef3137394011fb679a1129f80f6351fb05a4eff (cherry picked from commit 397e910835144efce4f11049b9fff6992e7c24ec) --- java/lint_defaults.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/java/lint_defaults.txt b/java/lint_defaults.txt index 4bc0c5fd4..1eee354cd 100644 --- a/java/lint_defaults.txt +++ b/java/lint_defaults.txt @@ -28,6 +28,11 @@ --disable_check SuspiciousImport --disable_check UnusedResources --disable_check ViewConstructor +# Disable NewApi checks for the platform since platform is the one that implements +# the API. This prevents noisy lint warnings like b/228956345#1 +# NewApi checks will continue to be enforced for apex deps since +# lint.strict_updatability_linting will be true for those Soong modules +--disable_check NewApi # Downgrade existing errors to warnings --warning_check AppCompatResource # 55 occurences in 10 modules @@ -66,7 +71,6 @@ --warning_check MissingTvBanner # 3 occurences in 3 modules --warning_check NamespaceTypo # 3 occurences in 3 modules --warning_check NetworkSecurityConfig # 46 occurences in 12 modules ---warning_check NewApi # 1996 occurences in 122 modules --warning_check NotSibling # 15 occurences in 10 modules --warning_check ObjectAnimatorBinding # 14 occurences in 5 modules --warning_check OnClick # 49 occurences in 21 modules From c7c47461519fe6ad0b750b71e29315d96490bc9d Mon Sep 17 00:00:00 2001 From: Inseob Kim Date: Mon, 25 Apr 2022 18:23:58 +0900 Subject: [PATCH 116/148] Add buildinfo_prop module buildinfo_prop module is a replacement for build/make/tools/buildinfo.sh so other images like microdroid can refer to build.prop. For now, buildinfo_prop only supports a few build.prop properties, and it's only used in microdroid. Bug: 189164487 Test: build Change-Id: I120654ca23a68de414df8da2051c6677afbab441 Merged-In: I120654ca23a68de414df8da2051c6677afbab441 (cherry picked from commit 4f1f3d97cacf4d92df00ff156062d0b65426434a) --- Android.bp | 11 +++ android/Android.bp | 1 + android/buildinfo_prop.go | 182 ++++++++++++++++++++++++++++++++++++++ android/config.go | 4 + android/variable.go | 1 + 5 files changed, 199 insertions(+) create mode 100644 android/buildinfo_prop.go diff --git a/Android.bp b/Android.bp index 42a8e5c91..63de01589 100644 --- a/Android.bp +++ b/Android.bp @@ -119,3 +119,14 @@ genrule { dexpreopt_systemserver_check { name: "dexpreopt_systemserver_check", } + +// buildinfo.prop contains common properties for system/build.prop, like ro.build.version.* +buildinfo_prop { + name: "buildinfo.prop", + + // not installable because this will be included to system/build.prop + installable: false, + + // Currently, only microdroid can refer to buildinfo.prop + visibility: ["//packages/modules/Virtualization/microdroid"], +} diff --git a/android/Android.bp b/android/Android.bp index 87b021fb6..d58370391 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -36,6 +36,7 @@ bootstrap_go_package { "bazel.go", "bazel_handler.go", "bazel_paths.go", + "buildinfo_prop.go", "config.go", "config_bp2build.go", "csuite_config.go", diff --git a/android/buildinfo_prop.go b/android/buildinfo_prop.go new file mode 100644 index 000000000..6339a7181 --- /dev/null +++ b/android/buildinfo_prop.go @@ -0,0 +1,182 @@ +// Copyright 2022 Google Inc. All rights reserved. +// +// 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. + +package android + +import ( + "fmt" + "strings" + + "github.com/google/blueprint/proptools" +) + +func init() { + ctx := InitRegistrationContext + ctx.RegisterSingletonModuleType("buildinfo_prop", buildinfoPropFactory) +} + +type buildinfoPropProperties struct { + // Whether this module is directly installable to one of the partitions. Default: true. + Installable *bool +} + +type buildinfoPropModule struct { + SingletonModuleBase + + properties buildinfoPropProperties + + outputFilePath OutputPath + installPath InstallPath +} + +var _ OutputFileProducer = (*buildinfoPropModule)(nil) + +func (p *buildinfoPropModule) installable() bool { + return proptools.BoolDefault(p.properties.Installable, true) +} + +// OutputFileProducer +func (p *buildinfoPropModule) OutputFiles(tag string) (Paths, error) { + if tag != "" { + return nil, fmt.Errorf("unsupported tag %q", tag) + } + return Paths{p.outputFilePath}, nil +} + +func (p *buildinfoPropModule) GenerateAndroidBuildActions(ctx ModuleContext) { + p.outputFilePath = PathForModuleOut(ctx, p.Name()).OutputPath + if !ctx.Config().KatiEnabled() { + WriteFileRule(ctx, p.outputFilePath, "# no buildinfo.prop if kati is disabled") + return + } + + rule := NewRuleBuilder(pctx, ctx) + cmd := rule.Command().Text("(") + + writeString := func(str string) { + cmd.Text(`echo "` + str + `" && `) + } + + writeString("# begin build properties") + writeString("# autogenerated by build/soong/android/buildinfo_prop.go") + + writeProp := func(key, value string) { + if strings.Contains(key, "=") { + panic(fmt.Errorf("wrong property key %q: key must not contain '='", key)) + } + writeString(key + "=" + value) + } + + config := ctx.Config() + + writeProp("ro.build.version.sdk", config.PlatformSdkVersion().String()) + writeProp("ro.build.version.preview_sdk", config.PlatformPreviewSdkVersion()) + writeProp("ro.build.version.codename", config.PlatformSdkCodename()) + writeProp("ro.build.version.all_codenames", strings.Join(config.PlatformVersionActiveCodenames(), ",")) + writeProp("ro.build.version.release", config.PlatformVersionLastStable()) + writeProp("ro.build.version.release_or_codename", config.PlatformVersionName()) + writeProp("ro.build.version.security_patch", config.PlatformSecurityPatch()) + writeProp("ro.build.version.base_os", config.PlatformBaseOS()) + writeProp("ro.build.version.min_supported_target_sdk", config.PlatformMinSupportedTargetSdkVersion()) + + if config.Eng() { + writeProp("ro.build.type", "eng") + } else if config.Debuggable() { + writeProp("ro.build.type", "userdebug") + } else { + writeProp("ro.build.type", "user") + } + + // Currently, only a few properties are implemented to unblock microdroid use case. + // TODO(b/189164487): support below properties as well and replace build/make/tools/buildinfo.sh + /* + if $BOARD_USE_VBMETA_DIGTEST_IN_FINGERPRINT { + writeProp("ro.build.legacy.id", config.BuildID()) + } else { + writeProp("ro.build.id", config.BuildId()) + } + writeProp("ro.build.display.id", $BUILD_DISPLAY_ID) + writeProp("ro.build.version.incremental", $BUILD_NUMBER) + writeProp("ro.build.version.preview_sdk_fingerprint", $PLATFORM_PREVIEW_SDK_FINGERPRINT) + writeProp("ro.build.version.known_codenames", $PLATFORM_VERSION_KNOWN_CODENAMES) + writeProp("ro.build.version.release_or_preview_display", $PLATFORM_DISPLAY_VERSION) + writeProp("ro.build.date", `$DATE`) + writeProp("ro.build.date.utc", `$DATE +%s`) + writeProp("ro.build.user", $BUILD_USERNAME) + writeProp("ro.build.host", $BUILD_HOSTNAME) + writeProp("ro.build.tags", $BUILD_VERSION_TAGS) + writeProp("ro.build.flavor", $TARGET_BUILD_FLAVOR) + // These values are deprecated, use "ro.product.cpu.abilist" + // instead (see below). + writeString("# ro.product.cpu.abi and ro.product.cpu.abi2 are obsolete,") + writeString("# use ro.product.cpu.abilist instead.") + writeProp("ro.product.cpu.abi", $TARGET_CPU_ABI) + if [ -n "$TARGET_CPU_ABI2" ] { + writeProp("ro.product.cpu.abi2", $TARGET_CPU_ABI2) + } + + if [ -n "$PRODUCT_DEFAULT_LOCALE" ] { + writeProp("ro.product.locale", $PRODUCT_DEFAULT_LOCALE) + } + writeProp("ro.wifi.channels", $PRODUCT_DEFAULT_WIFI_CHANNELS) + writeString("# ro.build.product is obsolete; use ro.product.device") + writeProp("ro.build.product", $TARGET_DEVICE) + + writeString("# Do not try to parse description or thumbprint") + writeProp("ro.build.description", $PRIVATE_BUILD_DESC) + if [ -n "$BUILD_THUMBPRINT" ] { + writeProp("ro.build.thumbprint", $BUILD_THUMBPRINT) + } + */ + + writeString("# end build properties") + + cmd.Text("true) > ").Output(p.outputFilePath) + rule.Build("build.prop", "generating build.prop") + + if !p.installable() { + p.SkipInstall() + } + + p.installPath = PathForModuleInstall(ctx) + ctx.InstallFile(p.installPath, p.Name(), p.outputFilePath) +} + +func (f *buildinfoPropModule) GenerateSingletonBuildActions(ctx SingletonContext) { + // does nothing; buildinfo_prop is a singeton because two buildinfo modules don't make sense. +} + +func (p *buildinfoPropModule) AndroidMkEntries() []AndroidMkEntries { + return []AndroidMkEntries{AndroidMkEntries{ + Class: "ETC", + OutputFile: OptionalPathForPath(p.outputFilePath), + ExtraEntries: []AndroidMkExtraEntriesFunc{ + func(ctx AndroidMkExtraEntriesContext, entries *AndroidMkEntries) { + entries.SetString("LOCAL_MODULE_PATH", p.installPath.String()) + entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base()) + entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.installable()) + }, + }, + }} +} + +// buildinfo_prop module generates a build.prop file, which contains a set of common +// system/build.prop properties, such as ro.build.version.*. Not all properties are implemented; +// currently this module is only for microdroid. +func buildinfoPropFactory() SingletonModule { + module := &buildinfoPropModule{} + module.AddProperties(&module.properties) + InitAndroidModule(module) + return module +} diff --git a/android/config.go b/android/config.go index 9f1fd6a1b..250c312b7 100644 --- a/android/config.go +++ b/android/config.go @@ -777,6 +777,10 @@ func (c *config) PlatformBaseOS() string { return String(c.productVariables.Platform_base_os) } +func (c *config) PlatformVersionLastStable() string { + return String(c.productVariables.Platform_version_last_stable) +} + func (c *config) MinSupportedSdkVersion() ApiLevel { return uncheckedFinalApiLevel(19) } diff --git a/android/variable.go b/android/variable.go index 077b81097..373891ae4 100644 --- a/android/variable.go +++ b/android/variable.go @@ -199,6 +199,7 @@ type productVariables struct { Platform_preview_sdk_version *string `json:",omitempty"` Platform_min_supported_target_sdk_version *string `json:",omitempty"` Platform_base_os *string `json:",omitempty"` + Platform_version_last_stable *string `json:",omitempty"` DeviceName *string `json:",omitempty"` DeviceProduct *string `json:",omitempty"` From b3089e8a200e72567743f297bb8033a07d016901 Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Mon, 2 May 2022 23:52:44 +0800 Subject: [PATCH 117/148] Update clang version to clang-r450784d Test: presubmit Bug: 219872355 Change-Id: If6c2c331044a363cb8f20a2516da894e72c4b7e7 (cherry picked from commit 4f6c92765d76a7f4893f7d9de5f8cae5c1af5314) Merged-In: If6c2c331044a363cb8f20a2516da894e72c4b7e7 --- rust/bindgen.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/bindgen.go b/rust/bindgen.go index c2b05129a..b4626a048 100644 --- a/rust/bindgen.go +++ b/rust/bindgen.go @@ -30,7 +30,7 @@ var ( defaultBindgenFlags = []string{""} // bindgen should specify its own Clang revision so updating Clang isn't potentially blocked on bindgen failures. - bindgenClangVersion = "clang-r445002" + bindgenClangVersion = "clang-r450784d" _ = pctx.VariableFunc("bindgenClangVersion", func(ctx android.PackageVarContext) string { if override := ctx.Config().Getenv("LLVM_BINDGEN_PREBUILTS_VERSION"); override != "" { From 3953153c9e24e510237c14fd77ac58f5555c3738 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 3 May 2022 00:28:40 +0000 Subject: [PATCH 118/148] Prevent non-app/non-test modules from statically including jacocoagent Previously, the .impl library of java_sdk_library modules would end up with the jacocoagent statically included. That is because their Instrument flag was set to true when created by their parent. As that was before the deps were added that meant that they ended up with a static dependency on jacoagent (at least when UnbundledBuild() was true). That was not previously a problem because the .impl files were only used at build time. However, a recent change to make updatable-media statically include framework-media.impl (which statically included the jacocoagent classes) broke the coverage build because the jacocoagent classes are not in the permitted packages for the updatable-media. When instrumenting the bootclasspath the jacocoagent library is added to the art-bootclasspath-fragment. The jacocoagent should only be statically included in apps, or test apps. This change adds an extra flag to specify whether the module type supports statically including the jacocoagent. This is set to true by apps and test apps but not when the java_sdk_library creates the .impl java_library preventing it from statically including jacocoagent. Bug: 230967146 Bug: 229932396 Test: COVERAGE_MODULES=media \ PRODUCT=mainline_modules_x86 \ TARGET_BUILD_APPS=com.google.android.media \ vendor/google/build/build_unbundled_coverage_mainline_module.sh # Fails without this change, passes with it. Change-Id: Ic95cf11a05f59b67e623474ed3dd9be6b4442c42 --- java/app.go | 2 ++ java/base.go | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/java/app.go b/java/app.go index c53fc8183..e04f8e618 100755 --- a/java/app.go +++ b/java/app.go @@ -909,6 +909,7 @@ func AndroidAppFactory() android.Module { module.Module.dexProperties.Optimize.Shrink = proptools.BoolPtr(true) module.Module.properties.Instrument = true + module.Module.properties.Supports_static_instrumentation = true module.Module.properties.Installable = proptools.BoolPtr(true) module.addHostAndDeviceProperties() @@ -1028,6 +1029,7 @@ func AndroidTestFactory() android.Module { module.Module.dexProperties.Optimize.EnabledByDefault = true module.Module.properties.Instrument = true + module.Module.properties.Supports_static_instrumentation = true module.Module.properties.Installable = proptools.BoolPtr(true) module.appProperties.Use_embedded_native_libs = proptools.BoolPtr(true) module.appProperties.AlwaysPackageNativeLibs = true diff --git a/java/base.go b/java/base.go index a0767183d..7aa281495 100644 --- a/java/base.go +++ b/java/base.go @@ -170,6 +170,9 @@ type CommonProperties struct { } Instrument bool `blueprint:"mutated"` + // If true, then the module supports statically including the jacocoagent + // into the library. + Supports_static_instrumentation bool `blueprint:"mutated"` // List of files to include in the META-INF/services folder of the resulting jar. Services []string `android:"path,arch_variant"` @@ -605,7 +608,8 @@ func (j *Module) shouldInstrument(ctx android.BaseModuleContext) bool { } func (j *Module) shouldInstrumentStatic(ctx android.BaseModuleContext) bool { - return j.shouldInstrument(ctx) && + return j.properties.Supports_static_instrumentation && + j.shouldInstrument(ctx) && (ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_STATIC") || ctx.Config().UnbundledBuild()) } From dddb402c02837fefe670a1c4826f5b4190ba2ec9 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 2 May 2022 13:59:33 -0700 Subject: [PATCH 119/148] Add missing dependency on compose plugin in kapt rules The kapt rule uses kotlincFlags but was not using kotlincDeps, causing the rule to get the -Xplugin argument on the compose compiler plugin jar, but not have a dependency on it. Bug: 231222079 Test: TestKotlinCompose Change-Id: I4c2cf30fb7d8cad4eededa29f67f4ffd459caa41 (cherry picked from commit 08b0a1cd795a3a30d45ef8ff9f52f6b58fc45304) Merged-In: I4c2cf30fb7d8cad4eededa29f67f4ffd459caa41 --- java/kotlin.go | 1 + java/kotlin_test.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/java/kotlin.go b/java/kotlin.go index eff5bb53f..903c6249b 100644 --- a/java/kotlin.go +++ b/java/kotlin.go @@ -175,6 +175,7 @@ func kotlinKapt(ctx android.ModuleContext, srcJarOutputFile, resJarOutputFile an var deps android.Paths deps = append(deps, flags.kotlincClasspath...) + deps = append(deps, flags.kotlincDeps...) deps = append(deps, srcJars...) deps = append(deps, flags.processorPath...) deps = append(deps, commonSrcFiles...) diff --git a/java/kotlin_test.go b/java/kotlin_test.go index f9ff98229..435d78294 100644 --- a/java/kotlin_test.go +++ b/java/kotlin_test.go @@ -325,6 +325,7 @@ func TestKotlinCompose(t *testing.T) { java_library { name: "withcompose", srcs: ["a.kt"], + plugins: ["plugin"], static_libs: ["androidx.compose.runtime_runtime"], } @@ -332,6 +333,10 @@ func TestKotlinCompose(t *testing.T) { name: "nocompose", srcs: ["a.kt"], } + + java_plugin { + name: "plugin", + } `) buildOS := result.Config.BuildOS.String() @@ -346,6 +351,9 @@ func TestKotlinCompose(t *testing.T) { android.AssertStringDoesContain(t, "missing compose compiler plugin", withCompose.VariablesForTestsRelativeToTop()["kotlincFlags"], "-Xplugin="+composeCompiler.String()) + android.AssertStringListContains(t, "missing kapt compose compiler dependency", + withCompose.Rule("kapt").Implicits.Strings(), composeCompiler.String()) + android.AssertStringListDoesNotContain(t, "unexpected compose compiler dependency", noCompose.Rule("kotlinc").Implicits.Strings(), composeCompiler.String()) From 9f2bcac70762215a1d97b1f451835e1d3d8e9933 Mon Sep 17 00:00:00 2001 From: Artur Satayev Date: Wed, 4 May 2022 12:28:59 +0000 Subject: [PATCH 120/148] Add support to max-target-s to generate_hiddenapi_lists Test: make Bug: 169748350 Change-Id: I2662a643a190ed531d85755d01e1be9c49c02e25 Merged-In: I2662a643a190ed531d85755d01e1be9c49c02e25 --- scripts/hiddenapi/generate_hiddenapi_lists.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/hiddenapi/generate_hiddenapi_lists.py b/scripts/hiddenapi/generate_hiddenapi_lists.py index 35e0948f0..6546c7f80 100755 --- a/scripts/hiddenapi/generate_hiddenapi_lists.py +++ b/scripts/hiddenapi/generate_hiddenapi_lists.py @@ -27,6 +27,7 @@ FLAG_MAX_TARGET_O = 'max-target-o' FLAG_MAX_TARGET_P = 'max-target-p' FLAG_MAX_TARGET_Q = 'max-target-q' FLAG_MAX_TARGET_R = 'max-target-r' +FLAG_MAX_TARGET_S = 'max-target-s' FLAG_CORE_PLATFORM_API = 'core-platform-api' FLAG_PUBLIC_API = 'public-api' FLAG_SYSTEM_API = 'system-api' @@ -41,6 +42,7 @@ FLAGS_API_LIST = [ FLAG_MAX_TARGET_P, FLAG_MAX_TARGET_Q, FLAG_MAX_TARGET_R, + FLAG_MAX_TARGET_S, ] ALL_FLAGS = FLAGS_API_LIST + [ FLAG_CORE_PLATFORM_API, From 1611334fa29d3793214ecf53828fe294726db3de Mon Sep 17 00:00:00 2001 From: Yurii Zubrytskyi Date: Tue, 3 May 2022 01:40:32 -0700 Subject: [PATCH 121/148] build/soong - support the REL platform version in classpath Make sure we select the proper API level number for the REL platform version when generating the classpath protos Bug: 231272086 Test: build + boot emulator Change-Id: Ib3b711dc05dd6136a68e6de414d806687a849bc9 --- java/classpath_fragment.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go index ca2752877..259e977d8 100644 --- a/java/classpath_fragment.go +++ b/java/classpath_fragment.go @@ -131,14 +131,14 @@ func configuredJarListToClasspathJars(ctx android.ModuleContext, configuredJars // TODO(208456999): instead of mapping "current" to latest, min_sdk_version should never be set to "current" if s.minSdkVersion.Specified() { if s.minSdkVersion.ApiLevel.IsCurrent() { - jar.minSdkVersion = ctx.Config().LatestPreviewApiLevel().String() + jar.minSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String() } else { jar.minSdkVersion = s.minSdkVersion.ApiLevel.String() } } if s.maxSdkVersion.Specified() { if s.maxSdkVersion.ApiLevel.IsCurrent() { - jar.maxSdkVersion = ctx.Config().LatestPreviewApiLevel().String() + jar.maxSdkVersion = ctx.Config().DefaultAppTargetSdk(ctx).String() } else { jar.maxSdkVersion = s.maxSdkVersion.ApiLevel.String() } From 3cdd35199d5ddd2c58970fe7b43f562db6f13381 Mon Sep 17 00:00:00 2001 From: Yurii Zubrytskyi Date: Tue, 3 May 2022 08:48:39 +0000 Subject: [PATCH 122/148] Revert "Hacky workaround for half-finalized builds." This reverts commit 50493f07979fd25c57cc3ae3755c66c04b5aee4a. Reason for revert: build is now fully finalized Change-Id: Iaa5b9d84b84303a8b8baf30641d861a035169f48 --- java/droidstubs.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/java/droidstubs.go b/java/droidstubs.go index d444738a6..3b1f7c041 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -379,8 +379,7 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a cmd.FlagWithOutput("--generate-api-levels ", d.apiVersionsXml) cmd.FlagWithInput("--apply-api-levels ", d.apiVersionsXml) cmd.FlagWithArg("--current-version ", ctx.Config().PlatformSdkVersion().String()) - // STOPSHIP: RESTORE THIS LOGIC WHEN DECLARING "REL" BUILD - // cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) + cmd.FlagWithArg("--current-codename ", ctx.Config().PlatformSdkCodename()) filename := proptools.StringDefault(d.properties.Api_levels_jar_filename, "android.jar") From ee3290d33a2352c520b81fb28d6480529182a469 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Wed, 20 Apr 2022 21:45:00 -0700 Subject: [PATCH 123/148] Background distGzipFile to speed up CI builds These can take a minute or more of build time, and currently hold up other processing. We could move to a parallel compression scheme to speed them up, but it's simpler just to background them and continue the build, waiting to make sure they've finished before exiting. Testing this on git_master/flame-userdebug: This brings a local no-op `m nothing dist` build from 2m1s to 1m39s, even though most of that time is still spent waiting on these (since there is very little else happening in a `nothing` build when Soong and Kati don't need to run). Running `touch art/Android.mk; m nothing dist` (so the above, but with Kati) goes from 3m39s to 2m2s. We spent 9 seconds at the end waiting for these to finish. CI cases that almost always run Kati plus some number of other actions are likely to completely hide the time taken to dist these files. Bug: 229932999 Test: Check $DIST_DIR, files still exist Change-Id: I1fb78d7c4d5103d72b5d71d9277dea0d452f8968 (cherry picked from commit 80d72618217a5ba988a8d944e241eb147f184e0f) Merged-In: I1fb78d7c4d5103d72b5d71d9277dea0d452f8968 --- ui/build/build.go | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/ui/build/build.go b/ui/build/build.go index d261f8947..aadf4af4e 100644 --- a/ui/build/build.go +++ b/ui/build/build.go @@ -18,6 +18,7 @@ import ( "io/ioutil" "os" "path/filepath" + "sync" "text/template" "android/soong/ui/metrics" @@ -205,6 +206,8 @@ func Build(ctx Context, config Config) { return } + defer waitForDist(ctx) + // checkProblematicFiles aborts the build if Android.mk or CleanSpec.mk are found at the root of the tree. checkProblematicFiles(ctx) @@ -329,8 +332,18 @@ func Build(ctx Context, config Config) { } } +var distWaitGroup sync.WaitGroup + +// waitForDist waits for all backgrounded distGzipFile and distFile writes to finish +func waitForDist(ctx Context) { + ctx.BeginTrace("soong_ui", "dist") + defer ctx.EndTrace() + + distWaitGroup.Wait() +} + // distGzipFile writes a compressed copy of src to the distDir if dist is enabled. Failures -// are printed but non-fatal. +// are printed but non-fatal. Uses the distWaitGroup func for backgrounding (optimization). func distGzipFile(ctx Context, config Config, src string, subDirs ...string) { if !config.Dist() { return @@ -343,13 +356,17 @@ func distGzipFile(ctx Context, config Config, src string, subDirs ...string) { ctx.Printf("failed to mkdir %s: %s", destDir, err.Error()) } - if err := gzipFileToDir(src, destDir); err != nil { - ctx.Printf("failed to dist %s: %s", filepath.Base(src), err.Error()) - } + distWaitGroup.Add(1) + go func() { + defer distWaitGroup.Done() + if err := gzipFileToDir(src, destDir); err != nil { + ctx.Printf("failed to dist %s: %s", filepath.Base(src), err.Error()) + } + }() } // distFile writes a copy of src to the distDir if dist is enabled. Failures are printed but -// non-fatal. +// non-fatal. Uses the distWaitGroup func for backgrounding (optimization). func distFile(ctx Context, config Config, src string, subDirs ...string) { if !config.Dist() { return @@ -362,7 +379,11 @@ func distFile(ctx Context, config Config, src string, subDirs ...string) { ctx.Printf("failed to mkdir %s: %s", destDir, err.Error()) } - if _, err := copyFile(src, filepath.Join(destDir, filepath.Base(src))); err != nil { - ctx.Printf("failed to dist %s: %s", filepath.Base(src), err.Error()) - } + distWaitGroup.Add(1) + go func() { + defer distWaitGroup.Done() + if _, err := copyFile(src, filepath.Join(destDir, filepath.Base(src))); err != nil { + ctx.Printf("failed to dist %s: %s", filepath.Base(src), err.Error()) + } + }() } From 456a77e9a03ee248c4d3704e9d8d22478bb88552 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Sun, 8 May 2022 00:39:35 +0000 Subject: [PATCH 124/148] Update sdk_version check for jni_libs of updatable apps With aosp/1640364, all variants of a cc_* module use min_sdk_version as the version part of the clang triple. Therefore, checking min_sdk_version of jni_libs should be sufficient to ensure that there is no unintended access to symbols in newer Android versions Test: go test ./java Test: TH Bug: 155209650 Bug: 209409604 Change-Id: I6c064f8a6ea12c8aa40165a9063380306a180c9b Merged-In: I6c064f8a6ea12c8aa40165a9063380306a180c9b (cherry picked from commit 2e8c044b2cb88473b4f672991371dab18204a7c2) --- java/app.go | 10 +++------- java/app_test.go | 10 +++++++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/java/app.go b/java/app.go index e04f8e618..ce58cb4ee 100755 --- a/java/app.go +++ b/java/app.go @@ -305,10 +305,6 @@ func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) { // If an updatable APK sets min_sdk_version, min_sdk_vesion of JNI libs should match with it. // This check is enforced for "updatable" APKs (including APK-in-APEX). -// b/155209650: until min_sdk_version is properly supported, use sdk_version instead. -// because, sdk_version is overridden by min_sdk_version (if set as smaller) -// and sdkLinkType is checked with dependencies so we can be sure that the whole dependency tree -// will meet the requirements. func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVersion android.ApiLevel) { // It's enough to check direct JNI deps' sdk_version because all transitive deps from JNI deps are checked in cc.checkLinkType() ctx.VisitDirectDeps(func(m android.Module) { @@ -319,10 +315,10 @@ func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVer // The domain of cc.sdk_version is "current" and // We can rely on android.SdkSpec to convert it to so that "current" is // handled properly regardless of sdk finalization. - jniSdkVersion, err := android.SdkSpecFrom(ctx, dep.SdkVersion()).EffectiveVersion(ctx) + jniSdkVersion, err := android.SdkSpecFrom(ctx, dep.MinSdkVersion()).EffectiveVersion(ctx) if err != nil || minSdkVersion.LessThan(jniSdkVersion) { - ctx.OtherModuleErrorf(dep, "sdk_version(%v) is higher than min_sdk_version(%v) of the containing android_app(%v)", - dep.SdkVersion(), minSdkVersion, ctx.ModuleName()) + ctx.OtherModuleErrorf(dep, "min_sdk_version(%v) is higher than min_sdk_version(%v) of the containing android_app(%v)", + dep.MinSdkVersion(), minSdkVersion, ctx.ModuleName()) return } diff --git a/java/app_test.go b/java/app_test.go index 366142611..887d4ae87 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -427,7 +427,8 @@ func TestUpdatableApps_JniLibShouldBeBuiltAgainstMinSdkVersion(t *testing.T) { name: "libjni", stl: "none", system_shared_libs: [], - sdk_version: "29", + sdk_version: "current", + min_sdk_version: "29", } ` fs := map[string][]byte{ @@ -481,12 +482,13 @@ func TestUpdatableApps_ErrorIfJniLibDoesntSupportMinSdkVersion(t *testing.T) { name: "libjni", stl: "none", sdk_version: "current", + min_sdk_version: "current", } ` - testJavaError(t, `"libjni" .*: sdk_version\(current\) is higher than min_sdk_version\(29\)`, bp) + testJavaError(t, `"libjni" .*: min_sdk_version\(current\) is higher than min_sdk_version\(29\)`, bp) } -func TestUpdatableApps_ErrorIfDepSdkVersionIsHigher(t *testing.T) { +func TestUpdatableApps_ErrorIfDepMinSdkVersionIsHigher(t *testing.T) { bp := cc.GatherRequiredDepsForTest(android.Android) + ` android_app { name: "foo", @@ -503,6 +505,7 @@ func TestUpdatableApps_ErrorIfDepSdkVersionIsHigher(t *testing.T) { shared_libs: ["libbar"], system_shared_libs: [], sdk_version: "27", + min_sdk_version: "27", } cc_library { @@ -510,6 +513,7 @@ func TestUpdatableApps_ErrorIfDepSdkVersionIsHigher(t *testing.T) { stl: "none", system_shared_libs: [], sdk_version: "current", + min_sdk_version: "current", } ` testJavaError(t, `"libjni" .*: links "libbar" built against newer API version "current"`, bp) From 91250b1ae468f0e8d8e75201823616a317071328 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Fri, 6 May 2022 22:12:55 +0000 Subject: [PATCH 125/148] Enforce updatable=true on apps of updatable apexes - Update apex_info (a topdown mutator) so that it sets updatable=true on apps of updatable apexes - Write a unit test that tests different combinations of updatable/non-updatable apks-in-apexes - Update an existing unit test that asserts a different error Test: go test ./java Test: m nothing (in internal) Bug: 209409604 Change-Id: Ie8881b857afcec44addf27fc360c5b8abf726bd2 Merged-In: Ie8881b857afcec44addf27fc360c5b8abf726bd2 (cherry picked from commit 42e89508eeb7d24bac5eb71b48aa89fbf5ed8aee) --- apex/apex.go | 19 +++++++++++++- apex/apex_test.go | 64 +++++++++++++++++++++++++++++++++++++++++++++++ java/app.go | 4 +++ 3 files changed, 86 insertions(+), 1 deletion(-) diff --git a/apex/apex.go b/apex/apex.go index 92cf53aa2..9d12ffa41 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -994,6 +994,7 @@ type ApexInfoMutator interface { // apexInfoMutator delegates the work of identifying which modules need an ApexInfo and apex // specific variant to modules that support the ApexInfoMutator. +// It also propagates updatable=true to apps of updatable apexes func apexInfoMutator(mctx android.TopDownMutatorContext) { if !mctx.Module().Enabled() { return @@ -1001,8 +1002,8 @@ func apexInfoMutator(mctx android.TopDownMutatorContext) { if a, ok := mctx.Module().(ApexInfoMutator); ok { a.ApexInfoMutator(mctx) - return } + enforceAppUpdatability(mctx) } // apexStrictUpdatibilityLintMutator propagates strict_updatability_linting to transitive deps of a mainline module @@ -1033,6 +1034,22 @@ func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) { } } +// enforceAppUpdatability propagates updatable=true to apps of updatable apexes +func enforceAppUpdatability(mctx android.TopDownMutatorContext) { + if !mctx.Module().Enabled() { + return + } + if apex, ok := mctx.Module().(*apexBundle); ok && apex.Updatable() { + // checking direct deps is sufficient since apex->apk is a direct edge, even when inherited via apex_defaults + mctx.VisitDirectDeps(func(module android.Module) { + // ignore android_test_app + if app, ok := module.(*java.AndroidApp); ok { + app.SetUpdatable(true) + } + }) + } +} + // TODO: b/215736885 Whittle the denylist // Transitive deps of certain mainline modules baseline NewApi errors // Skip these mainline modules for now diff --git a/apex/apex_test.go b/apex/apex_test.go index 4a52115db..5ffd99c8c 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -2393,6 +2393,7 @@ func TestApexMinSdkVersion_ErrorIfDepIsNewer_Java(t *testing.T) { key: "myapex.key", apps: ["AppFoo"], min_sdk_version: "29", + updatable: false, } apex_key { @@ -9324,6 +9325,69 @@ func TestApexStrictUpdtabilityLintBcpFragmentDeps(t *testing.T) { } } +// updatable apexes should propagate updatable=true to its apps +func TestUpdatableApexEnforcesAppUpdatability(t *testing.T) { + bp := ` + apex { + name: "myapex", + key: "myapex.key", + updatable: %v, + apps: [ + "myapp", + ], + min_sdk_version: "30", + } + apex_key { + name: "myapex.key", + } + android_app { + name: "myapp", + updatable: %v, + apex_available: [ + "myapex", + ], + sdk_version: "current", + min_sdk_version: "30", + } + ` + testCases := []struct { + name string + apex_is_updatable_bp bool + app_is_updatable_bp bool + app_is_updatable_expected bool + }{ + { + name: "Non-updatable apex respects updatable property of non-updatable app", + apex_is_updatable_bp: false, + app_is_updatable_bp: false, + app_is_updatable_expected: false, + }, + { + name: "Non-updatable apex respects updatable property of updatable app", + apex_is_updatable_bp: false, + app_is_updatable_bp: true, + app_is_updatable_expected: true, + }, + { + name: "Updatable apex respects updatable property of updatable app", + apex_is_updatable_bp: true, + app_is_updatable_bp: true, + app_is_updatable_expected: true, + }, + { + name: "Updatable apex sets updatable=true on non-updatable app", + apex_is_updatable_bp: true, + app_is_updatable_bp: false, + app_is_updatable_expected: true, + }, + } + for _, testCase := range testCases { + result := testApex(t, fmt.Sprintf(bp, testCase.apex_is_updatable_bp, testCase.app_is_updatable_bp)) + myapp := result.ModuleForTests("myapp", "android_common").Module().(*java.AndroidApp) + android.AssertBoolEquals(t, testCase.name, testCase.app_is_updatable_expected, myapp.Updatable()) + } +} + func TestMain(m *testing.M) { os.Exit(m.Run()) } diff --git a/java/app.go b/java/app.go index ce58cb4ee..c31f9fe22 100755 --- a/java/app.go +++ b/java/app.go @@ -847,6 +847,10 @@ func (a *AndroidApp) Updatable() bool { return Bool(a.appProperties.Updatable) } +func (a *AndroidApp) SetUpdatable(val bool) { + a.appProperties.Updatable = &val +} + func (a *AndroidApp) getCertString(ctx android.BaseModuleContext) string { certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(ctx.ModuleName()) if overridden { From 5088544ddccc2d755debb5b7930bf6de91d75ec6 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 16 May 2022 16:19:54 -0700 Subject: [PATCH 126/148] Fix prebuilts of overridden apps AndroidApp had its own HideFromMake method and flag that shadowed the one in ModuleBase. This caused performOverrideMutator to set the AndroidApp flag, but ModuleBase.skipInstall to read the ModuleBase flag, resulting in a conflicting install rule being created. Remove AndroidApp's HideFromMake in favor of the ModuleBase one. Bug: 232788722 Test: TestOverrideAndroidAppWithPrebuilt Change-Id: I8c0dfcb50ff4dc1e4d0574f150b10d79908f46aa Merged-In: I8c0dfcb50ff4dc1e4d0574f150b10d79908f46aa (cherry picked from commit aaa0c1ffcde21693d1d033d2e32ba638c211f695) --- java/androidmk.go | 2 +- java/app.go | 5 ----- java/app_test.go | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/java/androidmk.go b/java/androidmk.go index f51e072bd..7322637a7 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -314,7 +314,7 @@ func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries { } func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries { - if app.hideApexVariantFromMake || app.appProperties.HideFromMake { + if app.hideApexVariantFromMake || app.IsHideFromMake() { return []android.AndroidMkEntries{android.AndroidMkEntries{ Disabled: true, }} diff --git a/java/app.go b/java/app.go index e04f8e618..e64533151 100755 --- a/java/app.go +++ b/java/app.go @@ -99,7 +99,6 @@ type appProperties struct { // cc.Coverage related properties PreventInstall bool `blueprint:"mutated"` - HideFromMake bool `blueprint:"mutated"` IsCoverageVariant bool `blueprint:"mutated"` // Whether this app is considered mainline updatable or not. When set to true, this will enforce @@ -889,10 +888,6 @@ func (a *AndroidApp) SetPreventInstall() { a.appProperties.PreventInstall = true } -func (a *AndroidApp) HideFromMake() { - a.appProperties.HideFromMake = true -} - func (a *AndroidApp) MarkAsCoverageVariant(coverage bool) { a.appProperties.IsCoverageVariant = coverage } diff --git a/java/app_test.go b/java/app_test.go index 366142611..c811a8e32 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -2041,6 +2041,41 @@ func TestOverrideAndroidAppOverrides(t *testing.T) { } } +func TestOverrideAndroidAppWithPrebuilt(t *testing.T) { + result := PrepareForTestWithJavaDefaultModules.RunTestWithBp( + t, ` + android_app { + name: "foo", + srcs: ["a.java"], + sdk_version: "current", + } + + override_android_app { + name: "bar", + base: "foo", + } + + android_app_import { + name: "bar", + prefer: true, + apk: "bar.apk", + presigned: true, + } + `) + + // An app that has an override that also has a prebuilt should not be hidden. + foo := result.ModuleForTests("foo", "android_common") + if foo.Module().IsHideFromMake() { + t.Errorf("expected foo to have HideFromMake false") + } + + // An override that also has a prebuilt should be hidden. + barOverride := result.ModuleForTests("foo", "android_common_bar") + if !barOverride.Module().IsHideFromMake() { + t.Errorf("expected bar override variant of foo to have HideFromMake true") + } +} + func TestOverrideAndroidAppStem(t *testing.T) { ctx, _ := testJava(t, ` android_app { From 4f992b663fdb0f422a772ba2df9ef8ca9b6a7d6e Mon Sep 17 00:00:00 2001 From: Hsin-Yi Chen Date: Thu, 19 May 2022 15:17:54 +0800 Subject: [PATCH 127/148] Add diff_flags as a header_abi_checker property The property allows developers to add extra flags to header-abi-diff for specific libraries. Bug: 232891473 Test: m libbinder.vendor Change-Id: I203af73c784dfc7738bb64f57b224c08d5c595ce --- cc/builder.go | 7 +++++-- cc/library.go | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cc/builder.go b/cc/builder.go index ff4e9b447..ea06839a9 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -942,9 +942,10 @@ func unzipRefDump(ctx android.ModuleContext, zippedRefDump android.Path, baseNam return outputFile } -// sourceAbiDiff registers a build statement to compare linked sAbi dump files (.ldump). +// sourceAbiDiff registers a build statement to compare linked sAbi dump files (.lsdump). func sourceAbiDiff(ctx android.ModuleContext, inputDump android.Path, referenceDump android.Path, - baseName, exportedHeaderFlags string, checkAllApis, isLlndk, isNdk, isVndkExt bool) android.OptionalPath { + baseName, exportedHeaderFlags string, diffFlags []string, + checkAllApis, isLlndk, isNdk, isVndkExt bool) android.OptionalPath { outputFile := android.PathForModuleOut(ctx, baseName+".abidiff") libName := strings.TrimSuffix(baseName, filepath.Ext(baseName)) @@ -975,6 +976,8 @@ func sourceAbiDiff(ctx android.ModuleContext, inputDump android.Path, referenceD if isVndkExt { extraFlags = append(extraFlags, "-allow-extensions") } + // TODO(b/232891473): Simplify the above logic with diffFlags. + extraFlags = append(extraFlags, diffFlags...) ctx.Build(pctx, android.BuildParams{ Rule: sAbiDiff, diff --git a/cc/library.go b/cc/library.go index 0abcb6f39..b1c18f4d0 100644 --- a/cc/library.go +++ b/cc/library.go @@ -110,6 +110,9 @@ type LibraryProperties struct { // Run checks on all APIs (in addition to the ones referred by // one of exported ELF symbols.) Check_all_apis *bool + + // Extra flags passed to header-abi-diff + Diff_flags []string } // Inject boringssl hash into the shared library. This is only intended for use by external/boringssl. @@ -1638,6 +1641,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec if refAbiDumpFile != nil { library.sAbiDiff = sourceAbiDiff(ctx, library.sAbiOutputFile.Path(), refAbiDumpFile, fileName, exportedHeaderFlags, + library.Properties.Header_abi_checker.Diff_flags, Bool(library.Properties.Header_abi_checker.Check_all_apis), ctx.IsLlndk(), ctx.isNdk(ctx.Config()), ctx.IsVndkExt()) } From 8500198442494a6abee3a248c0238f69308b00f0 Mon Sep 17 00:00:00 2001 From: Yi-Yo Chiang Date: Thu, 19 May 2022 16:19:36 +0800 Subject: [PATCH 128/148] Add android.hardware.gnss-V2-ndk to VndkMustUseVendorVariantList Bug: 229319958 Test: Build android.hardware.gnss-V2-ndk.vendor without triggering "Checking VNDK vendor variant" error. Change-Id: Ic03a04b97db601ff46510e00b2986a30f60066e6 --- cc/config/vndk.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cc/config/vndk.go b/cc/config/vndk.go index f2e1a90b9..db69ce785 100644 --- a/cc/config/vndk.go +++ b/cc/config/vndk.go @@ -30,6 +30,7 @@ var VndkMustUseVendorVariantList = []string{ "android.hardware.dumpstate-V1-ndk", "android.hardware.gnss-V1-ndk", "android.hardware.gnss-V1-ndk_platform", + "android.hardware.gnss-V2-ndk", "android.hardware.gnss-ndk_platform", "android.hardware.gnss-unstable-ndk_platform", "android.hardware.health-V1-ndk", From dbd8eb11f421a3d852d0b593874e77b9c9ce12da Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Thu, 21 Apr 2022 11:13:45 -0400 Subject: [PATCH 129/148] Remove unused uses_sdks property for apexes (cherry picked from commit 7eed538208b6b158daa39504122545450db6c2e3) Bug: 232546567 Test: m nothing & compare build.ninja before/after Merged-In: I3f1199af338e1d2e48ec29cf9f59b6b36236c4cc Change-Id: I3f1199af338e1d2e48ec29cf9f59b6b36236c4cc --- android/apex.go | 6 --- android/apex_test.go | 65 ++++++++++-------------- android/sdk.go | 30 ----------- apex/apex.go | 20 -------- sdk/cc_sdk_test.go | 115 ------------------------------------------- sdk/java_sdk_test.go | 84 ------------------------------- sdk/sdk.go | 114 ------------------------------------------ sdk/sdk_test.go | 58 ---------------------- 8 files changed, 25 insertions(+), 467 deletions(-) diff --git a/android/apex.go b/android/apex.go index b127f7410..63cdaaf5e 100644 --- a/android/apex.go +++ b/android/apex.go @@ -58,9 +58,6 @@ type ApexInfo struct { // to true. UsePlatformApis bool - // The list of SDK modules that the containing apexBundle depends on. - RequiredSdks SdkRefs - // List of Apex variant names that this module is associated with. This initially is the // same as the `ApexVariationName` field. Then when multiple apex variants are merged in // mergeApexVariations, ApexInfo struct of the merged variant holds the list of apexBundles @@ -110,9 +107,6 @@ func (i ApexInfo) AddJSONData(d *map[string]interface{}) { // thus wouldn't be merged. func (i ApexInfo) mergedName(ctx PathContext) string { name := "apex" + strconv.Itoa(i.MinSdkVersion.FinalOrFutureInt()) - for _, sdk := range i.RequiredSdks { - name += "_" + sdk.Name + "_" + sdk.Version - } return name } diff --git a/android/apex_test.go b/android/apex_test.go index 1e2f3bde4..0bf4c9c36 100644 --- a/android/apex_test.go +++ b/android/apex_test.go @@ -33,10 +33,10 @@ func Test_mergeApexVariations(t *testing.T) { { name: "single", in: []ApexInfo{ - {"foo", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"foo", FutureApiLevel, false, false, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, }, wantMerged: []ApexInfo{ - {"apex10000", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"apex10000", FutureApiLevel, false, false, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, }, wantAliases: [][2]string{ {"foo", "apex10000"}, @@ -45,25 +45,25 @@ func Test_mergeApexVariations(t *testing.T) { { name: "merge", in: []ApexInfo{ - {"foo", FutureApiLevel, false, false, SdkRefs{{"baz", "1"}}, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, - {"bar", FutureApiLevel, false, false, SdkRefs{{"baz", "1"}}, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"foo", FutureApiLevel, false, false, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"bar", FutureApiLevel, false, false, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, }, wantMerged: []ApexInfo{ - {"apex10000_baz_1", FutureApiLevel, false, false, SdkRefs{{"baz", "1"}}, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, false}}, + {"apex10000", FutureApiLevel, false, false, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, false}}, wantAliases: [][2]string{ - {"bar", "apex10000_baz_1"}, - {"foo", "apex10000_baz_1"}, + {"bar", "apex10000"}, + {"foo", "apex10000"}, }, }, { name: "don't merge version", in: []ApexInfo{ - {"foo", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, - {"bar", uncheckedFinalApiLevel(30), false, false, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"foo", FutureApiLevel, false, false, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"bar", uncheckedFinalApiLevel(30), false, false, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, }, wantMerged: []ApexInfo{ - {"apex30", uncheckedFinalApiLevel(30), false, false, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, - {"apex10000", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"apex30", uncheckedFinalApiLevel(30), false, false, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"apex10000", FutureApiLevel, false, false, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, }, wantAliases: [][2]string{ {"bar", "apex30"}, @@ -73,44 +73,29 @@ func Test_mergeApexVariations(t *testing.T) { { name: "merge updatable", in: []ApexInfo{ - {"foo", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, - {"bar", FutureApiLevel, true, false, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"foo", FutureApiLevel, false, false, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"bar", FutureApiLevel, true, false, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, }, wantMerged: []ApexInfo{ - {"apex10000", FutureApiLevel, true, false, nil, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, NotForPrebuiltApex}, + {"apex10000", FutureApiLevel, true, false, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, NotForPrebuiltApex}, }, wantAliases: [][2]string{ {"bar", "apex10000"}, {"foo", "apex10000"}, }, }, - { - name: "don't merge sdks", - in: []ApexInfo{ - {"foo", FutureApiLevel, false, false, SdkRefs{{"baz", "1"}}, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, - {"bar", FutureApiLevel, false, false, SdkRefs{{"baz", "2"}}, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, - }, - wantMerged: []ApexInfo{ - {"apex10000_baz_2", FutureApiLevel, false, false, SdkRefs{{"baz", "2"}}, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, - {"apex10000_baz_1", FutureApiLevel, false, false, SdkRefs{{"baz", "1"}}, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, - }, - wantAliases: [][2]string{ - {"bar", "apex10000_baz_2"}, - {"foo", "apex10000_baz_1"}, - }, - }, { name: "don't merge when for prebuilt_apex", in: []ApexInfo{ - {"foo", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, - {"bar", FutureApiLevel, true, false, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"foo", FutureApiLevel, false, false, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"bar", FutureApiLevel, true, false, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, // This one should not be merged in with the others because it is for // a prebuilt_apex. - {"baz", FutureApiLevel, true, false, nil, []string{"baz"}, []string{"baz"}, nil, ForPrebuiltApex}, + {"baz", FutureApiLevel, true, false, []string{"baz"}, []string{"baz"}, nil, ForPrebuiltApex}, }, wantMerged: []ApexInfo{ - {"apex10000", FutureApiLevel, true, false, nil, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, NotForPrebuiltApex}, - {"baz", FutureApiLevel, true, false, nil, []string{"baz"}, []string{"baz"}, nil, ForPrebuiltApex}, + {"apex10000", FutureApiLevel, true, false, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, NotForPrebuiltApex}, + {"baz", FutureApiLevel, true, false, []string{"baz"}, []string{"baz"}, nil, ForPrebuiltApex}, }, wantAliases: [][2]string{ {"bar", "apex10000"}, @@ -120,11 +105,11 @@ func Test_mergeApexVariations(t *testing.T) { { name: "merge different UsePlatformApis but don't allow using platform api", in: []ApexInfo{ - {"foo", FutureApiLevel, false, false, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, - {"bar", FutureApiLevel, false, true, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"foo", FutureApiLevel, false, false, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"bar", FutureApiLevel, false, true, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, }, wantMerged: []ApexInfo{ - {"apex10000", FutureApiLevel, false, false, nil, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, NotForPrebuiltApex}, + {"apex10000", FutureApiLevel, false, false, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, NotForPrebuiltApex}, }, wantAliases: [][2]string{ {"bar", "apex10000"}, @@ -134,11 +119,11 @@ func Test_mergeApexVariations(t *testing.T) { { name: "merge same UsePlatformApis and allow using platform api", in: []ApexInfo{ - {"foo", FutureApiLevel, false, true, nil, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, - {"bar", FutureApiLevel, false, true, nil, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, + {"foo", FutureApiLevel, false, true, []string{"foo"}, []string{"foo"}, nil, NotForPrebuiltApex}, + {"bar", FutureApiLevel, false, true, []string{"bar"}, []string{"bar"}, nil, NotForPrebuiltApex}, }, wantMerged: []ApexInfo{ - {"apex10000", FutureApiLevel, false, true, nil, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, NotForPrebuiltApex}, + {"apex10000", FutureApiLevel, false, true, []string{"bar", "foo"}, []string{"bar", "foo"}, nil, NotForPrebuiltApex}, }, wantAliases: [][2]string{ {"bar", "apex10000"}, diff --git a/android/sdk.go b/android/sdk.go index 1d63d7a94..3a5624030 100644 --- a/android/sdk.go +++ b/android/sdk.go @@ -23,24 +23,8 @@ import ( "github.com/google/blueprint/proptools" ) -// RequiredSdks provides access to the set of SDKs required by an APEX and its contents. -// -// Extracted from SdkAware to make it easier to define custom subsets of the -// SdkAware interface and improve code navigation within the IDE. -// -// In addition to its use in SdkAware this interface must also be implemented by -// APEX to specify the SDKs required by that module and its contents. e.g. APEX -// is expected to implement RequiredSdks() by reading its own properties like -// `uses_sdks`. -type RequiredSdks interface { - // RequiredSdks returns the set of SDKs required by an APEX and its contents. - RequiredSdks() SdkRefs -} - // sdkAwareWithoutModule is provided simply to improve code navigation with the IDE. type sdkAwareWithoutModule interface { - RequiredSdks - // SdkMemberComponentName will return the name to use for a component of this module based on the // base name of this module. // @@ -81,7 +65,6 @@ type sdkAwareWithoutModule interface { ContainingSdk() SdkRef MemberName() string - BuildWithSdks(sdks SdkRefs) } // SdkAware is the interface that must be supported by any module to become a member of SDK or to be @@ -150,9 +133,6 @@ type sdkProperties struct { // The SDK that this module is a member of. nil if it is not a member of any SDK ContainingSdk *SdkRef `blueprint:"mutated"` - // The list of SDK names and versions that are used to build this module - RequiredSdks SdkRefs `blueprint:"mutated"` - // Name of the module that this sdk member is representing Sdk_member_name *string } @@ -208,16 +188,6 @@ func (s *SdkBase) MemberName() string { return proptools.String(s.properties.Sdk_member_name) } -// BuildWithSdks is used to mark that this module has to be built with the given SDK(s). -func (s *SdkBase) BuildWithSdks(sdks SdkRefs) { - s.properties.RequiredSdks = sdks -} - -// RequiredSdks returns the SDK(s) that this module has to be built with -func (s *SdkBase) RequiredSdks() SdkRefs { - return s.properties.RequiredSdks -} - // InitSdkAwareModule initializes the SdkBase struct. This must be called by all modules including // SdkBase. func InitSdkAwareModule(m SdkAware) { diff --git a/apex/apex.go b/apex/apex.go index 9d12ffa41..b54f1e95f 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -158,12 +158,6 @@ type apexBundleProperties struct { // or else conflicting build rules may be created. Multi_install_skip_symbol_files *bool - // List of SDKs that are used to build this APEX. A reference to an SDK should be either - // `name#version` or `name` which is an alias for `name#current`. If left empty, - // `platform#current` is implied. This value affects all modules included in this APEX. In - // other words, they are also built with the SDKs specified here. - Uses_sdks []string - // The type of APEX to build. Controls what the APEX payload is. Either 'image', 'zip' or // 'both'. When set to image, contents are stored in a filesystem image inside a zip // container. When set to zip, contents are stored in a zip container directly. This type is @@ -789,19 +783,6 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { commonVariation := ctx.Config().AndroidCommonTarget.Variations() ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...) ctx.AddFarVariationDependencies(commonVariation, compatConfigTag, a.properties.Compat_configs...) - - // Marks that this APEX (in fact all the modules in it) has to be built with the given SDKs. - // This field currently isn't used. - // TODO(jiyong): consider dropping this feature - // TODO(jiyong): ensure that all apexes are with non-empty uses_sdks - if len(a.properties.Uses_sdks) > 0 { - sdkRefs := []android.SdkRef{} - for _, str := range a.properties.Uses_sdks { - parsed := android.ParseSdkRef(ctx, str, "uses_sdks") - sdkRefs = append(sdkRefs, parsed) - } - a.BuildWithSdks(sdkRefs) - } } // DepsMutator for the overridden properties. @@ -966,7 +947,6 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) { apexInfo := android.ApexInfo{ ApexVariationName: apexVariationName, MinSdkVersion: minSdkVersion, - RequiredSdks: a.RequiredSdks(), Updatable: a.Updatable(), UsePlatformApis: a.UsePlatformApis(), InApexVariants: []string{apexVariationName}, diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go index cd63dac8c..571d21420 100644 --- a/sdk/cc_sdk_test.go +++ b/sdk/cc_sdk_test.go @@ -193,114 +193,6 @@ sdk_snapshot { `)) } -func TestBasicSdkWithCc(t *testing.T) { - result := testSdkWithCc(t, ` - sdk { - name: "mysdk", - native_shared_libs: ["sdkmember"], - } - - cc_library_shared { - name: "sdkmember", - system_shared_libs: [], - stl: "none", - apex_available: ["mysdkapex"], - } - - sdk_snapshot { - name: "mysdk@1", - native_shared_libs: ["sdkmember_mysdk@1"], - } - - sdk_snapshot { - name: "mysdk@2", - native_shared_libs: ["sdkmember_mysdk@2"], - } - - cc_prebuilt_library_shared { - name: "sdkmember", - srcs: ["libfoo.so"], - prefer: false, - system_shared_libs: [], - stl: "none", - } - - cc_prebuilt_library_shared { - name: "sdkmember_mysdk@1", - sdk_member_name: "sdkmember", - srcs: ["libfoo.so"], - system_shared_libs: [], - stl: "none", - // TODO: remove //apex_available:platform - apex_available: [ - "//apex_available:platform", - "myapex", - ], - } - - cc_prebuilt_library_shared { - name: "sdkmember_mysdk@2", - sdk_member_name: "sdkmember", - srcs: ["libfoo.so"], - system_shared_libs: [], - stl: "none", - // TODO: remove //apex_available:platform - apex_available: [ - "//apex_available:platform", - "myapex2", - ], - } - - cc_library_shared { - name: "mycpplib", - srcs: ["Test.cpp"], - shared_libs: ["sdkmember"], - system_shared_libs: [], - stl: "none", - apex_available: [ - "myapex", - "myapex2", - ], - } - - apex { - name: "myapex", - native_shared_libs: ["mycpplib"], - uses_sdks: ["mysdk@1"], - key: "myapex.key", - certificate: ":myapex.cert", - updatable: false, - } - - apex { - name: "myapex2", - native_shared_libs: ["mycpplib"], - uses_sdks: ["mysdk@2"], - key: "myapex.key", - certificate: ":myapex.cert", - updatable: false, - } - - apex { - name: "mysdkapex", - native_shared_libs: ["sdkmember"], - key: "myapex.key", - certificate: ":myapex.cert", - updatable: false, - } - `) - - sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk@1", "android_arm64_armv8-a_shared_apex10000_mysdk_1").Rule("toc").Output - sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk@2", "android_arm64_armv8-a_shared_apex10000_mysdk_2").Rule("toc").Output - - cpplibForMyApex := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_1") - cpplibForMyApex2 := result.ModuleForTests("mycpplib", "android_arm64_armv8-a_shared_apex10000_mysdk_2") - - // Depending on the uses_sdks value, different libs are linked - ensureListContains(t, pathsToStrings(cpplibForMyApex.Rule("ld").Implicits), sdkMemberV1.String()) - ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String()) -} - // Make sure the sdk can use host specific cc libraries static/shared and both. func TestHostSdkWithCc(t *testing.T) { testSdkWithCc(t, ` @@ -2835,11 +2727,6 @@ func TestNoSanitizerMembers(t *testing.T) { } `) - // Mixing the snapshot with the source (irrespective of which one is preferred) causes a problem - // due to missing variants. - // TODO(b/183204176): Remove this and fix the cause. - snapshotWithSourceErrorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(`\QReplaceDependencies could not find identical variant {os:android,image:,arch:arm64_armv8-a,sdk:,link:shared,version:} for module mynativelib\E`) - CheckSnapshot(t, result, "mysdk", "", checkUnversionedAndroidBpContents(` // This is auto-generated. DO NOT EDIT. @@ -2866,7 +2753,5 @@ myinclude/Test.h -> include/myinclude/Test.h arm64/include/Arm64Test.h -> arm64/include/arm64/include/Arm64Test.h .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so `), - snapshotTestErrorHandler(checkSnapshotWithSourcePreferred, snapshotWithSourceErrorHandler), - snapshotTestErrorHandler(checkSnapshotPreferredWithSource, snapshotWithSourceErrorHandler), ) } diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go index f0d3b35d7..a99fa1ff0 100644 --- a/sdk/java_sdk_test.go +++ b/sdk/java_sdk_test.go @@ -71,90 +71,6 @@ func TestSdkDependsOnSourceEvenWhenPrebuiltPreferred(t *testing.T) { ) } -func TestBasicSdkWithJavaLibrary(t *testing.T) { - result := android.GroupFixturePreparers( - prepareForSdkTestWithJava, - prepareForSdkTestWithApex, - ).RunTestWithBp(t, ` - sdk { - name: "mysdk", - java_header_libs: ["sdkmember"], - } - - sdk_snapshot { - name: "mysdk@1", - java_header_libs: ["sdkmember_mysdk@1"], - } - - sdk_snapshot { - name: "mysdk@2", - java_header_libs: ["sdkmember_mysdk@2"], - } - - java_library { - name: "sdkmember", - srcs: ["Test.java"], - system_modules: "none", - sdk_version: "none", - host_supported: true, - } - - java_import { - name: "sdkmember_mysdk@1", - sdk_member_name: "sdkmember", - host_supported: true, - } - - java_import { - name: "sdkmember_mysdk@2", - sdk_member_name: "sdkmember", - host_supported: true, - } - - java_library { - name: "myjavalib", - srcs: ["Test.java"], - libs: ["sdkmember"], - system_modules: "none", - sdk_version: "none", - compile_dex: true, - host_supported: true, - apex_available: [ - "myapex", - "myapex2", - ], - } - - apex { - name: "myapex", - java_libs: ["myjavalib"], - uses_sdks: ["mysdk@1"], - key: "myapex.key", - certificate: ":myapex.cert", - updatable: false, - } - - apex { - name: "myapex2", - java_libs: ["myjavalib"], - uses_sdks: ["mysdk@2"], - key: "myapex.key", - certificate: ":myapex.cert", - updatable: false, - } - `) - - sdkMemberV1 := result.ModuleForTests("sdkmember_mysdk@1", "android_common").Rule("combineJar").Output - sdkMemberV2 := result.ModuleForTests("sdkmember_mysdk@2", "android_common").Rule("combineJar").Output - - javalibForMyApex := result.ModuleForTests("myjavalib", "android_common_apex10000_mysdk_1") - javalibForMyApex2 := result.ModuleForTests("myjavalib", "android_common_apex10000_mysdk_2") - - // Depending on the uses_sdks value, different libs are linked - ensureListContains(t, pathsToStrings(javalibForMyApex.Rule("javac").Implicits), sdkMemberV1.String()) - ensureListContains(t, pathsToStrings(javalibForMyApex2.Rule("javac").Implicits), sdkMemberV2.String()) -} - func TestSnapshotWithJavaHeaderLibrary(t *testing.T) { result := android.GroupFixturePreparers( prepareForSdkTestWithJava, diff --git a/sdk/sdk.go b/sdk/sdk.go index 84c9a96e4..c8c7b79df 100644 --- a/sdk/sdk.go +++ b/sdk/sdk.go @@ -39,7 +39,6 @@ func registerSdkBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("sdk", SdkModuleFactory) ctx.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory) ctx.PreDepsMutators(RegisterPreDepsMutators) - ctx.PostDepsMutators(RegisterPostDepsMutators) } type sdk struct { @@ -278,20 +277,6 @@ func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) { ctx.BottomUp("SdkMemberInterVersion", memberInterVersionMutator).Parallel() } -// RegisterPostDepsMutators registers post-deps mutators to support modules implementing SdkAware -// interface and the sdk module type. This function has been made public to be called by tests -// outside of the sdk package -func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) { - // These must run AFTER apexMutator. Note that the apex package is imported even though there is - // no direct dependency to the package here. sdkDepsMutator sets the SDK requirements from an - // APEX to its dependents. Since different versions of the same SDK can be used by different - // APEXes, the apex and its dependents (which includes the dependencies to the sdk members) - // should have been mutated for the apex before the SDK requirements are set. - ctx.TopDown("SdkDepsMutator", sdkDepsMutator).Parallel() - ctx.BottomUp("SdkDepsReplaceMutator", sdkDepsReplaceMutator).Parallel() - ctx.TopDown("SdkRequirementCheck", sdkRequirementsMutator).Parallel() -} - type dependencyTag struct { blueprint.BaseDependencyTag } @@ -413,103 +398,4 @@ func memberInterVersionMutator(mctx android.BottomUpMutatorContext) { type sdkAndApexModule interface { android.Module android.DepIsInSameApex - android.RequiredSdks -} - -// Step 4: transitively ripple down the SDK requirements from the root modules like APEX to its -// descendants -func sdkDepsMutator(mctx android.TopDownMutatorContext) { - if parent, ok := mctx.Module().(sdkAndApexModule); ok { - // Module types for Mainline modules (e.g. APEX) are expected to implement RequiredSdks() - // by reading its own properties like `uses_sdks`. - requiredSdks := parent.RequiredSdks() - if len(requiredSdks) > 0 { - mctx.VisitDirectDeps(func(m android.Module) { - // Only propagate required sdks from the apex onto its contents. - if dep, ok := m.(android.SdkAware); ok && android.IsDepInSameApex(mctx, parent, dep) { - dep.BuildWithSdks(requiredSdks) - } - }) - } - } -} - -// Step 5: if libfoo.mysdk.11 is in the context where version 11 of mysdk is requested, the -// versioned module is used instead of the un-versioned (in-development) module libfoo -func sdkDepsReplaceMutator(mctx android.BottomUpMutatorContext) { - if versionedSdkMember, ok := mctx.Module().(android.SdkAware); ok && versionedSdkMember.IsInAnySdk() && versionedSdkMember.IsVersioned() { - if sdk := versionedSdkMember.ContainingSdk(); !sdk.Unversioned() { - // Only replace dependencies to with - // if the depending module requires it. e.g. - // foo -> sdkmember - // will be transformed to: - // foo -> sdkmember@1 - // if and only if foo is a member of an APEX that requires version 1 of the - // sdk containing sdkmember. - memberName := versionedSdkMember.MemberName() - - // Convert a panic into a normal error to allow it to be more easily tested for. This is a - // temporary workaround, once http://b/183204176 has been fixed this can be removed. - // TODO(b/183204176): Remove this after fixing. - defer func() { - if r := recover(); r != nil { - mctx.ModuleErrorf("sdkDepsReplaceMutator %s", r) - } - }() - - // Replace dependencies on sdkmember with a dependency on the current module which - // is a versioned prebuilt of the sdkmember if required. - mctx.ReplaceDependenciesIf(memberName, func(from blueprint.Module, tag blueprint.DependencyTag, to blueprint.Module) bool { - // from - foo - // to - sdkmember - replace := false - if parent, ok := from.(android.RequiredSdks); ok { - replace = parent.RequiredSdks().Contains(sdk) - } - return replace - }) - } - } -} - -// Step 6: ensure that the dependencies outside of the APEX are all from the required SDKs -func sdkRequirementsMutator(mctx android.TopDownMutatorContext) { - if m, ok := mctx.Module().(sdkAndApexModule); ok { - requiredSdks := m.RequiredSdks() - if len(requiredSdks) == 0 { - return - } - mctx.VisitDirectDeps(func(dep android.Module) { - tag := mctx.OtherModuleDependencyTag(dep) - if tag == android.DefaultsDepTag { - // dependency to defaults is always okay - return - } - - // Ignore the dependency from the unversioned member to any versioned members as an - // apex that depends on the unversioned member will not also be depending on a versioned - // member. - if _, ok := tag.(sdkMemberVersionedDepTag); ok { - return - } - - // If the dep is outside of the APEX, but is not in any of the required SDKs, we know that the - // dep is a violation. - if sa, ok := dep.(android.SdkAware); ok { - // It is not an error if a dependency that is excluded from the apex due to the tag is not - // in one of the required SDKs. That is because all of the existing tags that implement it - // do not depend on modules which can or should belong to an sdk_snapshot. - if _, ok := tag.(android.ExcludeFromApexContentsTag); ok { - // The tag defines a dependency that never requires the child module to be part of the - // same apex. - return - } - - if !m.DepIsInSameApex(mctx, dep) && !requiredSdks.Contains(sa.ContainingSdk()) { - mctx.ModuleErrorf("depends on %q (in SDK %q) that isn't part of the required SDKs: %v", - sa.Name(), sa.ContainingSdk(), requiredSdks) - } - } - }) - } } diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go index 83294f6ab..40de15027 100644 --- a/sdk/sdk_test.go +++ b/sdk/sdk_test.go @@ -37,64 +37,6 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -func TestDepNotInRequiredSdks(t *testing.T) { - testSdkError(t, `module "myjavalib".*depends on "otherlib".*that isn't part of the required SDKs:.*`, ` - sdk { - name: "mysdk", - java_header_libs: ["sdkmember"], - } - - sdk_snapshot { - name: "mysdk@1", - java_header_libs: ["sdkmember_mysdk_1"], - } - - java_import { - name: "sdkmember", - prefer: false, - host_supported: true, - } - - java_import { - name: "sdkmember_mysdk_1", - sdk_member_name: "sdkmember", - host_supported: true, - } - - java_library { - name: "myjavalib", - srcs: ["Test.java"], - libs: [ - "sdkmember", - "otherlib", - ], - system_modules: "none", - sdk_version: "none", - compile_dex: true, - host_supported: true, - apex_available: ["myapex"], - } - - // this lib is no in mysdk - java_library { - name: "otherlib", - srcs: ["Test.java"], - system_modules: "none", - sdk_version: "none", - compile_dex: true, - host_supported: true, - } - - apex { - name: "myapex", - java_libs: ["myjavalib"], - uses_sdks: ["mysdk@1"], - key: "myapex.key", - certificate: ":myapex.cert", - } - `) -} - // Ensure that prebuilt modules have the same effective visibility as the source // modules. func TestSnapshotVisibility(t *testing.T) { From a70425fb2f49bf0cf8d9d459c71c6f78d5cbd62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20Prieto=20Gasc=C3=B3?= Date: Fri, 20 May 2022 13:05:34 +0000 Subject: [PATCH 130/148] Revert "Append APEX version instead of build ID for APK-in-APEX ..." Revert "Make apexer replace instances of version placeholder str..." Revert submission 17944887-apk-in-apex Reason for revert: Caused a regression (b/230873680) Reverted Changes: Ic37eeba8b:Make apexer replace instances of version placehold... I9cef1418c:Append APEX version instead of build ID for APK-in... Change-Id: I3da8bcb782baf71cddce9e4e92fe3894fc187b5c --- apex/apex.go | 20 ++++++++++++++--- apex/apex_test.go | 57 ++++++++++++++++++++++++++++++++++++----------- apex/builder.go | 35 +++++++++++++---------------- 3 files changed, 76 insertions(+), 36 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 92cf53aa2..ef1eb8408 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -19,6 +19,7 @@ package apex import ( "fmt" "path/filepath" + "regexp" "sort" "strings" @@ -1656,7 +1657,20 @@ type androidApp interface { var _ androidApp = (*java.AndroidApp)(nil) var _ androidApp = (*java.AndroidAppImport)(nil) -const APEX_VERSION_PLACEHOLDER = "__APEX_VERSION_PLACEHOLDER__" +func sanitizedBuildIdForPath(ctx android.BaseModuleContext) string { + buildId := ctx.Config().BuildId() + + // The build ID is used as a suffix for a filename, so ensure that + // the set of characters being used are sanitized. + // - any word character: [a-zA-Z0-9_] + // - dots: . + // - dashes: - + validRegex := regexp.MustCompile(`^[\w\.\-\_]+$`) + if !validRegex.MatchString(buildId) { + ctx.ModuleErrorf("Unable to use build id %s as filename suffix, valid characters are [a-z A-Z 0-9 _ . -].", buildId) + } + return buildId +} func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp androidApp) apexFile { appDir := "app" @@ -1667,7 +1681,7 @@ func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp androidApp) apexF // TODO(b/224589412, b/226559955): Ensure that the subdirname is suffixed // so that PackageManager correctly invalidates the existing installed apk // in favour of the new APK-in-APEX. See bugs for more information. - dirInApex := filepath.Join(appDir, aapp.InstallApkName()+"@"+APEX_VERSION_PLACEHOLDER) + dirInApex := filepath.Join(appDir, aapp.InstallApkName()+"@"+sanitizedBuildIdForPath(ctx)) fileToCopy := aapp.OutputFile() af := newApexFile(ctx, fileToCopy, aapp.BaseModuleName(), dirInApex, app, aapp) @@ -1906,7 +1920,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { // suffixed so that PackageManager correctly invalidates the // existing installed apk in favour of the new APK-in-APEX. // See bugs for more information. - appDirName := filepath.Join(appDir, ap.BaseModuleName()+"@"+APEX_VERSION_PLACEHOLDER) + appDirName := filepath.Join(appDir, ap.BaseModuleName()+"@"+sanitizedBuildIdForPath(ctx)) af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(), appDirName, appSet, ap) af.certificate = java.PresignedCertificate filesInfo = append(filesInfo, af) diff --git a/apex/apex_test.go b/apex/apex_test.go index 4a52115db..7b2905884 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -223,6 +223,7 @@ var prepareForApexTest = android.GroupFixturePreparers( // not because of these tests specifically (it's not used by the tests) variables.Platform_version_active_codenames = []string{"Q", "Tiramisu"} variables.Platform_vndk_version = proptools.StringPtr("29") + variables.BuildId = proptools.StringPtr("TEST.BUILD_ID") }), ) @@ -682,7 +683,7 @@ func TestDefaults(t *testing.T) { "etc/myetc", "javalib/myjar.jar", "lib64/mylib.so", - "app/AppFoo@__APEX_VERSION_PLACEHOLDER__/AppFoo.apk", + "app/AppFoo@TEST.BUILD_ID/AppFoo.apk", "overlay/blue/rro.apk", "etc/bpf/bpf.o", "etc/bpf/bpf2.o", @@ -5682,8 +5683,8 @@ func TestApexWithApps(t *testing.T) { apexRule := module.Rule("apexRule") copyCmds := apexRule.Args["copy_commands"] - ensureContains(t, copyCmds, "image.apex/app/AppFoo@__APEX_VERSION_PLACEHOLDER__/AppFoo.apk") - ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv@__APEX_VERSION_PLACEHOLDER__/AppFooPriv.apk") + ensureContains(t, copyCmds, "image.apex/app/AppFoo@TEST.BUILD_ID/AppFoo.apk") + ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv@TEST.BUILD_ID/AppFooPriv.apk") appZipRule := ctx.ModuleForTests("AppFoo", "android_common_apex10000").Description("zip jni libs") // JNI libraries are uncompressed @@ -5700,6 +5701,36 @@ func TestApexWithApps(t *testing.T) { } } +func TestApexWithAppImportBuildId(t *testing.T) { + invalidBuildIds := []string{"../", "a b", "a/b", "a/b/../c", "/a"} + for _, id := range invalidBuildIds { + message := fmt.Sprintf("Unable to use build id %s as filename suffix", id) + fixture := android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.BuildId = proptools.StringPtr(id) + }) + testApexError(t, message, `apex { + name: "myapex", + key: "myapex.key", + apps: ["AppFooPrebuilt"], + updatable: false, + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + android_app_import { + name: "AppFooPrebuilt", + apk: "PrebuiltAppFoo.apk", + presigned: true, + apex_available: ["myapex"], + } + `, fixture) + } +} + func TestApexWithAppImports(t *testing.T) { ctx := testApex(t, ` apex { @@ -5745,8 +5776,8 @@ func TestApexWithAppImports(t *testing.T) { apexRule := module.Rule("apexRule") copyCmds := apexRule.Args["copy_commands"] - ensureContains(t, copyCmds, "image.apex/app/AppFooPrebuilt@__APEX_VERSION_PLACEHOLDER__/AppFooPrebuilt.apk") - ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPrivPrebuilt@__APEX_VERSION_PLACEHOLDER__/AwesomePrebuiltAppFooPriv.apk") + ensureContains(t, copyCmds, "image.apex/app/AppFooPrebuilt@TEST.BUILD_ID/AppFooPrebuilt.apk") + ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPrivPrebuilt@TEST.BUILD_ID/AwesomePrebuiltAppFooPriv.apk") } func TestApexWithAppImportsPrefer(t *testing.T) { @@ -5787,7 +5818,7 @@ func TestApexWithAppImportsPrefer(t *testing.T) { })) ensureExactContents(t, ctx, "myapex", "android_common_myapex_image", []string{ - "app/AppFoo@__APEX_VERSION_PLACEHOLDER__/AppFooPrebuilt.apk", + "app/AppFoo@TEST.BUILD_ID/AppFooPrebuilt.apk", }) } @@ -5820,7 +5851,7 @@ func TestApexWithTestHelperApp(t *testing.T) { apexRule := module.Rule("apexRule") copyCmds := apexRule.Args["copy_commands"] - ensureContains(t, copyCmds, "image.apex/app/TesterHelpAppFoo@__APEX_VERSION_PLACEHOLDER__/TesterHelpAppFoo.apk") + ensureContains(t, copyCmds, "image.apex/app/TesterHelpAppFoo@TEST.BUILD_ID/TesterHelpAppFoo.apk") } func TestApexPropertiesShouldBeDefaultable(t *testing.T) { @@ -6263,8 +6294,8 @@ func TestOverrideApex(t *testing.T) { apexRule := module.Rule("apexRule") copyCmds := apexRule.Args["copy_commands"] - ensureNotContains(t, copyCmds, "image.apex/app/app@__APEX_VERSION_PLACEHOLDER__/app.apk") - ensureContains(t, copyCmds, "image.apex/app/override_app@__APEX_VERSION_PLACEHOLDER__/override_app.apk") + ensureNotContains(t, copyCmds, "image.apex/app/app@TEST.BUILD_ID/app.apk") + ensureContains(t, copyCmds, "image.apex/app/override_app@TEST.BUILD_ID/override_app.apk") ensureNotContains(t, copyCmds, "image.apex/etc/bpf/bpf.o") ensureContains(t, copyCmds, "image.apex/etc/bpf/override_bpf.o") @@ -7168,7 +7199,7 @@ func TestAppBundle(t *testing.T) { content := bundleConfigRule.Args["content"] ensureContains(t, content, `"compression":{"uncompressed_glob":["apex_payload.img","apex_manifest.*"]}`) - ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.android.foo","path":"app/AppFoo@__APEX_VERSION_PLACEHOLDER__/AppFoo.apk"}]}`) + ensureContains(t, content, `"apex_config":{"apex_embedded_apk_config":[{"package_name":"com.android.foo","path":"app/AppFoo@TEST.BUILD_ID/AppFoo.apk"}]}`) } func TestAppSetBundle(t *testing.T) { @@ -7199,9 +7230,9 @@ func TestAppSetBundle(t *testing.T) { if len(copyCmds) != 3 { t.Fatalf("Expected 3 commands, got %d in:\n%s", len(copyCmds), s) } - ensureMatches(t, copyCmds[0], "^rm -rf .*/app/AppSet@__APEX_VERSION_PLACEHOLDER__$") - ensureMatches(t, copyCmds[1], "^mkdir -p .*/app/AppSet@__APEX_VERSION_PLACEHOLDER__$") - ensureMatches(t, copyCmds[2], "^unzip .*-d .*/app/AppSet@__APEX_VERSION_PLACEHOLDER__ .*/AppSet.zip$") + ensureMatches(t, copyCmds[0], "^rm -rf .*/app/AppSet@TEST.BUILD_ID$") + ensureMatches(t, copyCmds[1], "^mkdir -p .*/app/AppSet@TEST.BUILD_ID$") + ensureMatches(t, copyCmds[2], "^unzip .*-d .*/app/AppSet@TEST.BUILD_ID .*/AppSet.zip$") } func TestAppSetBundlePrebuilt(t *testing.T) { diff --git a/apex/builder.go b/apex/builder.go index d4765d022..abbf8ad25 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -107,16 +107,14 @@ var ( `--canned_fs_config ${canned_fs_config} ` + `--include_build_info ` + `--payload_type image ` + - `--key ${key} ` + - `--apex_version_placeholder ${apex_version_placeholder} ` + - `${opt_flags} ${image_dir} ${out} `, + `--key ${key} ${opt_flags} ${image_dir} ${out} `, CommandDeps: []string{"${apexer}", "${avbtool}", "${e2fsdroid}", "${merge_zips}", "${mke2fs}", "${resize2fs}", "${sefcontext_compile}", "${make_f2fs}", "${sload_f2fs}", "${make_erofs}", "${soong_zip}", "${zipalign}", "${aapt2}", "prebuilts/sdk/current/public/android.jar"}, Rspfile: "${out}.copy_commands", RspfileContent: "${copy_commands}", Description: "APEX ${image_dir} => ${out}", - }, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key", "opt_flags", "manifest", "payload_fs_type", "apex_version_placeholder") + }, "tool_path", "image_dir", "copy_commands", "file_contexts", "canned_fs_config", "key", "opt_flags", "manifest", "payload_fs_type") zipApexRule = pctx.StaticRule("zipApexRule", blueprint.RuleParams{ Command: `rm -rf ${image_dir} && mkdir -p ${image_dir} && ` + @@ -124,13 +122,12 @@ var ( `APEXER_TOOL_PATH=${tool_path} ` + `${apexer} --force --manifest ${manifest} ` + `--payload_type zip ` + - `--apex_version_placeholder ${apex_version_placeholder} ` + `${image_dir} ${out} `, CommandDeps: []string{"${apexer}", "${merge_zips}", "${soong_zip}", "${zipalign}", "${aapt2}"}, Rspfile: "${out}.copy_commands", RspfileContent: "${copy_commands}", Description: "ZipAPEX ${image_dir} => ${out}", - }, "tool_path", "image_dir", "copy_commands", "manifest", "apex_version_placeholder") + }, "tool_path", "image_dir", "copy_commands", "manifest") apexProtoConvertRule = pctx.AndroidStaticRule("apexProtoConvertRule", blueprint.RuleParams{ @@ -661,15 +658,14 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { Output: unsignedOutputFile, Description: "apex (" + apexType.name() + ")", Args: map[string]string{ - "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir, - "image_dir": imageDir.String(), - "copy_commands": strings.Join(copyCommands, " && "), - "manifest": a.manifestPbOut.String(), - "file_contexts": fileContexts.String(), - "canned_fs_config": cannedFsConfig.String(), - "key": a.privateKeyFile.String(), - "opt_flags": strings.Join(optFlags, " "), - "apex_version_placeholder": APEX_VERSION_PLACEHOLDER, + "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir, + "image_dir": imageDir.String(), + "copy_commands": strings.Join(copyCommands, " && "), + "manifest": a.manifestPbOut.String(), + "file_contexts": fileContexts.String(), + "canned_fs_config": cannedFsConfig.String(), + "key": a.privateKeyFile.String(), + "opt_flags": strings.Join(optFlags, " "), }, }) @@ -761,11 +757,10 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { Output: unsignedOutputFile, Description: "apex (" + apexType.name() + ")", Args: map[string]string{ - "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir, - "image_dir": imageDir.String(), - "copy_commands": strings.Join(copyCommands, " && "), - "manifest": a.manifestPbOut.String(), - "apex_version_placeholder": APEX_VERSION_PLACEHOLDER, + "tool_path": outHostBinDir + ":" + prebuiltSdkToolsBinDir, + "image_dir": imageDir.String(), + "copy_commands": strings.Join(copyCommands, " && "), + "manifest": a.manifestPbOut.String(), }, }) } From e89f3e22e5f7bdd5eeea7fcfbcfbda4dc061817f Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 29 Apr 2022 14:21:25 +0100 Subject: [PATCH 131/148] java_sdk_library_import: Delegate OutputFiles to impl library if needed (cherry picked from commit 1e940d5b449148105e33d75cbef4bbde307bf1f9) Bug: 230846030 Test: m nothing # Cherry pick into build with prebuilts enabled to verify. Change-Id: I5ac9b1cdd2fc61efbc988e84556202ff6cd57146 --- java/sdk_library.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index 3ecba9ae9..ad6d2ed60 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -2170,7 +2170,15 @@ func (module *SdkLibraryImport) UniqueApexVariations() bool { } func (module *SdkLibraryImport) OutputFiles(tag string) (android.Paths, error) { - return module.commonOutputFiles(tag) + paths, err := module.commonOutputFiles(tag) + if paths != nil || err != nil { + return paths, err + } + if module.implLibraryModule != nil { + return module.implLibraryModule.OutputFiles(tag) + } else { + return nil, nil + } } func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { From c54158d3c78c715c6a3cf3f4744d293cf804e51b Mon Sep 17 00:00:00 2001 From: Pete Bentley Date: Wed, 18 May 2022 18:01:22 +0100 Subject: [PATCH 132/148] Remove -sha256 flag when calling bssl_inject_hash. Cherry-pick note: Needed for the BoringSSL change in the same topic due to build flag changes. Flag removed upstream, all platforms now use SHA-256 for libcrypto integrity hash. Test: m && flashall Change-Id: I453edebb80ec2a853d54ce5c3f055b6456010524 (cherry picked from commit c0d89b3db1ca447b67e7c87d3fa6bb60bd9eb34d) Merged-In: I453edebb80ec2a853d54ce5c3f055b6456010524 --- cc/library.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cc/library.go b/cc/library.go index b1c18f4d0..f9bef6c5e 100644 --- a/cc/library.go +++ b/cc/library.go @@ -2437,7 +2437,6 @@ func maybeInjectBoringSSLHash(ctx android.ModuleContext, outputFile android.Modu rule := android.NewRuleBuilder(pctx, ctx) rule.Command(). BuiltTool("bssl_inject_hash"). - Flag("-sha256"). FlagWithInput("-in-object ", outputFile). FlagWithOutput("-o ", hashedOutputfile) rule.Build("injectCryptoHash", "inject crypto hash") From 87f73e527c24db4b2eec2aa0486edb7da2c406a4 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Wed, 25 May 2022 09:01:35 +0900 Subject: [PATCH 133/148] Remove AIDL modules from VndkMustUseVendorVariantList Vendor variants of AIDL-gen CC modules are by default different from core variants. So instead of adding them manually to the list, AIDL builder can mark them as MustUseVendorVariant. Bug: 233616647 Test: m Merged-In: Ifca0eb64d60ecb49d72cd0347336b69fb332c58c Change-Id: Ifca0eb64d60ecb49d72cd0347336b69fb332c58c (cherry picked from commit b8d3df82ac1d3e5ccb4a58bb3b31457d7450e353) --- cc/config/vndk.go | 102 +--------------------------------------------- 1 file changed, 1 insertion(+), 101 deletions(-) diff --git a/cc/config/vndk.go b/cc/config/vndk.go index db69ce785..dd612ce63 100644 --- a/cc/config/vndk.go +++ b/cc/config/vndk.go @@ -17,109 +17,9 @@ package config // List of VNDK libraries that have different core variant and vendor variant. // For these libraries, the vendor variants must be installed even if the device // has VndkUseCoreVariant set. -// TODO(b/150578172): clean up unstable and non-versioned aidl module +// Note that AIDL-generated modules must use vendor variants by default. var VndkMustUseVendorVariantList = []string{ - "android.hardware.authsecret-V1-ndk", - "android.hardware.authsecret-V1-ndk_platform", - "android.hardware.authsecret-ndk_platform", - "android.hardware.authsecret-unstable-ndk_platform", - "android.hardware.automotive.occupant_awareness-V1-ndk", - "android.hardware.automotive.occupant_awareness-V1-ndk_platform", - "android.hardware.automotive.occupant_awareness-ndk_platform", - "android.hardware.drm-V1-ndk", - "android.hardware.dumpstate-V1-ndk", - "android.hardware.gnss-V1-ndk", - "android.hardware.gnss-V1-ndk_platform", - "android.hardware.gnss-V2-ndk", - "android.hardware.gnss-ndk_platform", - "android.hardware.gnss-unstable-ndk_platform", - "android.hardware.health-V1-ndk", - "android.hardware.health-ndk", - "android.hardware.health.storage-V1-ndk", - "android.hardware.health.storage-V1-ndk_platform", - "android.hardware.health.storage-ndk_platform", - "android.hardware.health.storage-unstable-ndk_platform", - "android.hardware.identity-V2-ndk_platform", - "android.hardware.identity-V3-ndk", - "android.hardware.identity-V3-ndk_platform", - "android.hardware.identity-ndk_platform", - "android.hardware.light-V1-ndk", - "android.hardware.light-V1-ndk_platform", - "android.hardware.light-ndk_platform", - "android.hardware.memtrack-V1-ndk", - "android.hardware.memtrack-V1-ndk_platform", - "android.hardware.memtrack-ndk_platform", - "android.hardware.memtrack-unstable-ndk_platform", "android.hardware.nfc@1.2", - "android.hardware.oemlock-V1-ndk", - "android.hardware.oemlock-V1-ndk_platform", - "android.hardware.oemlock-ndk_platform", - "android.hardware.oemlock-unstable-ndk_platform", - "android.hardware.power-V1-ndk_platform", - "android.hardware.power-V2-ndk", - "android.hardware.power-V2-ndk_platform", - "android.hardware.power-ndk_platform", - "android.hardware.power.stats-V1-ndk", - "android.hardware.power.stats-V1-ndk_platform", - "android.hardware.power.stats-ndk_platform", - "android.hardware.power.stats-unstable-ndk_platform", - "android.hardware.rebootescrow-V1-ndk", - "android.hardware.rebootescrow-V1-ndk_platform", - "android.hardware.rebootescrow-ndk_platform", - "android.hardware.radio-V1-ndk", - "android.hardware.radio-V1-ndk_platform", - "android.hardware.radio.config-V1-ndk", - "android.hardware.radio.config-V1-ndk_platform", - "android.hardware.radio.data-V1-ndk", - "android.hardware.radio.data-V1-ndk_platform", - "android.hardware.radio.messaging-V1-ndk", - "android.hardware.radio.messaging-V1-ndk_platform", - "android.hardware.radio.modem-V1-ndk", - "android.hardware.radio.modem-V1-ndk_platform", - "android.hardware.radio.network-V1-ndk", - "android.hardware.radio.network-V1-ndk_platform", - "android.hardware.radio.sim-V1-ndk", - "android.hardware.radio.sim-V1-ndk_platform", - "android.hardware.radio.voice-V1-ndk", - "android.hardware.radio.voice-V1-ndk_platform", - "android.hardware.security.keymint-V1-ndk", - "android.hardware.security.keymint-V1-ndk_platform", - "android.hardware.security.keymint-ndk_platform", - "android.hardware.security.keymint-unstable-ndk_platform", - "android.hardware.security.secureclock-V1-ndk", - "android.hardware.security.secureclock-V1-ndk_platform", - "android.hardware.security.secureclock-ndk_platform", - "android.hardware.security.secureclock-unstable-ndk_platform", - "android.hardware.security.sharedsecret-V1-ndk", - "android.hardware.security.sharedsecret-V1-ndk_platform", - "android.hardware.security.sharedsecret-ndk_platform", - "android.hardware.security.sharedsecret-unstable-ndk_platform", - "android.hardware.sensors-V1-ndk", - "android.hardware.soundtrigger3-V1-ndk", - "android.hardware.soundtrigger3-V1-ndk_platform", - "android.hardware.uwb-V1-ndk", - "android.hardware.uwb-V1-ndk_platform", - "android.hardware.vibrator-V1-ndk_platform", - "android.hardware.vibrator-V2-ndk", - "android.hardware.vibrator-V2-ndk_platform", - "android.hardware.vibrator-ndk_platform", - "android.hardware.weaver-V1-ndk", - "android.hardware.weaver-V1-ndk_platform", - "android.hardware.weaver-ndk_platform", - "android.hardware.weaver-unstable-ndk_platform", - "android.system.suspend-V1-ndk", - "android.system.keystore2-V1-ndk", - "android.se.omapi-V1-ndk_platform", - "android.se.omapi-ndk_platform", - "android.se.omapi-unstable-ndk_platform", - "android.hardware.wifi.hostapd-V1-ndk", - "android.hardware.wifi.hostapd-V1-ndk_platform", - "android.hardware.wifi.supplicant-V1-ndk", - "android.system.keystore2-V1-ndk_platform", - "android.system.keystore2-ndk_platform", - "android.system.keystore2-unstable-ndk_platform", - "android.system.suspend-V1-ndk", - "android.system.suspend-V1-ndk_platform", "libbinder", "libcrypto", "libexpat", From 8e8ef9fe665cff26b608a5d05b2c712cb0a1a4b2 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 6 Jun 2022 17:28:00 +0000 Subject: [PATCH 134/148] Revert "Disable BTI for now." This reverts commit c75994d6235a023df6942fddeaa34b2a66f2e5f6. Reason for revert: BTI shipped in S, and we're going to work on app compat outreach rather than regress this security feature. Bug: https://issuetracker.google.com/216395195 Bug: https://issuetracker.google.com/233339366 Change-Id: Ic7143d756907ceb574a686258751840ce62c920f Merged-In: Ic7143d756907ceb574a686258751840ce62c920f --- cc/config/arm64_device.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go index dfe143f95..66087e6f0 100644 --- a/cc/config/arm64_device.go +++ b/cc/config/arm64_device.go @@ -33,9 +33,7 @@ var ( }, "armv8-a-branchprot": []string{ "-march=armv8-a", - // Disable BTI until drm vendors stop using OS libraries as sources - // of gadgets (https://issuetracker.google.com/216395195). - "-mbranch-protection=pac-ret", + "-mbranch-protection=standard", }, "armv8-2a": []string{ "-march=armv8.2-a", From b706b4efef8242aadcb756b345a70459fb94ea86 Mon Sep 17 00:00:00 2001 From: Sam Delmerico Date: Wed, 1 Jun 2022 15:45:02 +0000 Subject: [PATCH 135/148] add multilib data_device_bins properties Some targets need to be able to specify the specific architecture for a data_device_bin module. This commit adds new properties to allow specification of first, both, 32, or 64 multilib properties. Bug: 231448797 Bug: 232408185 Test: go test ./java -run TestDataDeviceBinsBuildsDeviceBinary Change-Id: I457cf4b1a9ccb28b46042f874c96bd0a87009fab Merged-In: I457cf4b1a9ccb28b46042f874c96bd0a87009fab --- android/arch.go | 14 ++-- android/config.go | 4 +- java/java.go | 133 +++++++++++++++++++++++++++++--- java/java_test.go | 192 ++++++++++++++++++++++++++++++++++++---------- 4 files changed, 284 insertions(+), 59 deletions(-) diff --git a/android/arch.go b/android/arch.go index f732a7dd0..cbf77c758 100644 --- a/android/arch.go +++ b/android/arch.go @@ -1832,10 +1832,10 @@ func getCommonTargets(targets []Target) []Target { return ret } -// firstTarget takes a list of Targets and a list of multilib values and returns a list of Targets +// FirstTarget takes a list of Targets and a list of multilib values and returns a list of Targets // that contains zero or one Target for each OsType, selecting the one that matches the earliest // filter. -func firstTarget(targets []Target, filters ...string) []Target { +func FirstTarget(targets []Target, filters ...string) []Target { // find the first target from each OS var ret []Target hasHost := false @@ -1865,9 +1865,9 @@ func decodeMultilibTargets(multilib string, targets []Target, prefer32 bool) ([] case "common_first": buildTargets = getCommonTargets(targets) if prefer32 { - buildTargets = append(buildTargets, firstTarget(targets, "lib32", "lib64")...) + buildTargets = append(buildTargets, FirstTarget(targets, "lib32", "lib64")...) } else { - buildTargets = append(buildTargets, firstTarget(targets, "lib64", "lib32")...) + buildTargets = append(buildTargets, FirstTarget(targets, "lib64", "lib32")...) } case "both": if prefer32 { @@ -1883,12 +1883,12 @@ func decodeMultilibTargets(multilib string, targets []Target, prefer32 bool) ([] buildTargets = filterMultilibTargets(targets, "lib64") case "first": if prefer32 { - buildTargets = firstTarget(targets, "lib32", "lib64") + buildTargets = FirstTarget(targets, "lib32", "lib64") } else { - buildTargets = firstTarget(targets, "lib64", "lib32") + buildTargets = FirstTarget(targets, "lib64", "lib32") } case "first_prefer32": - buildTargets = firstTarget(targets, "lib32", "lib64") + buildTargets = FirstTarget(targets, "lib32", "lib64") case "prefer32": buildTargets = filterMultilibTargets(targets, "lib32") if len(buildTargets) == 0 { diff --git a/android/config.go b/android/config.go index 250c312b7..ba95c5a20 100644 --- a/android/config.go +++ b/android/config.go @@ -410,7 +410,7 @@ func modifyTestConfigToSupportArchMutator(testConfig Config) { config.BuildOSTarget = config.Targets[config.BuildOS][0] config.BuildOSCommonTarget = getCommonTargets(config.Targets[config.BuildOS])[0] config.AndroidCommonTarget = getCommonTargets(config.Targets[Android])[0] - config.AndroidFirstDeviceTarget = firstTarget(config.Targets[Android], "lib64", "lib32")[0] + config.AndroidFirstDeviceTarget = FirstTarget(config.Targets[Android], "lib64", "lib32")[0] config.TestProductVariables.DeviceArch = proptools.StringPtr("arm64") config.TestProductVariables.DeviceArchVariant = proptools.StringPtr("armv8-a") config.TestProductVariables.DeviceSecondaryArch = proptools.StringPtr("arm") @@ -546,7 +546,7 @@ func NewConfig(moduleListFile string, runGoTests bool, outDir, soongOutDir strin // Compilation targets for Android. if len(config.Targets[Android]) > 0 { config.AndroidCommonTarget = getCommonTargets(config.Targets[Android])[0] - config.AndroidFirstDeviceTarget = firstTarget(config.Targets[Android], "lib64", "lib32")[0] + config.AndroidFirstDeviceTarget = FirstTarget(config.Targets[Android], "lib64", "lib32")[0] } config.BazelContext, err = NewBazelContext(config) diff --git a/java/java.go b/java/java.go index b34d6de8a..c8fb93cca 100644 --- a/java/java.go +++ b/java/java.go @@ -855,7 +855,25 @@ type hostTestProperties struct { Data_native_bins []string `android:"arch_variant"` // list of device binary modules that should be installed alongside the test - Data_device_bins []string `android:"arch_variant"` + // This property only adds the first variant of the dependency + Data_device_bins_first []string `android:"arch_variant"` + + // list of device binary modules that should be installed alongside the test + // This property adds 64bit AND 32bit variants of the dependency + Data_device_bins_both []string `android:"arch_variant"` + + // list of device binary modules that should be installed alongside the test + // This property only adds 64bit variants of the dependency + Data_device_bins_64 []string `android:"arch_variant"` + + // list of device binary modules that should be installed alongside the test + // This property adds 32bit variants of the dependency if available, or else + // defaults to the 64bit variant + Data_device_bins_prefer32 []string `android:"arch_variant"` + + // list of device binary modules that should be installed alongside the test + // This property only adds 32bit variants of the dependency + Data_device_bins_32 []string `android:"arch_variant"` } type testHelperLibraryProperties struct { @@ -922,6 +940,83 @@ func (j *JavaTestImport) InstallInTestcases() bool { return true } +func (j *TestHost) addDataDeviceBinsDeps(ctx android.BottomUpMutatorContext) { + if len(j.testHostProperties.Data_device_bins_first) > 0 { + deviceVariations := ctx.Config().AndroidFirstDeviceTarget.Variations() + ctx.AddFarVariationDependencies(deviceVariations, dataDeviceBinsTag, j.testHostProperties.Data_device_bins_first...) + } + + var maybeAndroid32Target *android.Target + var maybeAndroid64Target *android.Target + android32TargetList := android.FirstTarget(ctx.Config().Targets[android.Android], "lib32") + android64TargetList := android.FirstTarget(ctx.Config().Targets[android.Android], "lib64") + if len(android32TargetList) > 0 { + maybeAndroid32Target = &android32TargetList[0] + } + if len(android64TargetList) > 0 { + maybeAndroid64Target = &android64TargetList[0] + } + + if len(j.testHostProperties.Data_device_bins_both) > 0 { + if maybeAndroid32Target == nil && maybeAndroid64Target == nil { + ctx.PropertyErrorf("data_device_bins_both", "no device targets available. Targets: %q", ctx.Config().Targets) + return + } + if maybeAndroid32Target != nil { + ctx.AddFarVariationDependencies( + maybeAndroid32Target.Variations(), + dataDeviceBinsTag, + j.testHostProperties.Data_device_bins_both..., + ) + } + if maybeAndroid64Target != nil { + ctx.AddFarVariationDependencies( + maybeAndroid64Target.Variations(), + dataDeviceBinsTag, + j.testHostProperties.Data_device_bins_both..., + ) + } + } + + if len(j.testHostProperties.Data_device_bins_prefer32) > 0 { + if maybeAndroid32Target != nil { + ctx.AddFarVariationDependencies( + maybeAndroid32Target.Variations(), + dataDeviceBinsTag, + j.testHostProperties.Data_device_bins_prefer32..., + ) + } else { + if maybeAndroid64Target == nil { + ctx.PropertyErrorf("data_device_bins_prefer32", "no device targets available. Targets: %q", ctx.Config().Targets) + return + } + ctx.AddFarVariationDependencies( + maybeAndroid64Target.Variations(), + dataDeviceBinsTag, + j.testHostProperties.Data_device_bins_prefer32..., + ) + } + } + + if len(j.testHostProperties.Data_device_bins_32) > 0 { + if maybeAndroid32Target == nil { + ctx.PropertyErrorf("data_device_bins_32", "cannot find 32bit device target. Targets: %q", ctx.Config().Targets) + return + } + deviceVariations := maybeAndroid32Target.Variations() + ctx.AddFarVariationDependencies(deviceVariations, dataDeviceBinsTag, j.testHostProperties.Data_device_bins_32...) + } + + if len(j.testHostProperties.Data_device_bins_64) > 0 { + if maybeAndroid64Target == nil { + ctx.PropertyErrorf("data_device_bins_64", "cannot find 64bit device target. Targets: %q", ctx.Config().Targets) + return + } + deviceVariations := maybeAndroid64Target.Variations() + ctx.AddFarVariationDependencies(deviceVariations, dataDeviceBinsTag, j.testHostProperties.Data_device_bins_64...) + } +} + func (j *TestHost) DepsMutator(ctx android.BottomUpMutatorContext) { if len(j.testHostProperties.Data_native_bins) > 0 { for _, target := range ctx.MultiTargets() { @@ -929,11 +1024,6 @@ func (j *TestHost) DepsMutator(ctx android.BottomUpMutatorContext) { } } - if len(j.testHostProperties.Data_device_bins) > 0 { - deviceVariations := ctx.Config().AndroidFirstDeviceTarget.Variations() - ctx.AddFarVariationDependencies(deviceVariations, dataDeviceBinsTag, j.testHostProperties.Data_device_bins...) - } - if len(j.testProperties.Jni_libs) > 0 { for _, target := range ctx.MultiTargets() { sharedLibVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"}) @@ -941,6 +1031,8 @@ func (j *TestHost) DepsMutator(ctx android.BottomUpMutatorContext) { } } + j.addDataDeviceBinsDeps(ctx) + j.deps(ctx) } @@ -948,17 +1040,40 @@ func (j *TestHost) AddExtraResource(p android.Path) { j.extraResources = append(j.extraResources, p) } +func (j *TestHost) dataDeviceBins() []string { + ret := make([]string, 0, + len(j.testHostProperties.Data_device_bins_first)+ + len(j.testHostProperties.Data_device_bins_both)+ + len(j.testHostProperties.Data_device_bins_prefer32)+ + len(j.testHostProperties.Data_device_bins_32)+ + len(j.testHostProperties.Data_device_bins_64), + ) + + ret = append(ret, j.testHostProperties.Data_device_bins_first...) + ret = append(ret, j.testHostProperties.Data_device_bins_both...) + ret = append(ret, j.testHostProperties.Data_device_bins_prefer32...) + ret = append(ret, j.testHostProperties.Data_device_bins_32...) + ret = append(ret, j.testHostProperties.Data_device_bins_64...) + + return ret +} + func (j *TestHost) GenerateAndroidBuildActions(ctx android.ModuleContext) { var configs []tradefed.Config - if len(j.testHostProperties.Data_device_bins) > 0 { + dataDeviceBins := j.dataDeviceBins() + if len(dataDeviceBins) > 0 { // add Tradefed configuration to push device bins to device for testing remoteDir := filepath.Join("/data/local/tests/unrestricted/", j.Name()) options := []tradefed.Option{{Name: "cleanup", Value: "true"}} - for _, bin := range j.testHostProperties.Data_device_bins { + for _, bin := range dataDeviceBins { fullPath := filepath.Join(remoteDir, bin) options = append(options, tradefed.Option{Name: "push-file", Key: bin, Value: fullPath}) } - configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.PushFilePreparer", options}) + configs = append(configs, tradefed.Object{ + Type: "target_preparer", + Class: "com.android.tradefed.targetprep.PushFilePreparer", + Options: options, + }) } j.Test.generateAndroidBuildActionsWithConfig(ctx, configs) diff --git a/java/java_test.go b/java/java_test.go index 4c9382413..af889ccd4 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -1498,62 +1498,172 @@ func TestErrorproneEnabledOnlyByEnvironmentVariable(t *testing.T) { } func TestDataDeviceBinsBuildsDeviceBinary(t *testing.T) { - bp := ` + testCases := []struct { + dataDeviceBinType string + depCompileMultilib string + variants []string + expectedError string + }{ + { + dataDeviceBinType: "first", + depCompileMultilib: "first", + variants: []string{"android_arm64_armv8-a"}, + }, + { + dataDeviceBinType: "first", + depCompileMultilib: "both", + variants: []string{"android_arm64_armv8-a"}, + }, + { + // this is true because our testing framework is set up with + // Targets ~ [<64bit target>, <32bit target>], where 64bit is "first" + dataDeviceBinType: "first", + depCompileMultilib: "32", + expectedError: `Android.bp:2:3: dependency "bar" of "foo" missing variant`, + }, + { + dataDeviceBinType: "first", + depCompileMultilib: "64", + variants: []string{"android_arm64_armv8-a"}, + }, + { + dataDeviceBinType: "both", + depCompileMultilib: "both", + variants: []string{ + "android_arm_armv7-a-neon", + "android_arm64_armv8-a", + }, + }, + { + dataDeviceBinType: "both", + depCompileMultilib: "32", + expectedError: `Android.bp:2:3: dependency "bar" of "foo" missing variant`, + }, + { + dataDeviceBinType: "both", + depCompileMultilib: "64", + expectedError: `Android.bp:2:3: dependency "bar" of "foo" missing variant`, + }, + { + dataDeviceBinType: "both", + depCompileMultilib: "first", + expectedError: `Android.bp:2:3: dependency "bar" of "foo" missing variant`, + }, + { + dataDeviceBinType: "32", + depCompileMultilib: "32", + variants: []string{"android_arm_armv7-a-neon"}, + }, + { + dataDeviceBinType: "32", + depCompileMultilib: "first", + expectedError: `Android.bp:2:3: dependency "bar" of "foo" missing variant`, + }, + { + dataDeviceBinType: "32", + depCompileMultilib: "both", + variants: []string{"android_arm_armv7-a-neon"}, + }, + { + dataDeviceBinType: "32", + depCompileMultilib: "64", + expectedError: `Android.bp:2:3: dependency "bar" of "foo" missing variant`, + }, + { + dataDeviceBinType: "64", + depCompileMultilib: "64", + variants: []string{"android_arm64_armv8-a"}, + }, + { + dataDeviceBinType: "64", + depCompileMultilib: "both", + variants: []string{"android_arm64_armv8-a"}, + }, + { + dataDeviceBinType: "64", + depCompileMultilib: "first", + variants: []string{"android_arm64_armv8-a"}, + }, + { + dataDeviceBinType: "64", + depCompileMultilib: "32", + expectedError: `Android.bp:2:3: dependency "bar" of "foo" missing variant`, + }, + { + dataDeviceBinType: "prefer32", + depCompileMultilib: "32", + variants: []string{"android_arm_armv7-a-neon"}, + }, + { + dataDeviceBinType: "prefer32", + depCompileMultilib: "both", + variants: []string{"android_arm_armv7-a-neon"}, + }, + { + dataDeviceBinType: "prefer32", + depCompileMultilib: "first", + expectedError: `Android.bp:2:3: dependency "bar" of "foo" missing variant`, + }, + { + dataDeviceBinType: "prefer32", + depCompileMultilib: "64", + expectedError: `Android.bp:2:3: dependency "bar" of "foo" missing variant`, + }, + } + + bpTemplate := ` java_test_host { name: "foo", srcs: ["test.java"], - data_device_bins: ["bar"], + data_device_bins_%s: ["bar"], } cc_binary { name: "bar", + compile_multilib: "%s", } ` - ctx := android.GroupFixturePreparers( - PrepareForIntegrationTestWithJava, - ).RunTestWithBp(t, bp) + for _, tc := range testCases { + bp := fmt.Sprintf(bpTemplate, tc.dataDeviceBinType, tc.depCompileMultilib) - buildOS := ctx.Config.BuildOS.String() - fooVariant := ctx.ModuleForTests("foo", buildOS+"_common") - barVariant := ctx.ModuleForTests("bar", "android_arm64_armv8-a") - fooMod := fooVariant.Module().(*TestHost) - - relocated := barVariant.Output("bar") - expectedInput := "out/soong/.intermediates/bar/android_arm64_armv8-a/unstripped/bar" - android.AssertPathRelativeToTopEquals(t, "relocation input", expectedInput, relocated.Input) - - entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, fooMod)[0] - expectedData := []string{ - "out/soong/.intermediates/bar/android_arm64_armv8-a/bar:bar", - } - actualData := entries.EntryMap["LOCAL_COMPATIBILITY_SUPPORT_FILES"] - android.AssertStringPathsRelativeToTopEquals(t, "LOCAL_TEST_DATA", ctx.Config, expectedData, actualData) -} - -func TestDataDeviceBinsAutogenTradefedConfig(t *testing.T) { - bp := ` - java_test_host { - name: "foo", - srcs: ["test.java"], - data_device_bins: ["bar"], + errorHandler := android.FixtureExpectsNoErrors + if tc.expectedError != "" { + errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(tc.expectedError) } - cc_binary { - name: "bar", - } - ` + testName := fmt.Sprintf(`data_device_bins_%s with compile_multilib:"%s"`, tc.dataDeviceBinType, tc.depCompileMultilib) + t.Run(testName, func(t *testing.T) { + ctx := android.GroupFixturePreparers(PrepareForIntegrationTestWithJava). + ExtendWithErrorHandler(errorHandler). + RunTestWithBp(t, bp) + if tc.expectedError != "" { + return + } - ctx := android.GroupFixturePreparers( - PrepareForIntegrationTestWithJava, - ).RunTestWithBp(t, bp) + buildOS := ctx.Config.BuildOS.String() + fooVariant := ctx.ModuleForTests("foo", buildOS+"_common") + fooMod := fooVariant.Module().(*TestHost) + entries := android.AndroidMkEntriesForTest(t, ctx.TestContext, fooMod)[0] - buildOS := ctx.Config.BuildOS.String() - fooModule := ctx.ModuleForTests("foo", buildOS+"_common") - expectedAutogenConfig := `