summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/aar.go6
-rw-r--r--java/androidmk.go49
-rwxr-xr-xjava/app.go25
-rw-r--r--java/dexpreopt.go2
-rw-r--r--java/dexpreopt_bootjars.go13
-rw-r--r--java/hiddenapi_singleton.go7
-rw-r--r--java/java.go34
-rw-r--r--java/lint.go11
-rw-r--r--java/sdk_library.go34
9 files changed, 108 insertions, 73 deletions
diff --git a/java/aar.go b/java/aar.go
index 9cab0bdca..8d2a74ad1 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -477,6 +477,8 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
a.aapt.buildActions(ctx, sdkContext(a))
a.exportedSdkLibs = a.aapt.sdkLibraries
+ a.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
+
ctx.CheckbuildFile(a.proguardOptionsFile)
ctx.CheckbuildFile(a.exportPackage)
ctx.CheckbuildFile(a.aaptSrcJar)
@@ -569,6 +571,8 @@ type AARImport struct {
manifest android.WritablePath
exportedStaticPackages android.Paths
+
+ hideApexVariantFromMake bool
}
func (a *AARImport) sdkVersion() sdkSpec {
@@ -662,6 +666,8 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
return
}
+ a.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
+
aarName := ctx.ModuleName() + ".aar"
var aar android.Path
aar = android.PathForModuleSrc(ctx, a.properties.Aars[0])
diff --git a/java/androidmk.go b/java/androidmk.go
index 65c44a329..f72ee3760 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -23,8 +23,7 @@ import (
func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries {
hostDexNeeded := Bool(library.deviceProperties.Hostdex) && !library.Host()
- if !library.IsForPlatform() {
- // Don't emit hostdex modules from the APEX variants
+ if library.hideApexVariantFromMake {
hostDexNeeded = false
}
@@ -61,22 +60,15 @@ func (library *Library) AndroidMkEntriesHostDex() android.AndroidMkEntries {
func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
var entriesList []android.AndroidMkEntries
- mainEntries := android.AndroidMkEntries{Disabled: true}
-
- // For a java library built for an APEX, we don't need Make module
- hideFromMake := !library.IsForPlatform()
- // If not available for platform, don't emit to make.
- if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
- hideFromMake = true
- }
- if hideFromMake {
- // May still need to add some additional dependencies. This will be called
- // once for the platform variant (even if it is not being used) and once each
- // for the APEX specific variants. In order to avoid adding the dependency
- // multiple times only add it for the platform variant.
+ if library.hideApexVariantFromMake {
+ // For a java library built for an APEX we don't need Make module
+ entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
+ } else if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
+ // Platform variant. If not available for the platform, we don't need Make module.
+ // May still need to add some additional dependencies.
checkedModulePaths := library.additionalCheckedModules
- if library.IsForPlatform() && len(checkedModulePaths) != 0 {
- mainEntries = android.AndroidMkEntries{
+ if len(checkedModulePaths) != 0 {
+ entriesList = append(entriesList, android.AndroidMkEntries{
Class: "FAKE",
// Need at least one output file in order for this to take effect.
OutputFile: android.OptionalPathForPath(checkedModulePaths[0]),
@@ -86,10 +78,12 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", checkedModulePaths.Strings()...)
},
},
- }
+ })
+ } else {
+ entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
}
} else {
- mainEntries = android.AndroidMkEntries{
+ entriesList = append(entriesList, android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
DistFiles: library.distFiles,
OutputFile: android.OptionalPathForPath(library.outputFile),
@@ -134,12 +128,11 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
entries.SetOptionalPaths("LOCAL_SOONG_LINT_REPORTS", library.linter.reports)
},
},
- }
+ })
}
- hostDexEntries := library.AndroidMkEntriesHostDex()
+ entriesList = append(entriesList, library.AndroidMkEntriesHostDex())
- entriesList = append(entriesList, mainEntries, hostDexEntries)
return entriesList
}
@@ -189,7 +182,7 @@ func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
}
func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
- if !prebuilt.IsForPlatform() || !prebuilt.ContainingSdk().Unversioned() {
+ if prebuilt.hideApexVariantFromMake || !prebuilt.ContainingSdk().Unversioned() {
return []android.AndroidMkEntries{android.AndroidMkEntries{
Disabled: true,
}}
@@ -211,7 +204,7 @@ func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
}
func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
- if !prebuilt.IsForPlatform() {
+ if prebuilt.hideApexVariantFromMake {
return []android.AndroidMkEntries{android.AndroidMkEntries{
Disabled: true,
}}
@@ -239,7 +232,7 @@ func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
}
func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
- if !prebuilt.IsForPlatform() {
+ if prebuilt.hideApexVariantFromMake {
return []android.AndroidMkEntries{{
Disabled: true,
}}
@@ -309,7 +302,7 @@ func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
}
func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
- if !app.IsForPlatform() || app.appProperties.HideFromMake {
+ if app.hideApexVariantFromMake || app.appProperties.HideFromMake {
return []android.AndroidMkEntries{android.AndroidMkEntries{
Disabled: true,
}}
@@ -458,7 +451,7 @@ func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
}
func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
- if !a.IsForPlatform() {
+ if a.hideApexVariantFromMake {
return []android.AndroidMkEntries{{
Disabled: true,
}}
@@ -638,7 +631,7 @@ func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
}
func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
- if !a.IsForPlatform() {
+ if a.hideApexVariantFromMake {
// The non-platform variant is placed inside APEX. No reason to
// make it available to Make.
return nil
diff --git a/java/app.go b/java/app.go
index 13d08b94a..c25835c41 100755
--- a/java/app.go
+++ b/java/app.go
@@ -480,8 +480,9 @@ func (a *AndroidApp) useEmbeddedNativeLibs(ctx android.ModuleContext) bool {
ctx.PropertyErrorf("min_sdk_version", "invalid value %q: %s", a.minSdkVersion(), err)
}
+ apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
return (minSdkVersion >= 23 && Bool(a.appProperties.Use_embedded_native_libs)) ||
- !a.IsForPlatform()
+ !apexInfo.IsForPlatform()
}
// Returns whether this module should have the dex file stored uncompressed in the APK.
@@ -504,8 +505,9 @@ func (a *AndroidApp) shouldUncompressDex(ctx android.ModuleContext) bool {
}
func (a *AndroidApp) shouldEmbedJnis(ctx android.BaseModuleContext) bool {
+ apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
return ctx.Config().UnbundledBuild() || Bool(a.appProperties.Use_embedded_native_libs) ||
- !a.IsForPlatform() || a.appProperties.AlwaysPackageNativeLibs
+ !apexInfo.IsForPlatform() || a.appProperties.AlwaysPackageNativeLibs
}
func generateAaptRenamePackageFlags(packageName string, renameResourcesPackage bool) []string {
@@ -756,6 +758,10 @@ func (a *AndroidApp) InstallApkName() string {
func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
var apkDeps android.Paths
+ if !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() {
+ a.hideApexVariantFromMake = true
+ }
+
a.aapt.useEmbeddedNativeLibs = a.useEmbeddedNativeLibs(ctx)
a.aapt.useEmbeddedDex = Bool(a.appProperties.Use_embedded_dex)
@@ -850,8 +856,10 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
BuildBundleModule(ctx, bundleFile, a.exportPackage, jniJarFile, dexJarFile)
a.bundleFile = bundleFile
+ apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+
// Install the app package.
- if (Bool(a.Module.properties.Installable) || ctx.Host()) && a.IsForPlatform() {
+ if (Bool(a.Module.properties.Installable) || ctx.Host()) && apexInfo.IsForPlatform() {
ctx.InstallFile(a.installDir, a.outputFile.Base(), a.outputFile)
for _, extra := range a.extraOutputFiles {
ctx.InstallFile(a.installDir, extra.Base(), extra)
@@ -979,7 +987,7 @@ func (a *AndroidApp) buildAppDependencyInfo(ctx android.ModuleContext) {
}
func (a *AndroidApp) Updatable() bool {
- return Bool(a.appProperties.Updatable) || a.ApexModuleBase.Updatable()
+ return Bool(a.appProperties.Updatable)
}
func (a *AndroidApp) getCertString(ctx android.BaseModuleContext) string {
@@ -1335,6 +1343,8 @@ type AndroidAppImport struct {
preprocessed bool
installPath android.InstallPath
+
+ hideApexVariantFromMake bool
}
type AndroidAppImportProperties struct {
@@ -1481,6 +1491,11 @@ func (a *AndroidAppImport) InstallApkName() string {
}
func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext) {
+ apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ if !apexInfo.IsForPlatform() {
+ a.hideApexVariantFromMake = true
+ }
+
numCertPropsSet := 0
if String(a.properties.Certificate) != "" {
numCertPropsSet++
@@ -1569,7 +1584,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
// TODO: Optionally compress the output apk.
- if a.IsForPlatform() {
+ if apexInfo.IsForPlatform() {
a.installPath = ctx.InstallFile(installDir, apkFilename, a.outputFile)
}
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index f1b717874..20dbc666b 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -94,7 +94,7 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool {
}
// Don't preopt APEX variant module
- if am, ok := ctx.Module().(android.ApexModule); ok && !am.IsForPlatform() {
+ if apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo); !apexInfo.IsForPlatform() {
return true
}
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 7877031f8..9f49786ba 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -266,12 +266,13 @@ func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, modul
}
// Check that this module satisfies constraints for a particular boot image.
- apex, isApexModule := module.(android.ApexModule)
- fromUpdatableApex := isApexModule && apex.Updatable()
+ _, isApexModule := module.(android.ApexModule)
+ apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
+ fromUpdatableApex := isApexModule && apexInfo.Updatable
if image.name == artBootImageName {
- if isApexModule && len(apex.InApexes()) > 0 && allHavePrefix(apex.InApexes(), "com.android.art.") {
+ if isApexModule && len(apexInfo.InApexes) > 0 && allHavePrefix(apexInfo.InApexes, "com.android.art.") {
// ok: found the jar in the ART apex
- } else if isApexModule && apex.IsForPlatform() && isHostdex(module) {
+ } else if isApexModule && apexInfo.IsForPlatform() && isHostdex(module) {
// exception (skip and continue): special "hostdex" platform variant
return -1, nil
} else if name == "jacocoagent" && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
@@ -279,7 +280,7 @@ func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, modul
return -1, nil
} else if fromUpdatableApex {
// error: this jar is part of an updatable apex other than ART
- ctx.Errorf("module %q from updatable apexes %q is not allowed in the ART boot image", name, apex.InApexes())
+ ctx.Errorf("module %q from updatable apexes %q is not allowed in the ART boot image", name, apexInfo.InApexes)
} else {
// error: this jar is part of the platform or a non-updatable apex
ctx.Errorf("module %q is not allowed in the ART boot image", name)
@@ -289,7 +290,7 @@ func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, modul
// ok: this jar is part of the platform or a non-updatable apex
} else {
// error: this jar is part of an updatable apex
- ctx.Errorf("module %q from updatable apexes %q is not allowed in the framework boot image", name, apex.InApexes())
+ ctx.Errorf("module %q from updatable apexes %q is not allowed in the framework boot image", name, apexInfo.InApexes)
}
} else {
panic("unknown boot image: " + image.name)
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index 61a9b97e4..b140b899b 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -161,10 +161,9 @@ func stubFlagsRule(ctx android.SingletonContext) {
// For a java lib included in an APEX, only take the one built for
// the platform variant, and skip the variants for APEXes.
// Otherwise, the hiddenapi tool will complain about duplicated classes
- if a, ok := module.(android.ApexModule); ok {
- if android.InAnyApex(module.Name()) && !a.IsForPlatform() {
- return
- }
+ apexInfo := ctx.ModuleProvider(module, android.ApexInfoProvider).(android.ApexInfo)
+ if !apexInfo.IsForPlatform() {
+ return
}
bootDexJars = append(bootDexJars, jar)
diff --git a/java/java.go b/java/java.go
index 1d7eaa771..7821035ac 100644
--- a/java/java.go
+++ b/java/java.go
@@ -451,6 +451,8 @@ type Module struct {
// Collect the module directory for IDE info in java/jdeps.go.
modulePaths []string
+
+ hideApexVariantFromMake bool
}
func (j *Module) addHostProperties() {
@@ -638,8 +640,9 @@ func (j *Module) shouldInstrumentInApex(ctx android.BaseModuleContext) bool {
// Force enable the instrumentation for java code that is built for APEXes ...
// except for the jacocoagent itself (because instrumenting jacocoagent using jacocoagent
// doesn't make sense) or framework libraries (e.g. libraries found in the InstrumentFrameworkModules list) unless EMMA_INSTRUMENT_FRAMEWORK is true.
+ apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
isJacocoAgent := ctx.ModuleName() == "jacocoagent"
- if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && !isJacocoAgent && !j.IsForPlatform() {
+ if j.DirectlyInAnyApex() && !isJacocoAgent && !apexInfo.IsForPlatform() {
if !inList(ctx.ModuleName(), config.InstrumentFrameworkModules) {
return true
} else if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
@@ -1590,7 +1593,8 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
j.implementationAndResourcesJar = implementationAndResourcesJar
// Enable dex compilation for the APEX variants, unless it is disabled explicitly
- if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && !j.IsForPlatform() {
+ apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ if j.DirectlyInAnyApex() && !apexInfo.IsForPlatform() {
if j.dexProperties.Compile_dex == nil {
j.dexProperties.Compile_dex = proptools.BoolPtr(true)
}
@@ -1672,7 +1676,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
j.linter.compileSdkVersion = lintSDKVersionString(j.sdkVersion())
j.linter.javaLanguageLevel = flags.javaVersion.String()
j.linter.kotlinLanguageLevel = "1.3"
- if j.ApexVariationName() != "" && ctx.Config().UnbundledBuildApps() {
+ if !apexInfo.IsForPlatform() && ctx.Config().UnbundledBuildApps() {
j.linter.buildModuleReportZip = true
}
j.linter.lint(ctx)
@@ -1934,7 +1938,7 @@ func (j *Library) PermittedPackagesForUpdatableBootJars() []string {
func shouldUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter) bool {
// Store uncompressed (and aligned) any dex files from jars in APEXes.
- if am, ok := ctx.Module().(android.ApexModule); ok && !am.IsForPlatform() {
+ if apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo); !apexInfo.IsForPlatform() {
return true
}
@@ -1956,6 +1960,11 @@ func shouldUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter) bo
}
func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ if !apexInfo.IsForPlatform() {
+ j.hideApexVariantFromMake = true
+ }
+
j.checkSdkVersions(ctx)
j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", j.Stem()+".jar")
j.dexpreopter.isSDKLibrary = j.deviceProperties.IsSDKLibrary
@@ -1970,7 +1979,7 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Collect the module directory for IDE info in java/jdeps.go.
j.modulePaths = append(j.modulePaths, ctx.ModuleDir())
- exclusivelyForApex := android.InAnyApex(ctx.ModuleName()) && !j.IsForPlatform()
+ exclusivelyForApex := !apexInfo.IsForPlatform()
if (Bool(j.properties.Installable) || ctx.Host()) && !exclusivelyForApex {
var extraInstallDeps android.Paths
if j.InstallMixin != nil {
@@ -2562,6 +2571,8 @@ type Import struct {
combinedClasspathFile android.Path
exportedSdkLibs dexpreopt.LibraryPaths
exportAidlIncludeDirs android.Paths
+
+ hideApexVariantFromMake bool
}
func (j *Import) sdkVersion() sdkSpec {
@@ -2617,6 +2628,10 @@ func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
}
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ if !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform() {
+ j.hideApexVariantFromMake = true
+ }
+
jars := android.PathsForModuleSrc(ctx, j.properties.Jars)
jarName := j.Stem() + ".jar"
@@ -2849,6 +2864,8 @@ type DexImport struct {
maybeStrippedDexJarFile android.Path
dexpreopter
+
+ hideApexVariantFromMake bool
}
func (j *DexImport) Prebuilt() *android.Prebuilt {
@@ -2884,6 +2901,11 @@ func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.PropertyErrorf("jars", "exactly one jar must be provided")
}
+ apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ if !apexInfo.IsForPlatform() {
+ j.hideApexVariantFromMake = true
+ }
+
j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", j.Stem()+".jar")
j.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &j.dexpreopter)
@@ -2928,7 +2950,7 @@ func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.maybeStrippedDexJarFile = dexOutputFile
- if j.IsForPlatform() {
+ if apexInfo.IsForPlatform() {
ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
j.Stem()+".jar", dexOutputFile)
}
diff --git a/java/lint.go b/java/lint.go
index 3a210cc0b..3df582f6e 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -451,10 +451,13 @@ func (l *lintSingleton) generateLintReportZips(ctx android.SingletonContext) {
return
}
- if apex, ok := m.(android.ApexModule); ok && apex.NotAvailableForPlatform() && apex.IsForPlatform() {
- // There are stray platform variants of modules in apexes that are not available for
- // the platform, and they sometimes can't be built. Don't depend on them.
- return
+ if apex, ok := m.(android.ApexModule); ok && apex.NotAvailableForPlatform() {
+ apexInfo := ctx.ModuleProvider(m, android.ApexInfoProvider).(android.ApexInfo)
+ if apexInfo.IsForPlatform() {
+ // There are stray platform variants of modules in apexes that are not available for
+ // the platform, and they sometimes can't be built. Don't depend on them.
+ return
+ }
}
if l, ok := m.(lintOutputsIntf); ok {
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 60924a662..3673ea152 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1410,22 +1410,14 @@ func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s sdkSpec) and
return android.Paths{jarPath.Path()}
}
-// Get the apex names for module, nil if it is for platform.
-func getApexNamesForModule(module android.Module) []string {
- if apex, ok := module.(android.ApexModule); ok {
- return apex.InApexes()
- }
-
- return nil
-}
-
// Check to see if the other module is within the same set of named APEXes as this module.
//
// If either this or the other module are on the platform then this will return
// false.
-func withinSameApexesAs(module android.ApexModule, other android.Module) bool {
- names := module.InApexes()
- return len(names) > 0 && reflect.DeepEqual(names, getApexNamesForModule(other))
+func withinSameApexesAs(ctx android.BaseModuleContext, other android.Module) bool {
+ apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
+ otherApexInfo := ctx.OtherModuleProvider(other, android.ApexInfoProvider).(android.ApexInfo)
+ return len(otherApexInfo.InApexes) > 0 && reflect.DeepEqual(apexInfo.InApexes, otherApexInfo.InApexes)
}
func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkSpec, headerJars bool) android.Paths {
@@ -1444,7 +1436,7 @@ func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkS
// Only allow access to the implementation library in the following condition:
// * No sdk_version specified on the referencing module.
// * The referencing module is in the same apex as this.
- if sdkVersion.kind == sdkPrivate || withinSameApexesAs(module, ctx.Module()) {
+ if sdkVersion.kind == sdkPrivate || withinSameApexesAs(ctx, module) {
if headerJars {
return module.HeaderJars()
} else {
@@ -1961,7 +1953,7 @@ func (module *SdkLibraryImport) sdkJars(ctx android.BaseModuleContext, sdkVersio
// For consistency with SdkLibrary make the implementation jar available to libraries that
// are within the same APEX.
implLibraryModule := module.implLibraryModule
- if implLibraryModule != nil && withinSameApexesAs(module, ctx.Module()) {
+ if implLibraryModule != nil && withinSameApexesAs(ctx, module) {
if headerJars {
return implLibraryModule.HeaderJars()
} else {
@@ -2057,6 +2049,8 @@ type sdkLibraryXml struct {
outputFilePath android.OutputPath
installDirPath android.InstallPath
+
+ hideApexVariantFromMake bool
}
type sdkLibraryXmlProperties struct {
@@ -2114,13 +2108,13 @@ func (module *sdkLibraryXml) ShouldSupportSdkVersion(ctx android.BaseModuleConte
}
// File path to the runtime implementation library
-func (module *sdkLibraryXml) implPath() string {
+func (module *sdkLibraryXml) implPath(ctx android.ModuleContext) string {
implName := proptools.String(module.properties.Lib_name)
- if apexName := module.ApexVariationName(); apexName != "" {
+ if apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo); !apexInfo.IsForPlatform() {
// TODO(b/146468504): ApexVariationName() is only a soong module name, not apex name.
// In most cases, this works fine. But when apex_name is set or override_apex is used
// this can be wrong.
- return fmt.Sprintf("/apex/%s/javalib/%s.jar", apexName, implName)
+ return fmt.Sprintf("/apex/%s/javalib/%s.jar", apexInfo.ApexVariationName, implName)
}
partition := "system"
if module.SocSpecific() {
@@ -2136,8 +2130,10 @@ func (module *sdkLibraryXml) implPath() string {
}
func (module *sdkLibraryXml) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ module.hideApexVariantFromMake = !ctx.Provider(android.ApexInfoProvider).(android.ApexInfo).IsForPlatform()
+
libName := proptools.String(module.properties.Lib_name)
- xmlContent := fmt.Sprintf(permissionsTemplate, libName, module.implPath())
+ xmlContent := fmt.Sprintf(permissionsTemplate, libName, module.implPath(ctx))
module.outputFilePath = android.PathForModuleOut(ctx, libName+".xml").OutputPath
rule := android.NewRuleBuilder()
@@ -2151,7 +2147,7 @@ func (module *sdkLibraryXml) GenerateAndroidBuildActions(ctx android.ModuleConte
}
func (module *sdkLibraryXml) AndroidMkEntries() []android.AndroidMkEntries {
- if !module.IsForPlatform() {
+ if module.hideApexVariantFromMake {
return []android.AndroidMkEntries{android.AndroidMkEntries{
Disabled: true,
}}