diff options
Diffstat (limited to 'apex/apex.go')
| -rw-r--r-- | apex/apex.go | 236 |
1 files changed, 197 insertions, 39 deletions
diff --git a/apex/apex.go b/apex/apex.go index 1267ec758..8e35e07c0 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -26,6 +26,7 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" + "android/soong/bpf" "android/soong/cc" prebuilt_etc "android/soong/etc" "android/soong/java" @@ -41,6 +42,9 @@ const ( imageApexType = "image" zipApexType = "zip" flattenedApexType = "flattened" + + ext4FsType = "ext4" + f2fsFsType = "f2fs" ) type dependencyTag struct { @@ -63,6 +67,7 @@ var ( usesTag = dependencyTag{name: "uses"} androidAppTag = dependencyTag{name: "androidApp", payload: true} rroTag = dependencyTag{name: "rro", payload: true} + bpfTag = dependencyTag{name: "bpf", payload: true} apexAvailBaseline = makeApexAvailableBaseline() @@ -95,6 +100,13 @@ func makeApexAvailableBaseline() 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", @@ -177,6 +189,19 @@ func makeApexAvailableBaseline() map[string][]string { // // 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", @@ -292,7 +317,6 @@ func makeApexAvailableBaseline() map[string][]string { "libpdx_headers", "libpdx_uds", "libprocinfo", - "libsonivox", "libspeexresampler", "libspeexresampler", "libstagefright_esds", @@ -329,6 +353,7 @@ func makeApexAvailableBaseline() map[string][]string { "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", @@ -341,6 +366,7 @@ func makeApexAvailableBaseline() map[string][]string { "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", @@ -434,6 +460,7 @@ func makeApexAvailableBaseline() map[string][]string { "libpdx_headers", "libscudo_wrapper", "libsfplugin_ccodec_utils", + "libspeexresampler", "libstagefright_amrnb_common", "libstagefright_amrnbdec", "libstagefright_amrnbenc", @@ -476,6 +503,8 @@ func makeApexAvailableBaseline() map[string][]string { // Module separator // m["com.android.permission"] = []string{ + "car-ui-lib", + "iconloader", "kotlin-annotations", "kotlin-stdlib", "kotlin-stdlib-jdk7", @@ -485,6 +514,17 @@ func makeApexAvailableBaseline() map[string][]string { "kotlinx-coroutines-core", "kotlinx-coroutines-core-nodeps", "permissioncontroller-statsd", + "GooglePermissionController", + "PermissionController", + "SettingsLibActionBarShadow", + "SettingsLibAppPreference", + "SettingsLibBarChartPreference", + "SettingsLibLayoutPreference", + "SettingsLibProgressBar", + "SettingsLibSearchWidget", + "SettingsLibSettingsTheme", + "SettingsLibRestrictedLockUtils", + "SettingsLibHelpUtils", } // // Module separator @@ -643,6 +683,55 @@ func makeApexAvailableBaseline() map[string][]string { 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) @@ -660,6 +749,24 @@ func init() { sort.Strings(*apexFileContextsInfos) ctx.Strict("APEX_FILE_CONTEXTS_INFOS", strings.Join(*apexFileContextsInfos, " ")) }) + + 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) { @@ -669,6 +776,7 @@ func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) { func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) { ctx.TopDown("apex_deps", apexDepsMutator).Parallel() + ctx.BottomUp("apex_unique", apexUniqueVariationsMutator).Parallel() ctx.BottomUp("apex", apexMutator).Parallel() ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel() ctx.BottomUp("apex_uses", apexUsesMutator).Parallel() @@ -688,7 +796,9 @@ func apexDepsMutator(mctx android.TopDownMutatorContext) { apexInfo := android.ApexInfo{ ApexVariationName: mctx.ModuleName(), MinSdkVersion: a.minSdkVersion(mctx), + RequiredSdks: a.RequiredSdks(), Updatable: a.Updatable(), + InApexes: []string{mctx.ModuleName()}, } useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface()) @@ -721,6 +831,17 @@ func apexDepsMutator(mctx android.TopDownMutatorContext) { }) } +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. + am.UpdateUniqueApexVariationsForDeps(mctx) + } +} + // 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 @@ -733,18 +854,6 @@ func markPlatformAvailability(mctx android.BottomUpMutatorContext) { if am, ok := mctx.Module().(android.ApexModule); ok { availableToPlatform := am.AvailableFor(android.AvailableToPlatform) - // In a rare case when a lib is marked as available only to an apex - // but the apex doesn't exist. This can happen in a partial manifest branch - // like master-art. Currently, libstatssocket in the stats APEX is causing - // this problem. - // Include the lib in platform because the module SDK that ought to provide - // it doesn't exist, so it would otherwise be left out completely. - // TODO(b/154888298) remove this by adding those libraries in module SDKS and skipping - // this check for libraries provided by SDKs. - if !availableToPlatform && !android.InAnyApex(am.Name()) { - availableToPlatform = true - } - // 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) { @@ -956,6 +1065,9 @@ type apexBundleProperties struct { // List of prebuilt files that are embedded inside this APEX bundle Prebuilts []string + // List of BPF programs inside APEX + Bpfs []string + // Name of the apex_key module that provides the private key to sign APEX Key *string @@ -1026,6 +1138,10 @@ type apexBundleProperties struct { // Should be only used in non-system apexes (e.g. vendor: true). // Default is false. Use_vndk_as_stable *bool + + // The type of filesystem to use for an image apex. Either 'ext4' or 'f2fs'. + // Default 'ext4'. + Payload_fs_type *string } type apexTargetBundleProperties struct { @@ -1175,6 +1291,8 @@ type apexFile struct { overriddenPackageName string // only for apps isJniLib bool + + noticeFiles android.Paths } func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, androidMkModuleName string, installDir string, class apexFileClass, module android.Module) apexFile { @@ -1190,6 +1308,7 @@ func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, androidM ret.requiredModuleNames = module.RequiredModuleNames() ret.targetRequiredModuleNames = module.TargetRequiredModuleNames() ret.hostRequiredModuleNames = module.HostRequiredModuleNames() + ret.noticeFiles = module.NoticeFiles() } return ret } @@ -1233,6 +1352,24 @@ 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 @@ -1298,6 +1435,8 @@ type apexBundle struct { // Optional list of lint report zip files for apexes that contain java or app modules lintReports android.Paths + + payloadFsType fsType } func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, @@ -1307,26 +1446,26 @@ func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, // conflicting variations with this module. This is required since // arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64' // for native shared libs. - ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ - {Mutator: "image", Variation: imageVariation}, - {Mutator: "link", Variation: "shared"}, - {Mutator: "version", Variation: ""}, // "" is the non-stub variant - }...), sharedLibTag, nativeModules.Native_shared_libs...) - ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ - {Mutator: "image", Variation: imageVariation}, - {Mutator: "link", Variation: "shared"}, - {Mutator: "version", Variation: ""}, // "" is the non-stub variant - }...), jniLibTag, nativeModules.Jni_libs...) + binVariations := target.Variations() + libVariations := append(target.Variations(), + blueprint.Variation{Mutator: "link", Variation: "shared"}) + + if ctx.Device() { + binVariations = append(binVariations, + blueprint.Variation{Mutator: "image", Variation: imageVariation}) + libVariations = append(libVariations, + blueprint.Variation{Mutator: "image", Variation: imageVariation}, + blueprint.Variation{Mutator: "version", Variation: ""}) // "" is the non-stub variant + } + + ctx.AddFarVariationDependencies(libVariations, sharedLibTag, nativeModules.Native_shared_libs...) - ctx.AddFarVariationDependencies(append(target.Variations(), - blueprint.Variation{Mutator: "image", Variation: imageVariation}), - executableTag, nativeModules.Binaries...) + ctx.AddFarVariationDependencies(libVariations, jniLibTag, nativeModules.Jni_libs...) - ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ - {Mutator: "image", Variation: imageVariation}, - {Mutator: "test_per_src", Variation: ""}, // "" is the all-tests variant - }...), testTag, nativeModules.Tests...) + ctx.AddFarVariationDependencies(binVariations, executableTag, nativeModules.Binaries...) + + ctx.AddFarVariationDependencies(binVariations, testTag, nativeModules.Tests...) } func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) { @@ -1444,6 +1583,9 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), javaLibTag, a.properties.Java_libs...) + ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), + bpfTag, a.properties.Bpfs...) + // With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library. if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(), @@ -1711,7 +1853,7 @@ func apexFileForJavaLibrary(ctx android.BaseModuleContext, module javaModule) ap } func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, depName string) apexFile { - dirInApex := filepath.Join("etc", prebuilt.SubDir()) + dirInApex := filepath.Join(prebuilt.BaseDir(), prebuilt.SubDir()) fileToCopy := prebuilt.OutputFile() return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt) } @@ -1764,6 +1906,11 @@ 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") + return newApexFile(ctx, builtFile, builtFile.Base(), dirInApex, etc, bpfProgram) +} + // Context "decorator", overriding the InstallBypassMake method to always reply `true`. type flattenedApexContext struct { android.ModuleContext @@ -1797,7 +1944,7 @@ func (a *apexBundle) WalkPayloadDeps(ctx android.ModuleContext, do android.Paylo } // Check for the indirect dependencies if it is considered as part of the APEX - if am.ApexVariationName() != "" { + if android.InList(ctx.ModuleName(), am.InApexes()) { return do(ctx, parent, am, false /* externalDep */) } @@ -1922,13 +2069,6 @@ func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext return false } - // TODO(jiyong) remove this check when R is published to AOSP. Currently, libstatssocket - // is capable of providing a stub variant, but is being statically linked from the bluetooth - // APEX. - if toName == "libstatssocket" { - return false - } - // The dynamic linker and crash_dump tool in the runtime APEX is the only exception to this rule. // It can't make the static dependencies dynamic because it can't // do the dynamic linking for itself. @@ -2099,6 +2239,15 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { } else { ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay module", depName) } + case bpfTag: + if bpfProgram, ok := child.(bpf.BpfModule); ok { + filesToCopy, _ := bpfProgram.OutputFiles("") + for _, bpfFile := range filesToCopy { + filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, bpfProgram)) + } + } else { + ctx.PropertyErrorf("bpfs", "%q is not a bpf module", depName) + } case prebuiltTag: if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok { filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName)) @@ -2270,6 +2419,15 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.installDir = android.PathForModuleInstall(ctx, "apex") a.filesInfo = filesInfo + switch proptools.StringDefault(a.properties.Payload_fs_type, ext4FsType) { + case ext4FsType: + a.payloadFsType = ext4 + case f2fsFsType: + a.payloadFsType = f2fs + default: + ctx.PropertyErrorf("payload_fs_type", "%q is not a valid filesystem for apex [ext4, f2fs]", *a.properties.Payload_fs_type) + } + // Optimization. If we are building bundled APEX, for the files that are gathered due to the // transitive dependencies, don't place them inside the APEX, but place a symlink pointing // the same library in the system partition, thus effectively sharing the same libraries |