summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/sdk_library.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 6503e8b30..43a340ed7 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1295,6 +1295,24 @@ func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s sdkSpec) and
return android.Paths{jarPath.Path()}
}
+// Get the apex name for module, "" if it is for platform.
+func getApexNameForModule(module android.Module) string {
+ if apex, ok := module.(android.ApexModule); ok {
+ return apex.ApexName()
+ }
+
+ return ""
+}
+
+// Check to see if the other module is within the same named APEX as this module.
+//
+// If either this or the other module are on the platform then this will return
+// false.
+func (module *SdkLibrary) withinSameApexAs(other android.Module) bool {
+ name := module.ApexName()
+ return name != "" && getApexNameForModule(other) == name
+}
+
func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkSpec, headerJars bool) android.Paths {
// Only provide access to the implementation library if it is actually built.
@@ -1303,7 +1321,8 @@ 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.
- if sdkVersion.kind == sdkPrivate {
+ // * The referencing module is in the same apex as this.
+ if sdkVersion.kind == sdkPrivate || module.withinSameApexAs(ctx.Module()) {
if headerJars {
return module.HeaderJars()
} else {