diff options
Diffstat (limited to 'apex/apex.go')
-rw-r--r-- | apex/apex.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/apex/apex.go b/apex/apex.go index d7dc6d718..d3e7eee9d 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -29,6 +29,7 @@ import ( "android/soong/android" "android/soong/bpf" "android/soong/cc" + "android/soong/dexpreopt" prebuilt_etc "android/soong/etc" "android/soong/filesystem" "android/soong/java" @@ -1919,6 +1920,32 @@ func (vctx *visitorContext) normalizeFileInfo(mctx android.ModuleContext) { }) } +// enforcePartitionTagOnApexSystemServerJar checks that the partition tags of an apex system server jar matches +// the partition tags of the top-level apex. +// e.g. if the top-level apex sets system_ext_specific to true, the javalib must set this property to true as well. +// This check ensures that the dexpreopt artifacts of the apex system server jar is installed in the same partition +// as the apex. +func (a *apexBundle) enforcePartitionTagOnApexSystemServerJar(ctx android.ModuleContext) { + global := dexpreopt.GetGlobalConfig(ctx) + ctx.VisitDirectDepsWithTag(sscpfTag, func(child android.Module) { + info, ok := android.OtherModuleProvider(ctx, child, java.LibraryNameToPartitionInfoProvider) + if !ok { + ctx.ModuleErrorf("Could not find partition info of apex system server jars.") + } + apexPartition := ctx.Module().PartitionTag(ctx.DeviceConfig()) + for javalib, javalibPartition := range info.LibraryNameToPartition { + if !global.AllApexSystemServerJars(ctx).ContainsJar(javalib) { + continue // not an apex system server jar + } + if apexPartition != javalibPartition { + ctx.ModuleErrorf(` +%s is an apex systemserver jar, but its partition does not match the partition of its containing apex. Expected %s, Got %s`, + javalib, apexPartition, javalibPartition) + } + } + }) +} + func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, child, parent android.Module) bool { depTag := ctx.OtherModuleDependencyTag(child) if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok { @@ -2341,6 +2368,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.required = append(a.required, a.VintfFragmentModuleNames(ctx)...) a.setOutputFiles(ctx) + a.enforcePartitionTagOnApexSystemServerJar(ctx) } // Set prebuiltInfoProvider. This will be used by `apex_prebuiltinfo_singleton` to print out a metadata file |