apex: Make android_library support APEX variants
The android_library module type can be used within an android_app that
can itself be added to an apex but android_library does not call
android.InitApexModule(module) and so it does not support apex variants
and so is treated as if it cannot be part of an APEX even though it
actually is.
Now, android_library supports AEPX variants.
Due to this change, the whilelist for apex_available got bigger.
Exempt-From-Owner-Approval: cherry-pick from internal
Bug: 156978407
Test: m
Merged-In: I3a21d653fe9c4159e3a89791fe1a8597865eeae6
Change-Id: I3a21d653fe9c4159e3a89791fe1a8597865eeae6
(cherry picked from commit bd133b1bdc1de378992491c3154a9ec0b347f7c3)
diff --git a/java/aar.go b/java/aar.go
index 6e3b9e6..0e103f2 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -513,6 +513,7 @@
module.androidLibraryProperties.BuildAAR = true
+ android.InitApexModule(module)
InitJavaModule(module, android.DeviceSupported)
return module
}
@@ -537,8 +538,12 @@
type AARImport struct {
android.ModuleBase
android.DefaultableModuleBase
+ android.ApexModuleBase
prebuilt android.Prebuilt
+ // Functionality common to Module and Import.
+ embeddableInModuleAndImport
+
properties AARImportProperties
classpathFile android.WritablePath
@@ -742,6 +747,10 @@
return nil, nil
}
+func (a *AARImport) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
+ return a.depIsInSameApex(ctx, dep)
+}
+
var _ android.PrebuiltInterface = (*Import)(nil)
// android_library_import imports an `.aar` file into the build graph as if it was built with android_library.
@@ -754,6 +763,7 @@
module.AddProperties(&module.properties)
android.InitPrebuiltModule(module, &module.properties.Aars)
+ android.InitApexModule(module)
InitJavaModule(module, android.DeviceSupported)
return module
}
diff --git a/java/androidmk.go b/java/androidmk.go
index ba1af0d..6747b30 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -211,6 +211,11 @@
}
func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
+ if !prebuilt.IsForPlatform() {
+ return []android.AndroidMkEntries{{
+ Disabled: true,
+ }}
+ }
return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
@@ -416,6 +421,11 @@
}
func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
+ if !a.IsForPlatform() {
+ return []android.AndroidMkEntries{{
+ Disabled: true,
+ }}
+ }
entriesList := a.Library.AndroidMkEntries()
entries := &entriesList[0]