summaryrefslogtreecommitdiff
path: root/apex
diff options
context:
space:
mode:
Diffstat (limited to 'apex')
-rw-r--r--apex/aconfig_test.go3
-rw-r--r--apex/apex.go69
-rw-r--r--apex/apex_test.go80
-rw-r--r--apex/builder.go6
-rw-r--r--apex/container_test.go6
-rw-r--r--apex/prebuilt.go16
6 files changed, 122 insertions, 58 deletions
diff --git a/apex/aconfig_test.go b/apex/aconfig_test.go
index 76227a9ab..0eb8ef479 100644
--- a/apex/aconfig_test.go
+++ b/apex/aconfig_test.go
@@ -60,6 +60,7 @@ func TestValidationAcrossContainersExportedPass(t *testing.T) {
apex_available: [
"myapex",
],
+ compile_dex: true,
}
aconfig_declarations {
name: "my_aconfig_declarations_foo",
@@ -339,6 +340,7 @@ func TestValidationAcrossContainersNotExportedFail(t *testing.T) {
apex_available: [
"myapex",
],
+ compile_dex: true,
}
aconfig_declarations {
name: "my_aconfig_declarations_foo",
@@ -761,6 +763,7 @@ func TestValidationNotPropagateAcrossShared(t *testing.T) {
apex_available: [
"myapex",
],
+ compile_dex: true,
}
java_library {
name: "my_java_library_foo",
diff --git a/apex/apex.go b/apex/apex.go
index dc24df3d1..0e40d7c0e 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -67,7 +67,6 @@ func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
// it should create a platform variant.
ctx.BottomUp("mark_platform_availability", markPlatformAvailability)
ctx.Transition("apex", &apexTransitionMutator{})
- ctx.BottomUp("apex_directly_in_any", apexDirectlyInAnyMutator).MutatesDependencies()
}
type apexBundleProperties struct {
@@ -435,6 +434,7 @@ type apexBundle struct {
archProperties apexArchBundleProperties
overridableProperties overridableProperties
vndkProperties apexVndkProperties // only for apex_vndk modules
+ testProperties apexTestProperties // only for apex_test modules
///////////////////////////////////////////////////////////////////////////////////////////
// Inputs
@@ -993,25 +993,7 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) {
return true
}
- // Records whether a certain module is included in this apexBundle via direct dependency or
- // inndirect dependency.
- contents := make(map[string]android.ApexMembership)
- mctx.WalkDeps(func(child, parent android.Module) bool {
- if !continueApexDepsWalk(child, parent) {
- return false
- }
- // If the parent is apexBundle, this child is directly depended.
- _, directDep := parent.(*apexBundle)
- depName := mctx.OtherModuleName(child)
- contents[depName] = contents[depName].Add(directDep)
- return true
- })
-
- // The membership information is saved for later access
- apexContents := android.NewApexContents(contents)
- android.SetProvider(mctx, android.ApexBundleInfoProvider, android.ApexBundleInfo{
- Contents: apexContents,
- })
+ android.SetProvider(mctx, android.ApexBundleInfoProvider, android.ApexBundleInfo{})
minSdkVersion := a.minSdkVersion(mctx)
// When min_sdk_version is not set, the apex is built against FutureApiLevel.
@@ -1039,8 +1021,6 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) {
Updatable: a.Updatable(),
UsePlatformApis: a.UsePlatformApis(),
InApexVariants: []string{apexVariationName},
- InApexModules: []string{a.Name()}, // could be com.mycompany.android.foo
- ApexContents: []*android.ApexContents{apexContents},
TestApexes: testApexes,
BaseApexName: mctx.ModuleName(),
ApexAvailableName: proptools.String(a.properties.Apex_available_name),
@@ -1242,14 +1222,6 @@ func apexModuleTypeRequiresVariant(module ApexInfoMutator) bool {
return true
}
-// See android.UpdateDirectlyInAnyApex
-// TODO(jiyong): move this to android/apex.go?
-func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) {
- if am, ok := mctx.Module().(android.ApexModule); ok {
- android.UpdateDirectlyInAnyApex(mctx, am)
- }
-}
-
const (
// File extensions of an APEX for different packaging methods
imageApexSuffix = ".apex"
@@ -1325,6 +1297,23 @@ func (a *apexBundle) UsePlatformApis() bool {
return proptools.BoolDefault(a.properties.Platform_apis, false)
}
+type apexValidationType int
+
+const (
+ hostApexVerifier apexValidationType = iota
+ apexSepolicyTests
+)
+
+func (a *apexBundle) skipValidation(validationType apexValidationType) bool {
+ switch validationType {
+ case hostApexVerifier:
+ return proptools.Bool(a.testProperties.Skip_validations.Host_apex_verifier)
+ case apexSepolicyTests:
+ return proptools.Bool(a.testProperties.Skip_validations.Apex_sepolicy_tests)
+ }
+ panic("Unknown validation type")
+}
+
// 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 {
@@ -1752,7 +1741,8 @@ func (a *apexBundle) setSystemLibLink(ctx android.ModuleContext) {
}
func (a *apexBundle) setPayloadFsType(ctx android.ModuleContext) {
- switch proptools.StringDefault(a.properties.Payload_fs_type, ext4FsType) {
+ defaultFsType := ctx.Config().DefaultApexPayloadType()
+ switch proptools.StringDefault(a.properties.Payload_fs_type, defaultFsType) {
case ext4FsType:
a.payloadFsType = ext4
case f2fsFsType:
@@ -2082,7 +2072,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
//
// Skip the dependency in unbundled builds where the device image is not
// being built.
- if ch.IsStubsImplementationRequired() && !am.DirectlyInAnyApex() && !ctx.Config().UnbundledBuild() {
+ if ch.IsStubsImplementationRequired() && !am.NotInPlatform() && !ctx.Config().UnbundledBuild() {
// we need a module name for Make
name := ch.ImplementationModuleNameForMake(ctx) + ch.Properties.SubName
if !android.InList(name, a.makeModulesToInstall) {
@@ -2179,8 +2169,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
ctx.PropertyErrorf("systemserverclasspath_fragments",
"systemserverclasspath_fragment content %q of type %q is not supported", depName, ctx.OtherModuleType(child))
}
- } else if _, ok := depTag.(android.CopyDirectlyInAnyApexTag); ok {
- // nothing
} else if depTag == android.DarwinUniversalVariantTag {
// nothing
} else if depTag == android.RequiredDepTag {
@@ -2457,10 +2445,14 @@ func newApexBundle() *apexBundle {
return module
}
-func ApexBundleFactory(testApex bool) android.Module {
- bundle := newApexBundle()
- bundle.testApex = testApex
- return bundle
+type apexTestProperties struct {
+ // Boolean flags for validation checks. Test APEXes can turn on/off individual checks.
+ Skip_validations struct {
+ // Skips `Apex_sepolicy_tests` check if true
+ Apex_sepolicy_tests *bool
+ // Skips `Host_apex_verifier` check if true
+ Host_apex_verifier *bool
+ }
}
// apex_test is an APEX for testing. The difference from the ordinary apex module type is that
@@ -2468,6 +2460,7 @@ func ApexBundleFactory(testApex bool) android.Module {
func TestApexBundleFactory() android.Module {
bundle := newApexBundle()
bundle.testApex = true
+ bundle.AddProperties(&bundle.testProperties)
return bundle
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index d0494d67d..6e9295911 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -495,6 +495,7 @@ func TestBasicApex(t *testing.T) {
"//apex_available:platform",
"myapex",
],
+ compile_dex: true,
}
dex_import {
@@ -664,6 +665,7 @@ func TestDefaults(t *testing.T) {
sdk_version: "none",
system_modules: "none",
apex_available: [ "myapex" ],
+ compile_dex: true,
}
android_app {
@@ -2035,6 +2037,7 @@ func TestApexMinSdkVersion_SupportsCodeNames_JavaLibs(t *testing.T) {
apex_available: [ "myapex" ],
sdk_version: "current",
min_sdk_version: "S", // should be okay
+ compile_dex: true,
}
`,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
@@ -2584,6 +2587,7 @@ func TestApexMinSdkVersion_ErrorIfIncompatibleVersion(t *testing.T) {
"myapex",
],
min_sdk_version: "30",
+ compile_dex: true,
}
`)
@@ -2611,6 +2615,7 @@ func TestApexMinSdkVersion_ErrorIfIncompatibleVersion(t *testing.T) {
// Compile against core API surface
sdk_version: "core_current",
min_sdk_version: "30",
+ compile_dex: true,
}
`)
@@ -2658,6 +2663,7 @@ func TestApexMinSdkVersion_Okay(t *testing.T) {
],
apex_available: ["myapex"],
min_sdk_version: "29",
+ compile_dex: true,
}
java_library {
@@ -2737,6 +2743,7 @@ func TestJavaStableSdkVersion(t *testing.T) {
srcs: ["foo/bar/MyClass.java"],
sdk_version: "test_current",
apex_available: ["myapex"],
+ compile_dex: true,
}
`,
},
@@ -2761,6 +2768,7 @@ func TestJavaStableSdkVersion(t *testing.T) {
sdk_version: "current",
apex_available: ["myapex"],
min_sdk_version: "29",
+ compile_dex: true,
}
`,
},
@@ -2784,6 +2792,7 @@ func TestJavaStableSdkVersion(t *testing.T) {
srcs: ["foo/bar/MyClass.java"],
sdk_version: "test_current",
apex_available: ["myapex"],
+ compile_dex: true,
}
`,
},
@@ -2807,6 +2816,7 @@ func TestJavaStableSdkVersion(t *testing.T) {
srcs: ["foo/bar/MyClass.java"],
sdk_version: "core_platform",
apex_available: ["myapex"],
+ compile_dex: true,
}
`,
preparer: java.FixtureUseLegacyCorePlatformApi("myjar-uses-legacy"),
@@ -2835,6 +2845,7 @@ func TestJavaStableSdkVersion(t *testing.T) {
sdk_version: "current",
apex_available: ["myapex"],
static_libs: ["transitive-jar"],
+ compile_dex: true,
}
java_library {
name: "transitive-jar",
@@ -5913,6 +5924,7 @@ func TestErrorsIfDepsAreNotEnabled(t *testing.T) {
system_modules: "none",
enabled: false,
apex_available: ["myapex"],
+ compile_dex: true,
}
`)
}
@@ -7089,6 +7101,51 @@ func TestApexAvailable_PrefixMatch(t *testing.T) {
`)
}
+func TestApexValidation_TestApexCanSkipInitRcCheck(t *testing.T) {
+ t.Parallel()
+ ctx := testApex(t, `
+ apex_test {
+ name: "myapex",
+ key: "myapex.key",
+ skip_validations: {
+ host_apex_verifier: true,
+ },
+ updatable: false,
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ `)
+
+ validations := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("signapk").Validations.Strings()
+ if android.SuffixInList(validations, "host_apex_verifier.timestamp") {
+ t.Error("should not run host_apex_verifier")
+ }
+}
+
+func TestApexValidation_TestApexCheckInitRc(t *testing.T) {
+ t.Parallel()
+ ctx := testApex(t, `
+ apex_test {
+ name: "myapex",
+ key: "myapex.key",
+ updatable: false,
+ }
+ apex_key {
+ name: "myapex.key",
+ public_key: "testkey.avbpubkey",
+ private_key: "testkey.pem",
+ }
+ `)
+
+ validations := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("signapk").Validations.Strings()
+ if !android.SuffixInList(validations, "host_apex_verifier.timestamp") {
+ t.Error("should run host_apex_verifier")
+ }
+}
+
func TestOverrideApex(t *testing.T) {
t.Parallel()
ctx := testApex(t, `
@@ -7525,6 +7582,7 @@ func TestJavaSDKLibrary_WithinApex(t *testing.T) {
apex_available: ["myapex"],
sdk_version: "none",
system_modules: "none",
+ compile_dex: true,
}
java_library {
@@ -7534,6 +7592,7 @@ func TestJavaSDKLibrary_WithinApex(t *testing.T) {
apex_available: ["myapex"],
sdk_version: "none",
system_modules: "none",
+ compile_dex: true,
}
prebuilt_apis {
@@ -7643,6 +7702,7 @@ func TestJavaSDKLibrary_ImportPreferred(t *testing.T) {
apex_available: ["myapex"],
sdk_version: "none",
system_modules: "none",
+ compile_dex: true,
}
`),
"source/a.java": nil,
@@ -7664,6 +7724,7 @@ func TestJavaSDKLibrary_ImportPreferred(t *testing.T) {
public: {
enabled: true,
},
+ compile_dex: true,
}
`),
"prebuilt/a.jar": nil,
@@ -7680,6 +7741,7 @@ func TestJavaSDKLibrary_ImportPreferred(t *testing.T) {
public: {
jars: ["a.jar"],
},
+ compile_dex: true,
}
`),
}), withFiles(filesForSdkLibrary),
@@ -7758,6 +7820,7 @@ func TestCompatConfig(t *testing.T) {
sdk_version: "none",
system_modules: "none",
apex_available: [ "myapex" ],
+ compile_dex: true,
}
// Make sure that a preferred prebuilt does not affect the apex contents.
@@ -7997,6 +8060,7 @@ func TestSymlinksFromApexToSystem(t *testing.T) {
"//apex_available:platform",
],
min_sdk_version: "33",
+ compile_dex: true,
}
java_library {
@@ -8605,6 +8669,7 @@ func TestApexPermittedPackagesRules(t *testing.T) {
apex_available: ["myapex"],
sdk_version: "none",
system_modules: "none",
+ compile_dex: true,
}
java_library {
name: "nonbcp_lib2",
@@ -8613,6 +8678,7 @@ func TestApexPermittedPackagesRules(t *testing.T) {
permitted_packages: ["a.b"],
sdk_version: "none",
system_modules: "none",
+ compile_dex: true,
}
apex {
name: "myapex",
@@ -8638,6 +8704,7 @@ func TestApexPermittedPackagesRules(t *testing.T) {
permitted_packages: ["foo.bar"],
sdk_version: "none",
system_modules: "none",
+ compile_dex: true,
}
java_library {
name: "bcp_lib2",
@@ -8646,6 +8713,7 @@ func TestApexPermittedPackagesRules(t *testing.T) {
permitted_packages: ["foo.bar", "bar.baz"],
sdk_version: "none",
system_modules: "none",
+ compile_dex: true,
}
apex {
name: "myapex",
@@ -8676,6 +8744,7 @@ func TestApexPermittedPackagesRules(t *testing.T) {
sdk_version: "none",
min_sdk_version: "29",
system_modules: "none",
+ compile_dex: true,
}
java_library {
name: "bcp_lib_unrestricted",
@@ -8685,6 +8754,7 @@ func TestApexPermittedPackagesRules(t *testing.T) {
sdk_version: "none",
min_sdk_version: "29",
system_modules: "none",
+ compile_dex: true,
}
apex {
name: "myapex",
@@ -9834,6 +9904,7 @@ func TestApexStrictUpdtabilityLint(t *testing.T) {
},
sdk_version: "current",
min_sdk_version: "29",
+ compile_dex: true,
}
`
fs := android.MockFS{
@@ -10268,6 +10339,7 @@ func TestAconfigFilesJavaDeps(t *testing.T) {
apex_available: [
"myapex",
],
+ compile_dex: true,
}
java_library {
@@ -10279,6 +10351,7 @@ func TestAconfigFilesJavaDeps(t *testing.T) {
apex_available: [
"myapex",
],
+ compile_dex: true,
}
aconfig_declarations {
@@ -10365,6 +10438,7 @@ func TestAconfigFilesJavaAndCcDeps(t *testing.T) {
apex_available: [
"myapex",
],
+ compile_dex: true,
}
cc_library {
@@ -10691,6 +10765,7 @@ func TestAconfigFilesOnlyMatchCurrentApex(t *testing.T) {
apex_available: [
"myapex",
],
+ compile_dex: true,
}
java_library {
@@ -10702,6 +10777,7 @@ func TestAconfigFilesOnlyMatchCurrentApex(t *testing.T) {
apex_available: [
"myapex",
],
+ compile_dex: true,
}
aconfig_declarations {
@@ -10776,6 +10852,7 @@ func TestAconfigFilesRemoveDuplicates(t *testing.T) {
apex_available: [
"myapex",
],
+ compile_dex: true,
}
java_library {
@@ -10787,6 +10864,7 @@ func TestAconfigFilesRemoveDuplicates(t *testing.T) {
apex_available: [
"myapex",
],
+ compile_dex: true,
}
aconfig_declarations {
@@ -11469,6 +11547,7 @@ func TestApexMinSdkVersionOverride(t *testing.T) {
apex_available: ["com.android.apex30"],
min_sdk_version: "30",
sdk_version: "current",
+ compile_dex: true,
}
override_apex {
@@ -11760,6 +11839,7 @@ func TestSdkLibraryTransitiveClassLoaderContext(t *testing.T) {
"com.android.foo30",
],
sdk_version: "core_current",
+ compile_dex: true,
}
java_library {
diff --git a/apex/builder.go b/apex/builder.go
index d0acc8d6c..e5ae10622 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -924,14 +924,14 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
var validations android.Paths
validations = append(validations, runApexLinkerconfigValidation(ctx, unsignedOutputFile, imageDir))
// TODO(b/279688635) deapexer supports [ext4]
- if !a.testApex && suffix == imageApexSuffix && ext4 == a.payloadFsType {
+ if !a.skipValidation(apexSepolicyTests) && suffix == imageApexSuffix && ext4 == a.payloadFsType {
validations = append(validations, runApexSepolicyTests(ctx, unsignedOutputFile))
}
if !a.testApex && len(a.properties.Unwanted_transitive_deps) > 0 {
validations = append(validations,
runApexElfCheckerUnwanted(ctx, unsignedOutputFile, a.properties.Unwanted_transitive_deps))
}
- if !a.testApex && android.InList(a.payloadFsType, []fsType{ext4, erofs}) {
+ if !a.skipValidation(hostApexVerifier) && android.InList(a.payloadFsType, []fsType{ext4, erofs}) {
validations = append(validations, runApexHostVerifier(ctx, a, unsignedOutputFile))
}
ctx.Build(pctx, android.BuildParams{
@@ -1220,7 +1220,7 @@ func runApexLinkerconfigValidation(ctx android.ModuleContext, apexFile android.P
// $ deapexer list -Z {apex_file} > {file_contexts}
// $ apex_sepolicy_tests -f {file_contexts}
func runApexSepolicyTests(ctx android.ModuleContext, apexFile android.Path) android.Path {
- timestamp := android.PathForModuleOut(ctx, "sepolicy_tests.timestamp")
+ timestamp := android.PathForModuleOut(ctx, "apex_sepolicy_tests.timestamp")
ctx.Build(pctx, android.BuildParams{
Rule: apexSepolicyTestsRule,
Input: apexFile,
diff --git a/apex/container_test.go b/apex/container_test.go
index d1dfb9cab..395793f61 100644
--- a/apex/container_test.go
+++ b/apex/container_test.go
@@ -15,10 +15,11 @@
package apex
import (
- "android/soong/android"
- "android/soong/java"
"fmt"
"testing"
+
+ "android/soong/android"
+ "android/soong/java"
)
var checkContainerMatch = func(t *testing.T, name string, container string, expected bool, actual bool) {
@@ -329,6 +330,7 @@ func TestUpdatableAndNonUpdatableApexesIdenticalMinSdkVersion(t *testing.T) {
],
min_sdk_version: "30",
sdk_version: "current",
+ compile_dex: true,
}
`)
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index acf3b91fe..f93eada8b 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -306,10 +306,6 @@ func (p *prebuiltCommon) DepIsInSameApex(ctx android.BaseModuleContext, dep andr
// extra copying of files. Contrast that with source apex modules that has to build each variant
// from source.
func (p *prebuiltCommon) apexInfoMutator(mctx android.TopDownMutatorContext) {
-
- // Collect direct dependencies into contents.
- contents := make(map[string]android.ApexMembership)
-
// Collect the list of dependencies.
var dependencies []android.ApexModule
mctx.WalkDeps(func(child, parent android.Module) bool {
@@ -347,29 +343,19 @@ func (p *prebuiltCommon) apexInfoMutator(mctx android.TopDownMutatorContext) {
// behavior whether there is a corresponding source module present or not.
depName = android.RemoveOptionalPrebuiltPrefix(depName)
- // Remember if this module was added as a direct dependency.
- direct := parent == mctx.Module()
- contents[depName] = contents[depName].Add(direct)
-
// Add the module to the list of dependencies that need to have an APEX variant.
dependencies = append(dependencies, child.(android.ApexModule))
return true
})
- // Create contents for the prebuilt_apex and store it away for later use.
- apexContents := android.NewApexContents(contents)
- android.SetProvider(mctx, android.ApexBundleInfoProvider, android.ApexBundleInfo{
- Contents: apexContents,
- })
+ android.SetProvider(mctx, android.ApexBundleInfoProvider, android.ApexBundleInfo{})
// Create an ApexInfo for the prebuilt_apex.
apexVariationName := p.ApexVariationName()
apexInfo := android.ApexInfo{
ApexVariationName: apexVariationName,
InApexVariants: []string{apexVariationName},
- InApexModules: []string{p.BaseModuleName()}, // BaseModuleName() to avoid the prebuilt_ prefix.
- ApexContents: []*android.ApexContents{apexContents},
ForPrebuiltApex: true,
}