diff options
Diffstat (limited to 'apex/apex.go')
| -rw-r--r-- | apex/apex.go | 2243 |
1 files changed, 1123 insertions, 1120 deletions
diff --git a/apex/apex.go b/apex/apex.go index 91770f464..ce323ca4d 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -33,692 +33,6 @@ import ( "android/soong/sh" ) -const ( - imageApexSuffix = ".apex" - zipApexSuffix = ".zipapex" - flattenedSuffix = ".flattened" - - imageApexType = "image" - zipApexType = "zip" - flattenedApexType = "flattened" - - ext4FsType = "ext4" - f2fsFsType = "f2fs" -) - -type dependencyTag struct { - blueprint.BaseDependencyTag - name string - - // determines if the dependent will be part of the APEX payload - payload bool -} - -var ( - sharedLibTag = dependencyTag{name: "sharedLib", payload: true} - jniLibTag = dependencyTag{name: "jniLib", payload: true} - executableTag = dependencyTag{name: "executable", payload: true} - javaLibTag = dependencyTag{name: "javaLib", payload: true} - prebuiltTag = dependencyTag{name: "prebuilt", payload: true} - testTag = dependencyTag{name: "test", payload: true} - keyTag = dependencyTag{name: "key"} - certificateTag = dependencyTag{name: "certificate"} - androidAppTag = dependencyTag{name: "androidApp", payload: true} - rroTag = dependencyTag{name: "rro", payload: true} - bpfTag = dependencyTag{name: "bpf", payload: true} - testForTag = dependencyTag{name: "test for"} - - apexAvailBaseline = makeApexAvailableBaseline() - - inverseApexAvailBaseline = invertApexBaseline(apexAvailBaseline) -) - -// Transform the map of apex -> modules to module -> apexes. -func invertApexBaseline(m map[string][]string) map[string][]string { - r := make(map[string][]string) - for apex, modules := range m { - for _, module := range modules { - r[module] = append(r[module], apex) - } - } - return r -} - -// Retrieve the baseline of apexes to which the supplied module belongs. -func BaselineApexAvailable(moduleName string) []string { - return inverseApexAvailBaseline[normalizeModuleName(moduleName)] -} - -// This is a map from apex to modules, which overrides the -// apex_available setting for that particular module to make -// it available for the apex regardless of its setting. -// TODO(b/147364041): remove this -func makeApexAvailableBaseline() map[string][]string { - // The "Module separator"s below are employed to minimize merge conflicts. - m := make(map[string][]string) - // - // Module separator - // - m["com.android.appsearch"] = []string{ - "icing-java-proto-lite", - "libprotobuf-java-lite", - } - // - // Module separator - // - m["com.android.bluetooth.updatable"] = []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.hardware.media@1.0", - "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", - "libFraunhoferAAC", - "libaudio-a2dp-hw-utils", - "libaudio-hearing-aid-hw-utils", - "libbinder_headers", - "libbluetooth", - "libbluetooth-types", - "libbluetooth-types-header", - "libbluetooth_gd", - "libbluetooth_headers", - "libbluetooth_jni", - "libbt-audio-hal-interface", - "libbt-bta", - "libbt-common", - "libbt-hci", - "libbt-platform-protos-lite", - "libbt-protos-lite", - "libbt-sbc-decoder", - "libbt-sbc-encoder", - "libbt-stack", - "libbt-utils", - "libbtcore", - "libbtdevice", - "libbte", - "libbtif", - "libchrome", - "libevent", - "libfmq", - "libg722codec", - "libgui_headers", - "libmedia_headers", - "libmodpb64", - "libosi", - "libstagefright_foundation_headers", - "libstagefright_headers", - "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 - // - m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"} - // - // Module separator - // - m["com.android.extservices"] = []string{ - "error_prone_annotations", - "ExtServices-core", - "ExtServices", - "libtextclassifier-java", - "libz_current", - "textclassifier-statsd", - "TextClassifierNotificationLibNoManifest", - "TextClassifierServiceLibNoManifest", - } - // - // Module separator - // - m["com.android.neuralnetworks"] = []string{ - "android.hardware.neuralnetworks@1.0", - "android.hardware.neuralnetworks@1.1", - "android.hardware.neuralnetworks@1.2", - "android.hardware.neuralnetworks@1.3", - "android.hidl.allocator@1.0", - "android.hidl.memory.token@1.0", - "android.hidl.memory@1.0", - "android.hidl.safe_union@1.0", - "libarect", - "libbuildversion", - "libmath", - "libprocpartition", - "libsync", - } - // - // 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", - "libbinder_headers", - "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", - "libsync", - "libui", - "libui_headers", - "libunwindstack", - "libvibrator", - "libvorbisidec", - "libwavextractor", - "libwebm", - "media_ndk_headers", - "media_plugin_headers", - "updatable-media", - } - // - // 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", - "android.hardware.graphics.mapper@2.0", - "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", - "libbinder_headers", - "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_bufferqueue_helper", - "libstagefright_enc_common", - "libstagefright_flacdec", - "libstagefright_foundation", - "libstagefright_foundation_headers", - "libstagefright_headers", - "libstagefright_m4vh263dec", - "libstagefright_m4vh263enc", - "libstagefright_mp3dec", - "libsync", - "libui", - "libui_headers", - "libunwindstack", - "libvorbisidec", - "libvpx", - "libyuv", - "libyuv_static", - "media_ndk_headers", - "media_plugin_headers", - "mediaswcodec", - } - // - // Module separator - // - m["com.android.mediaprovider"] = []string{ - "MediaProvider", - "MediaProviderGoogle", - "fmtlib_ndk", - "libbase_ndk", - "libfuse", - "libfuse_jni", - } - // - // Module separator - // - m["com.android.permission"] = []string{ - "car-ui-lib", - "iconloader", - "kotlin-annotations", - "kotlin-stdlib", - "kotlin-stdlib-jdk7", - "kotlin-stdlib-jdk8", - "kotlinx-coroutines-android", - "kotlinx-coroutines-android-nodeps", - "kotlinx-coroutines-core", - "kotlinx-coroutines-core-nodeps", - "permissioncontroller-statsd", - "GooglePermissionController", - "PermissionController", - "SettingsLibActionBarShadow", - "SettingsLibAppPreference", - "SettingsLibBarChartPreference", - "SettingsLibLayoutPreference", - "SettingsLibProgressBar", - "SettingsLibSearchWidget", - "SettingsLibSettingsTheme", - "SettingsLibRestrictedLockUtils", - "SettingsLibHelpUtils", - } - // - // Module separator - // - m["com.android.runtime"] = []string{ - "bionic_libc_platform_headers", - "libarm-optimized-routines-math", - "libc_aeabi", - "libc_bionic", - "libc_bionic_ndk", - "libc_bootstrap", - "libc_common", - "libc_common_shared", - "libc_common_static", - "libc_dns", - "libc_dynamic_dispatch", - "libc_fortify", - "libc_freebsd", - "libc_freebsd_large_stack", - "libc_gdtoa", - "libc_init_dynamic", - "libc_init_static", - "libc_jemalloc_wrapper", - "libc_netbsd", - "libc_nomalloc", - "libc_nopthread", - "libc_openbsd", - "libc_openbsd_large_stack", - "libc_openbsd_ndk", - "libc_pthread", - "libc_static_dispatch", - "libc_syscalls", - "libc_tzcode", - "libc_unwind_static", - "libdebuggerd", - "libdebuggerd_common_headers", - "libdebuggerd_handler_core", - "libdebuggerd_handler_fallback", - "libdl_static", - "libjemalloc5", - "liblinker_main", - "liblinker_malloc", - "liblz4", - "liblzma", - "libprocinfo", - "libpropertyinfoparser", - "libscudo", - "libstdc++", - "libsystemproperties", - "libtombstoned_client_static", - "libunwindstack", - "libz", - "libziparchive", - } - // - // Module separator - // - m["com.android.tethering"] = []string{ - "android.hardware.tetheroffload.config-V1.0-java", - "android.hardware.tetheroffload.control-V1.0-java", - "android.hidl.base-V1.0-java", - "libcgrouprc", - "libcgrouprc_format", - "libtetherutilsjni", - "libvndksupport", - "net-utils-framework-common", - "netd_aidl_interface-V3-java", - "netlink-client", - "networkstack-aidl-interfaces-java", - "tethering-aidl-interfaces-java", - "TetheringApiCurrentLib", - } - // - // Module separator - // - m["com.android.wifi"] = []string{ - "PlatformProperties", - "android.hardware.wifi-V1.0-java", - "android.hardware.wifi-V1.0-java-constants", - "android.hardware.wifi-V1.1-java", - "android.hardware.wifi-V1.2-java", - "android.hardware.wifi-V1.3-java", - "android.hardware.wifi-V1.4-java", - "android.hardware.wifi.hostapd-V1.0-java", - "android.hardware.wifi.hostapd-V1.1-java", - "android.hardware.wifi.hostapd-V1.2-java", - "android.hardware.wifi.supplicant-V1.0-java", - "android.hardware.wifi.supplicant-V1.1-java", - "android.hardware.wifi.supplicant-V1.2-java", - "android.hardware.wifi.supplicant-V1.3-java", - "android.hidl.base-V1.0-java", - "android.hidl.manager-V1.0-java", - "android.hidl.manager-V1.1-java", - "android.hidl.manager-V1.2-java", - "bouncycastle-unbundled", - "dnsresolver_aidl_interface-V2-java", - "error_prone_annotations", - "framework-wifi-pre-jarjar", - "framework-wifi-util-lib", - "ipmemorystore-aidl-interfaces-V3-java", - "ipmemorystore-aidl-interfaces-java", - "ksoap2", - "libnanohttpd", - "libwifi-jni", - "net-utils-services-common", - "netd_aidl_interface-V2-java", - "netd_aidl_interface-unstable-java", - "netd_event_listener_interface-java", - "netlink-client", - "networkstack-client", - "services.net", - "wifi-lite-protos", - "wifi-nano-protos", - "wifi-service-pre-jarjar", - "wifi-service-resources", - } - // - // Module separator - // - m["com.android.sdkext"] = []string{ - "fmtlib_ndk", - "libbase_ndk", - "libprotobuf-cpp-lite-ndk", - } - // - // Module separator - // - m["com.android.os.statsd"] = []string{ - "libstatssocket", - } - // - // Module separator - // - m[android.AvailableToAnyApex] = []string{ - // TODO(b/156996905) Set apex_available/min_sdk_version for androidx/extras support libraries - "androidx", - "androidx-constraintlayout_constraintlayout", - "androidx-constraintlayout_constraintlayout-nodeps", - "androidx-constraintlayout_constraintlayout-solver", - "androidx-constraintlayout_constraintlayout-solver-nodeps", - "com.google.android.material_material", - "com.google.android.material_material-nodeps", - - "libatomic", - "libclang_rt", - "libgcc_stripped", - "libprofile-clang-extras", - "libprofile-clang-extras_ndk", - "libprofile-extras", - "libprofile-extras_ndk", - "libunwind_llvm", - } - return m -} - -// 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{ - "com.android.conscrypt": []string{ - "android.net.ssl", - "com.android.org.conscrypt", - }, - "com.android.media": []string{ - "android.media", - }, - } -} - -// 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{ - "com.android.mediaprovider": []string{ - "android.provider", - }, - "com.android.permission": []string{ - "android.permission", - "android.app.role", - "com.android.permission", - "com.android.role", - }, - "com.android.sdkext": []string{ - "android.os.ext", - }, - "com.android.os.statsd": []string{ - "android.app", - "android.os", - "android.util", - "com.android.internal.statsd", - "com.android.server.stats", - }, - "com.android.wifi": []string{ - "com.android.server.wifi", - "com.android.wifi.x", - "android.hardware.wifi", - "android.net.wifi", - }, - "com.android.tethering": []string{ - "android.net", - }, - } -} - func init() { android.RegisterModuleType("apex", BundleFactory) android.RegisterModuleType("apex_test", testApexBundleFactory) @@ -730,24 +44,6 @@ func init() { android.PreDepsMutators(RegisterPreDepsMutators) android.PostDepsMutators(RegisterPostDepsMutators) - - android.AddNeverAllowRules(createApexPermittedPackagesRules(qModulesPackages())...) - android.AddNeverAllowRules(createApexPermittedPackagesRules(rModulesPackages())...) -} - -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 { - permitted_packages_rule := 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 allow these packages: " + strings.Join(module_packages, ",") + - ". Please jarjar or move code around.") - rules = append(rules, permitted_packages_rule) - } - return rules } func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) { @@ -766,304 +62,6 @@ func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) { ctx.BottomUp("mark_platform_availability", markPlatformAvailability).Parallel() } -// Mark the direct and transitive dependencies of apex bundles so that they -// can be built for the apex bundles. -func apexDepsMutator(mctx android.TopDownMutatorContext) { - if !mctx.Module().Enabled() { - return - } - a, ok := mctx.Module().(*apexBundle) - if !ok || a.vndkApex { - return - } - - useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface()) - excludeVndkLibs := useVndk && proptools.Bool(a.properties.Use_vndk_as_stable) - if !useVndk && proptools.Bool(a.properties.Use_vndk_as_stable) { - mctx.PropertyErrorf("use_vndk_as_stable", "not supported for system/system_ext APEXes") - return - } - - contents := make(map[string]android.ApexMembership) - - continueApexDepsWalk := func(child, parent android.Module) bool { - am, ok := child.(android.ApexModule) - if !ok || !am.CanHaveApexVariants() { - return false - } - if !parent.(android.DepIsInSameApex).DepIsInSameApex(mctx, child) { - return false - } - if excludeVndkLibs { - if c, ok := child.(*cc.Module); ok && c.IsVndk() { - return false - } - } - return true - } - - mctx.WalkDeps(func(child, parent android.Module) bool { - if !continueApexDepsWalk(child, parent) { - return false - } - - depName := mctx.OtherModuleName(child) - // If the parent is apexBundle, this child is directly depended. - _, directDep := parent.(*apexBundle) - contents[depName] = contents[depName].Add(directDep) - return true - }) - - apexContents := android.NewApexContents(mctx.ModuleName(), contents) - mctx.SetProvider(ApexBundleInfoProvider, ApexBundleInfo{ - Contents: apexContents, - }) - - apexInfo := android.ApexInfo{ - ApexVariationName: mctx.ModuleName(), - MinSdkVersionStr: a.minSdkVersion(mctx).String(), - RequiredSdks: a.RequiredSdks(), - Updatable: a.Updatable(), - InApexes: []string{mctx.ModuleName()}, - ApexContents: []*android.ApexContents{apexContents}, - } - - mctx.WalkDeps(func(child, parent android.Module) bool { - if !continueApexDepsWalk(child, parent) { - return false - } - - child.(android.ApexModule).BuildForApex(apexInfo) - return true - }) -} - -func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { - return - } - if am, ok := mctx.Module().(android.ApexModule); ok { - // Check if any dependencies use unique apex variations. If so, use unique apex variations - // for this module. - android.UpdateUniqueApexVariationsForDeps(mctx, am) - } -} - -func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { - return - } - // Check if this module is a test for an apex. If so, add a dependency on the apex - // in order to retrieve its contents later. - if am, ok := mctx.Module().(android.ApexModule); ok { - if testFor := am.TestFor(); len(testFor) > 0 { - mctx.AddFarVariationDependencies([]blueprint.Variation{ - {Mutator: "os", Variation: am.Target().OsVariation()}, - {"arch", "common"}, - }, testForTag, testFor...) - } - } -} - -func apexTestForMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { - return - } - - if _, ok := mctx.Module().(android.ApexModule); ok { - var contents []*android.ApexContents - for _, testFor := range mctx.GetDirectDepsWithTag(testForTag) { - abInfo := mctx.OtherModuleProvider(testFor, ApexBundleInfoProvider).(ApexBundleInfo) - contents = append(contents, abInfo.Contents) - } - mctx.SetProvider(android.ApexTestForInfoProvider, android.ApexTestForInfo{ - ApexContents: contents, - }) - } -} - -// mark if a module cannot be available to platform. A module cannot be available -// to platform if 1) it is explicitly marked as not available (i.e. "//apex_available:platform" -// is absent) or 2) it depends on another module that isn't (or can't be) available to platform -func markPlatformAvailability(mctx android.BottomUpMutatorContext) { - // Host and recovery are not considered as platform - if mctx.Host() || mctx.Module().InstallInRecovery() { - return - } - - if am, ok := mctx.Module().(android.ApexModule); ok { - availableToPlatform := am.AvailableFor(android.AvailableToPlatform) - - // If any of the dep is not available to platform, this module is also considered - // as being not available to platform even if it has "//apex_available:platform" - mctx.VisitDirectDeps(func(child android.Module) { - if !am.DepIsInSameApex(mctx, child) { - // if the dependency crosses apex boundary, don't consider it - return - } - if dep, ok := child.(android.ApexModule); ok && dep.NotAvailableForPlatform() { - availableToPlatform = false - // TODO(b/154889534) trigger an error when 'am' has "//apex_available:platform" - } - }) - - // Exception 1: stub libraries and native bridge libraries are always available to platform - if cc, ok := mctx.Module().(*cc.Module); ok && - (cc.IsStubs() || cc.Target().NativeBridge == android.NativeBridgeEnabled) { - availableToPlatform = true - } - - // Exception 2: bootstrap bionic libraries are also always available to platform - if cc.InstallToBootstrap(mctx.ModuleName(), mctx.Config()) { - availableToPlatform = true - } - - if !availableToPlatform { - am.SetNotAvailableForPlatform() - } - } -} - -// If a module in an APEX depends on a module from an SDK then it needs an APEX -// specific variant created for it. Refer to sdk.sdkDepsReplaceMutator. -func inAnySdk(module android.Module) bool { - if sa, ok := module.(android.SdkAware); ok { - return sa.IsInAnySdk() - } - - return false -} - -// Create apex variations if a module is included in APEX(s). -func apexMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { - return - } - - if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() { - android.CreateApexVariations(mctx, am) - } else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex { - // apex bundle itself is mutated so that it and its modules have same - // apex variant. - apexBundleName := mctx.ModuleName() - mctx.CreateVariations(apexBundleName) - } else if o, ok := mctx.Module().(*OverrideApex); ok { - apexBundleName := o.GetOverriddenModuleName() - if apexBundleName == "" { - mctx.ModuleErrorf("base property is not set") - return - } - mctx.CreateVariations(apexBundleName) - } - -} - -func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { - return - } - if am, ok := mctx.Module().(android.ApexModule); ok { - android.UpdateDirectlyInAnyApex(mctx, am) - } -} - -func apexFlattenedMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled() { - return - } - if ab, ok := mctx.Module().(*apexBundle); ok { - var variants []string - switch proptools.StringDefault(ab.properties.Payload_type, "image") { - case "image": - variants = append(variants, imageApexType, flattenedApexType) - case "zip": - variants = append(variants, zipApexType) - case "both": - variants = append(variants, imageApexType, zipApexType, flattenedApexType) - default: - mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type) - return - } - - modules := mctx.CreateLocalVariations(variants...) - - for i, v := range variants { - switch v { - case imageApexType: - modules[i].(*apexBundle).properties.ApexType = imageApex - case zipApexType: - modules[i].(*apexBundle).properties.ApexType = zipApex - case flattenedApexType: - modules[i].(*apexBundle).properties.ApexType = flattenedApex - if !mctx.Config().FlattenApex() && ab.Platform() { - modules[i].(*apexBundle).MakeAsSystemExt() - } - } - } - } else if _, ok := mctx.Module().(*OverrideApex); ok { - mctx.CreateVariations(imageApexType, flattenedApexType) - } -} - -var ( - useVendorAllowListKey = android.NewOnceKey("useVendorAllowList") -) - -// useVendorAllowList returns the list of APEXes which are allowed to use_vendor. -// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__, -// which may cause compatibility issues. (e.g. libbinder) -// Even though libbinder restricts its availability via 'apex_available' property and relies on -// yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules -// to avoid similar problems. -func useVendorAllowList(config android.Config) []string { - return config.Once(useVendorAllowListKey, func() interface{} { - return []string{ - // swcodec uses "vendor" variants for smaller size - "com.android.media.swcodec", - "test_com.android.media.swcodec", - } - }).([]string) -} - -// setUseVendorAllowListForTest overrides useVendorAllowList and must be -// called before the first call to useVendorAllowList() -func setUseVendorAllowListForTest(config android.Config, allowList []string) { - config.Once(useVendorAllowListKey, func() interface{} { - return allowList - }) -} - -type ApexNativeDependencies struct { - // List of native libraries - Native_shared_libs []string - - // List of JNI libraries - Jni_libs []string - - // List of native executables - Binaries []string - - // List of native tests - Tests []string -} - -type apexMultilibProperties struct { - // Native dependencies whose compile_multilib is "first" - First ApexNativeDependencies - - // Native dependencies whose compile_multilib is "both" - Both ApexNativeDependencies - - // Native dependencies whose compile_multilib is "prefer32" - Prefer32 ApexNativeDependencies - - // Native dependencies whose compile_multilib is "32" - Lib32 ApexNativeDependencies - - // Native dependencies whose compile_multilib is "64" - Lib64 ApexNativeDependencies -} - type apexBundleProperties struct { // Json manifest file describing meta info of this APEX bundle. Default: // "apex_manifest.json" @@ -1164,11 +162,36 @@ type apexBundleProperties struct { Payload_fs_type *string } -type ApexBundleInfo struct { - Contents *android.ApexContents +type ApexNativeDependencies struct { + // List of native libraries + Native_shared_libs []string + + // List of JNI libraries + Jni_libs []string + + // List of native executables + Binaries []string + + // List of native tests + Tests []string } -var ApexBundleInfoProvider = blueprint.NewMutatorProvider(ApexBundleInfo{}, "apex_deps") +type apexMultilibProperties struct { + // Native dependencies whose compile_multilib is "first" + First ApexNativeDependencies + + // Native dependencies whose compile_multilib is "both" + Both ApexNativeDependencies + + // Native dependencies whose compile_multilib is "prefer32" + Prefer32 ApexNativeDependencies + + // Native dependencies whose compile_multilib is "32" + Lib32 ApexNativeDependencies + + // Native dependencies whose compile_multilib is "64" + Lib64 ApexNativeDependencies +} type apexTargetBundleProperties struct { Target struct { @@ -1219,35 +242,75 @@ type overridableProperties struct { Allowed_files *string `android:"path"` } -type apexPackaging int +type apexBundle struct { + android.ModuleBase + android.DefaultableModuleBase + android.OverridableModuleBase + android.SdkBase -const ( - imageApex apexPackaging = iota - zipApex - flattenedApex -) + properties apexBundleProperties + targetProperties apexTargetBundleProperties + overridableProperties overridableProperties -// The suffix for the output "file", not the module -func (a apexPackaging) suffix() string { - switch a { - case imageApex: - return imageApexSuffix - case zipApex: - return zipApexSuffix - default: - panic(fmt.Errorf("unknown APEX type %d", a)) - } -} + // specific to apex_vndk modules + vndkProperties apexVndkProperties -func (a apexPackaging) name() string { - switch a { - case imageApex: - return imageApexType - case zipApex: - return zipApexType - default: - panic(fmt.Errorf("unknown APEX type %d", a)) - } + bundleModuleFile android.WritablePath + outputFile android.WritablePath + installDir android.InstallPath + + prebuiltFileToDelete string + + public_key_file android.Path + private_key_file android.Path + + container_certificate_file android.Path + container_private_key_file android.Path + + fileContexts android.WritablePath + + // list of files to be included in this apex + filesInfo []apexFile + + // list of module names that should be installed along with this APEX + requiredDeps []string + + // list of module names that this APEX is including (to be shown via *-deps-info target) + android.ApexBundleDepsInfo + + testApex bool + vndkApex bool + artApex bool + primaryApexType bool + + manifestJsonOut android.WritablePath + manifestPbOut android.WritablePath + + // list of commands to create symlinks for backward compatibility. + // these commands will be attached as LOCAL_POST_INSTALL_CMD to + // apex package itself(for unflattened build) or apex_manifest(for flattened build) + // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting. + compatSymlinks []string + + // Suffix of module name in Android.mk + // ".flattened", ".apex", ".zipapex", or "" + suffix string + + installedFilesFile android.WritablePath + + // Whether to create symlink to the system file instead of having a file + // inside the apex or not + linkToSystemLib bool + + // Struct holding the merged notice file paths in different formats + mergedNotices android.NoticeOutputs + + // Optional list of lint report zip files for apexes that contain java or app modules + lintReports android.Paths + + payloadFsType fsType + + distFiles android.TaggedDistFiles } type apexFileClass int @@ -1378,95 +441,6 @@ func (af *apexFile) AvailableToPlatform() bool { return false } -type fsType int - -const ( - ext4 fsType = iota - f2fs -) - -func (f fsType) string() string { - switch f { - case ext4: - return ext4FsType - case f2fs: - return f2fsFsType - default: - panic(fmt.Errorf("unknown APEX payload type %d", f)) - } -} - -type apexBundle struct { - android.ModuleBase - android.DefaultableModuleBase - android.OverridableModuleBase - android.SdkBase - - properties apexBundleProperties - targetProperties apexTargetBundleProperties - overridableProperties overridableProperties - - // specific to apex_vndk modules - vndkProperties apexVndkProperties - - bundleModuleFile android.WritablePath - outputFile android.WritablePath - installDir android.InstallPath - - prebuiltFileToDelete string - - public_key_file android.Path - private_key_file android.Path - - container_certificate_file android.Path - container_private_key_file android.Path - - fileContexts android.WritablePath - - // list of files to be included in this apex - filesInfo []apexFile - - // list of module names that should be installed along with this APEX - requiredDeps []string - - // list of module names that this APEX is including (to be shown via *-deps-info target) - android.ApexBundleDepsInfo - - testApex bool - vndkApex bool - artApex bool - primaryApexType bool - - manifestJsonOut android.WritablePath - manifestPbOut android.WritablePath - - // list of commands to create symlinks for backward compatibility. - // these commands will be attached as LOCAL_POST_INSTALL_CMD to - // apex package itself(for unflattened build) or apex_manifest(for flattened build) - // so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting. - compatSymlinks []string - - // Suffix of module name in Android.mk - // ".flattened", ".apex", ".zipapex", or "" - suffix string - - installedFilesFile android.WritablePath - - // Whether to create symlink to the system file instead of having a file - // inside the apex or not - linkToSystemLib bool - - // Struct holding the merged notice file paths in different formats - mergedNotices android.NoticeOutputs - - // Optional list of lint report zip files for apexes that contain java or app modules - lintReports android.Paths - - payloadFsType fsType - - distFiles android.TaggedDistFiles -} - func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, nativeModules ApexNativeDependencies, target android.Target, imageVariation string) { @@ -1509,6 +483,29 @@ func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) { } } +type dependencyTag struct { + blueprint.BaseDependencyTag + name string + + // determines if the dependent will be part of the APEX payload + payload bool +} + +var ( + sharedLibTag = dependencyTag{name: "sharedLib", payload: true} + jniLibTag = dependencyTag{name: "jniLib", payload: true} + executableTag = dependencyTag{name: "executable", payload: true} + javaLibTag = dependencyTag{name: "javaLib", payload: true} + prebuiltTag = dependencyTag{name: "prebuilt", payload: true} + testTag = dependencyTag{name: "test", payload: true} + keyTag = dependencyTag{name: "key"} + certificateTag = dependencyTag{name: "certificate"} + androidAppTag = dependencyTag{name: "androidApp", payload: true} + rroTag = dependencyTag{name: "rro", payload: true} + bpfTag = dependencyTag{name: "bpf", payload: true} + testForTag = dependencyTag{name: "test for"} +) + func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorAllowList(ctx.Config())) { ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true") @@ -1658,6 +655,341 @@ func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutato rroTag, a.overridableProperties.Rros...) } +type ApexBundleInfo struct { + Contents *android.ApexContents +} + +var ApexBundleInfoProvider = blueprint.NewMutatorProvider(ApexBundleInfo{}, "apex_deps") + +// Mark the direct and transitive dependencies of apex bundles so that they +// can be built for the apex bundles. +func apexDepsMutator(mctx android.TopDownMutatorContext) { + if !mctx.Module().Enabled() { + return + } + a, ok := mctx.Module().(*apexBundle) + if !ok || a.vndkApex { + return + } + + useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface()) + excludeVndkLibs := useVndk && proptools.Bool(a.properties.Use_vndk_as_stable) + if !useVndk && proptools.Bool(a.properties.Use_vndk_as_stable) { + mctx.PropertyErrorf("use_vndk_as_stable", "not supported for system/system_ext APEXes") + return + } + + contents := make(map[string]android.ApexMembership) + + continueApexDepsWalk := func(child, parent android.Module) bool { + am, ok := child.(android.ApexModule) + if !ok || !am.CanHaveApexVariants() { + return false + } + if !parent.(android.DepIsInSameApex).DepIsInSameApex(mctx, child) { + return false + } + if excludeVndkLibs { + if c, ok := child.(*cc.Module); ok && c.IsVndk() { + return false + } + } + return true + } + + mctx.WalkDeps(func(child, parent android.Module) bool { + if !continueApexDepsWalk(child, parent) { + return false + } + + depName := mctx.OtherModuleName(child) + // If the parent is apexBundle, this child is directly depended. + _, directDep := parent.(*apexBundle) + contents[depName] = contents[depName].Add(directDep) + return true + }) + + apexContents := android.NewApexContents(mctx.ModuleName(), contents) + mctx.SetProvider(ApexBundleInfoProvider, ApexBundleInfo{ + Contents: apexContents, + }) + + apexInfo := android.ApexInfo{ + ApexVariationName: mctx.ModuleName(), + MinSdkVersionStr: a.minSdkVersion(mctx).String(), + RequiredSdks: a.RequiredSdks(), + Updatable: a.Updatable(), + InApexes: []string{mctx.ModuleName()}, + ApexContents: []*android.ApexContents{apexContents}, + } + + mctx.WalkDeps(func(child, parent android.Module) bool { + if !continueApexDepsWalk(child, parent) { + return false + } + + child.(android.ApexModule).BuildForApex(apexInfo) + return true + }) +} + +func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) { + if !mctx.Module().Enabled() { + return + } + if am, ok := mctx.Module().(android.ApexModule); ok { + // Check if any dependencies use unique apex variations. If so, use unique apex variations + // for this module. + android.UpdateUniqueApexVariationsForDeps(mctx, am) + } +} + +func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) { + if !mctx.Module().Enabled() { + return + } + // Check if this module is a test for an apex. If so, add a dependency on the apex + // in order to retrieve its contents later. + if am, ok := mctx.Module().(android.ApexModule); ok { + if testFor := am.TestFor(); len(testFor) > 0 { + mctx.AddFarVariationDependencies([]blueprint.Variation{ + {Mutator: "os", Variation: am.Target().OsVariation()}, + {"arch", "common"}, + }, testForTag, testFor...) + } + } +} + +func apexTestForMutator(mctx android.BottomUpMutatorContext) { + if !mctx.Module().Enabled() { + return + } + + if _, ok := mctx.Module().(android.ApexModule); ok { + var contents []*android.ApexContents + for _, testFor := range mctx.GetDirectDepsWithTag(testForTag) { + abInfo := mctx.OtherModuleProvider(testFor, ApexBundleInfoProvider).(ApexBundleInfo) + contents = append(contents, abInfo.Contents) + } + mctx.SetProvider(android.ApexTestForInfoProvider, android.ApexTestForInfo{ + ApexContents: contents, + }) + } +} + +// mark if a module cannot be available to platform. A module cannot be available +// to platform if 1) it is explicitly marked as not available (i.e. "//apex_available:platform" +// is absent) or 2) it depends on another module that isn't (or can't be) available to platform +func markPlatformAvailability(mctx android.BottomUpMutatorContext) { + // Host and recovery are not considered as platform + if mctx.Host() || mctx.Module().InstallInRecovery() { + return + } + + if am, ok := mctx.Module().(android.ApexModule); ok { + availableToPlatform := am.AvailableFor(android.AvailableToPlatform) + + // If any of the dep is not available to platform, this module is also considered + // as being not available to platform even if it has "//apex_available:platform" + mctx.VisitDirectDeps(func(child android.Module) { + if !am.DepIsInSameApex(mctx, child) { + // if the dependency crosses apex boundary, don't consider it + return + } + if dep, ok := child.(android.ApexModule); ok && dep.NotAvailableForPlatform() { + availableToPlatform = false + // TODO(b/154889534) trigger an error when 'am' has "//apex_available:platform" + } + }) + + // Exception 1: stub libraries and native bridge libraries are always available to platform + if cc, ok := mctx.Module().(*cc.Module); ok && + (cc.IsStubs() || cc.Target().NativeBridge == android.NativeBridgeEnabled) { + availableToPlatform = true + } + + // Exception 2: bootstrap bionic libraries are also always available to platform + if cc.InstallToBootstrap(mctx.ModuleName(), mctx.Config()) { + availableToPlatform = true + } + + if !availableToPlatform { + am.SetNotAvailableForPlatform() + } + } +} + +// If a module in an APEX depends on a module from an SDK then it needs an APEX +// specific variant created for it. Refer to sdk.sdkDepsReplaceMutator. +func inAnySdk(module android.Module) bool { + if sa, ok := module.(android.SdkAware); ok { + return sa.IsInAnySdk() + } + + return false +} + +// Create apex variations if a module is included in APEX(s). +func apexMutator(mctx android.BottomUpMutatorContext) { + if !mctx.Module().Enabled() { + return + } + + if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() { + android.CreateApexVariations(mctx, am) + } else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex { + // apex bundle itself is mutated so that it and its modules have same + // apex variant. + apexBundleName := mctx.ModuleName() + mctx.CreateVariations(apexBundleName) + } else if o, ok := mctx.Module().(*OverrideApex); ok { + apexBundleName := o.GetOverriddenModuleName() + if apexBundleName == "" { + mctx.ModuleErrorf("base property is not set") + return + } + mctx.CreateVariations(apexBundleName) + } + +} + +func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) { + if !mctx.Module().Enabled() { + return + } + if am, ok := mctx.Module().(android.ApexModule); ok { + android.UpdateDirectlyInAnyApex(mctx, am) + } +} + +type apexPackaging int + +const ( + imageApex apexPackaging = iota + zipApex + flattenedApex +) + +const ( + imageApexSuffix = ".apex" + zipApexSuffix = ".zipapex" + flattenedSuffix = ".flattened" + + imageApexType = "image" + zipApexType = "zip" + flattenedApexType = "flattened" + + ext4FsType = "ext4" + f2fsFsType = "f2fs" +) + +// The suffix for the output "file", not the module +func (a apexPackaging) suffix() string { + switch a { + case imageApex: + return imageApexSuffix + case zipApex: + return zipApexSuffix + default: + panic(fmt.Errorf("unknown APEX type %d", a)) + } +} + +func (a apexPackaging) name() string { + switch a { + case imageApex: + return imageApexType + case zipApex: + return zipApexType + default: + panic(fmt.Errorf("unknown APEX type %d", a)) + } +} + +func apexFlattenedMutator(mctx android.BottomUpMutatorContext) { + if !mctx.Module().Enabled() { + return + } + if ab, ok := mctx.Module().(*apexBundle); ok { + var variants []string + switch proptools.StringDefault(ab.properties.Payload_type, "image") { + case "image": + variants = append(variants, imageApexType, flattenedApexType) + case "zip": + variants = append(variants, zipApexType) + case "both": + variants = append(variants, imageApexType, zipApexType, flattenedApexType) + default: + mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type) + return + } + + modules := mctx.CreateLocalVariations(variants...) + + for i, v := range variants { + switch v { + case imageApexType: + modules[i].(*apexBundle).properties.ApexType = imageApex + case zipApexType: + modules[i].(*apexBundle).properties.ApexType = zipApex + case flattenedApexType: + modules[i].(*apexBundle).properties.ApexType = flattenedApex + if !mctx.Config().FlattenApex() && ab.Platform() { + modules[i].(*apexBundle).MakeAsSystemExt() + } + } + } + } else if _, ok := mctx.Module().(*OverrideApex); ok { + mctx.CreateVariations(imageApexType, flattenedApexType) + } +} + +var ( + useVendorAllowListKey = android.NewOnceKey("useVendorAllowList") +) + +// useVendorAllowList returns the list of APEXes which are allowed to use_vendor. +// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__, +// which may cause compatibility issues. (e.g. libbinder) +// Even though libbinder restricts its availability via 'apex_available' property and relies on +// yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules +// to avoid similar problems. +func useVendorAllowList(config android.Config) []string { + return config.Once(useVendorAllowListKey, func() interface{} { + return []string{ + // swcodec uses "vendor" variants for smaller size + "com.android.media.swcodec", + "test_com.android.media.swcodec", + } + }).([]string) +} + +// setUseVendorAllowListForTest overrides useVendorAllowList and must be +// called before the first call to useVendorAllowList() +func setUseVendorAllowListForTest(config android.Config, allowList []string) { + config.Once(useVendorAllowListKey, func() interface{} { + return allowList + }) +} + +type fsType int + +const ( + ext4 fsType = iota + f2fs +) + +func (f fsType) string() string { + switch f { + case ext4: + return ext4FsType + case f2fs: + return f2fsFsType + default: + panic(fmt.Errorf("unknown APEX payload type %d", f)) + } +} + func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { // direct deps of an APEX bundle are all part of the APEX bundle return true @@ -2615,3 +1947,674 @@ func overrideApexFactory() android.Module { android.InitOverrideModule(m) return m } + +var ( + apexAvailBaseline = makeApexAvailableBaseline() + inverseApexAvailBaseline = invertApexBaseline(apexAvailBaseline) +) + +// Transform the map of apex -> modules to module -> apexes. +func invertApexBaseline(m map[string][]string) map[string][]string { + r := make(map[string][]string) + for apex, modules := range m { + for _, module := range modules { + r[module] = append(r[module], apex) + } + } + return r +} + +// Retrieve the baseline of apexes to which the supplied module belongs. +func BaselineApexAvailable(moduleName string) []string { + return inverseApexAvailBaseline[normalizeModuleName(moduleName)] +} + +// This is a map from apex to modules, which overrides the +// apex_available setting for that particular module to make +// it available for the apex regardless of its setting. +// TODO(b/147364041): remove this +func makeApexAvailableBaseline() map[string][]string { + // The "Module separator"s below are employed to minimize merge conflicts. + m := make(map[string][]string) + // + // Module separator + // + m["com.android.appsearch"] = []string{ + "icing-java-proto-lite", + "libprotobuf-java-lite", + } + // + // Module separator + // + m["com.android.bluetooth.updatable"] = []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.hardware.media@1.0", + "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", + "libFraunhoferAAC", + "libaudio-a2dp-hw-utils", + "libaudio-hearing-aid-hw-utils", + "libbinder_headers", + "libbluetooth", + "libbluetooth-types", + "libbluetooth-types-header", + "libbluetooth_gd", + "libbluetooth_headers", + "libbluetooth_jni", + "libbt-audio-hal-interface", + "libbt-bta", + "libbt-common", + "libbt-hci", + "libbt-platform-protos-lite", + "libbt-protos-lite", + "libbt-sbc-decoder", + "libbt-sbc-encoder", + "libbt-stack", + "libbt-utils", + "libbtcore", + "libbtdevice", + "libbte", + "libbtif", + "libchrome", + "libevent", + "libfmq", + "libg722codec", + "libgui_headers", + "libmedia_headers", + "libmodpb64", + "libosi", + "libstagefright_foundation_headers", + "libstagefright_headers", + "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 + // + m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"} + // + // Module separator + // + m["com.android.extservices"] = []string{ + "error_prone_annotations", + "ExtServices-core", + "ExtServices", + "libtextclassifier-java", + "libz_current", + "textclassifier-statsd", + "TextClassifierNotificationLibNoManifest", + "TextClassifierServiceLibNoManifest", + } + // + // Module separator + // + m["com.android.neuralnetworks"] = []string{ + "android.hardware.neuralnetworks@1.0", + "android.hardware.neuralnetworks@1.1", + "android.hardware.neuralnetworks@1.2", + "android.hardware.neuralnetworks@1.3", + "android.hidl.allocator@1.0", + "android.hidl.memory.token@1.0", + "android.hidl.memory@1.0", + "android.hidl.safe_union@1.0", + "libarect", + "libbuildversion", + "libmath", + "libprocpartition", + "libsync", + } + // + // 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", + "libbinder_headers", + "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", + "libsync", + "libui", + "libui_headers", + "libunwindstack", + "libvibrator", + "libvorbisidec", + "libwavextractor", + "libwebm", + "media_ndk_headers", + "media_plugin_headers", + "updatable-media", + } + // + // 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", + "android.hardware.graphics.mapper@2.0", + "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", + "libbinder_headers", + "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_bufferqueue_helper", + "libstagefright_enc_common", + "libstagefright_flacdec", + "libstagefright_foundation", + "libstagefright_foundation_headers", + "libstagefright_headers", + "libstagefright_m4vh263dec", + "libstagefright_m4vh263enc", + "libstagefright_mp3dec", + "libsync", + "libui", + "libui_headers", + "libunwindstack", + "libvorbisidec", + "libvpx", + "libyuv", + "libyuv_static", + "media_ndk_headers", + "media_plugin_headers", + "mediaswcodec", + } + // + // Module separator + // + m["com.android.mediaprovider"] = []string{ + "MediaProvider", + "MediaProviderGoogle", + "fmtlib_ndk", + "libbase_ndk", + "libfuse", + "libfuse_jni", + } + // + // Module separator + // + m["com.android.permission"] = []string{ + "car-ui-lib", + "iconloader", + "kotlin-annotations", + "kotlin-stdlib", + "kotlin-stdlib-jdk7", + "kotlin-stdlib-jdk8", + "kotlinx-coroutines-android", + "kotlinx-coroutines-android-nodeps", + "kotlinx-coroutines-core", + "kotlinx-coroutines-core-nodeps", + "permissioncontroller-statsd", + "GooglePermissionController", + "PermissionController", + "SettingsLibActionBarShadow", + "SettingsLibAppPreference", + "SettingsLibBarChartPreference", + "SettingsLibLayoutPreference", + "SettingsLibProgressBar", + "SettingsLibSearchWidget", + "SettingsLibSettingsTheme", + "SettingsLibRestrictedLockUtils", + "SettingsLibHelpUtils", + } + // + // Module separator + // + m["com.android.runtime"] = []string{ + "bionic_libc_platform_headers", + "libarm-optimized-routines-math", + "libc_aeabi", + "libc_bionic", + "libc_bionic_ndk", + "libc_bootstrap", + "libc_common", + "libc_common_shared", + "libc_common_static", + "libc_dns", + "libc_dynamic_dispatch", + "libc_fortify", + "libc_freebsd", + "libc_freebsd_large_stack", + "libc_gdtoa", + "libc_init_dynamic", + "libc_init_static", + "libc_jemalloc_wrapper", + "libc_netbsd", + "libc_nomalloc", + "libc_nopthread", + "libc_openbsd", + "libc_openbsd_large_stack", + "libc_openbsd_ndk", + "libc_pthread", + "libc_static_dispatch", + "libc_syscalls", + "libc_tzcode", + "libc_unwind_static", + "libdebuggerd", + "libdebuggerd_common_headers", + "libdebuggerd_handler_core", + "libdebuggerd_handler_fallback", + "libdl_static", + "libjemalloc5", + "liblinker_main", + "liblinker_malloc", + "liblz4", + "liblzma", + "libprocinfo", + "libpropertyinfoparser", + "libscudo", + "libstdc++", + "libsystemproperties", + "libtombstoned_client_static", + "libunwindstack", + "libz", + "libziparchive", + } + // + // Module separator + // + m["com.android.tethering"] = []string{ + "android.hardware.tetheroffload.config-V1.0-java", + "android.hardware.tetheroffload.control-V1.0-java", + "android.hidl.base-V1.0-java", + "libcgrouprc", + "libcgrouprc_format", + "libtetherutilsjni", + "libvndksupport", + "net-utils-framework-common", + "netd_aidl_interface-V3-java", + "netlink-client", + "networkstack-aidl-interfaces-java", + "tethering-aidl-interfaces-java", + "TetheringApiCurrentLib", + } + // + // Module separator + // + m["com.android.wifi"] = []string{ + "PlatformProperties", + "android.hardware.wifi-V1.0-java", + "android.hardware.wifi-V1.0-java-constants", + "android.hardware.wifi-V1.1-java", + "android.hardware.wifi-V1.2-java", + "android.hardware.wifi-V1.3-java", + "android.hardware.wifi-V1.4-java", + "android.hardware.wifi.hostapd-V1.0-java", + "android.hardware.wifi.hostapd-V1.1-java", + "android.hardware.wifi.hostapd-V1.2-java", + "android.hardware.wifi.supplicant-V1.0-java", + "android.hardware.wifi.supplicant-V1.1-java", + "android.hardware.wifi.supplicant-V1.2-java", + "android.hardware.wifi.supplicant-V1.3-java", + "android.hidl.base-V1.0-java", + "android.hidl.manager-V1.0-java", + "android.hidl.manager-V1.1-java", + "android.hidl.manager-V1.2-java", + "bouncycastle-unbundled", + "dnsresolver_aidl_interface-V2-java", + "error_prone_annotations", + "framework-wifi-pre-jarjar", + "framework-wifi-util-lib", + "ipmemorystore-aidl-interfaces-V3-java", + "ipmemorystore-aidl-interfaces-java", + "ksoap2", + "libnanohttpd", + "libwifi-jni", + "net-utils-services-common", + "netd_aidl_interface-V2-java", + "netd_aidl_interface-unstable-java", + "netd_event_listener_interface-java", + "netlink-client", + "networkstack-client", + "services.net", + "wifi-lite-protos", + "wifi-nano-protos", + "wifi-service-pre-jarjar", + "wifi-service-resources", + } + // + // Module separator + // + m["com.android.sdkext"] = []string{ + "fmtlib_ndk", + "libbase_ndk", + "libprotobuf-cpp-lite-ndk", + } + // + // Module separator + // + m["com.android.os.statsd"] = []string{ + "libstatssocket", + } + // + // Module separator + // + m[android.AvailableToAnyApex] = []string{ + // TODO(b/156996905) Set apex_available/min_sdk_version for androidx/extras support libraries + "androidx", + "androidx-constraintlayout_constraintlayout", + "androidx-constraintlayout_constraintlayout-nodeps", + "androidx-constraintlayout_constraintlayout-solver", + "androidx-constraintlayout_constraintlayout-solver-nodeps", + "com.google.android.material_material", + "com.google.android.material_material-nodeps", + + "libatomic", + "libclang_rt", + "libgcc_stripped", + "libprofile-clang-extras", + "libprofile-clang-extras_ndk", + "libprofile-extras", + "libprofile-extras_ndk", + "libunwind_llvm", + } + return m +} + +func init() { + android.AddNeverAllowRules(createApexPermittedPackagesRules(qModulesPackages())...) + android.AddNeverAllowRules(createApexPermittedPackagesRules(rModulesPackages())...) +} + +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 { + permitted_packages_rule := 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 allow these packages: " + strings.Join(module_packages, ",") + + ". Please jarjar or move code around.") + rules = append(rules, permitted_packages_rule) + } + return rules +} + +// 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{ + "com.android.conscrypt": []string{ + "android.net.ssl", + "com.android.org.conscrypt", + }, + "com.android.media": []string{ + "android.media", + }, + } +} + +// 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{ + "com.android.mediaprovider": []string{ + "android.provider", + }, + "com.android.permission": []string{ + "android.permission", + "android.app.role", + "com.android.permission", + "com.android.role", + }, + "com.android.sdkext": []string{ + "android.os.ext", + }, + "com.android.os.statsd": []string{ + "android.app", + "android.os", + "android.util", + "com.android.internal.statsd", + "com.android.server.stats", + }, + "com.android.wifi": []string{ + "com.android.server.wifi", + "com.android.wifi.x", + "android.hardware.wifi", + "android.net.wifi", + }, + "com.android.tethering": []string{ + "android.net", + }, + } +} |