Prebuilt stub not available to platform is handled correctly
When a shared library providing stubs is included in an APEX, only the
stub variant (i.e. version:"1", etc.) gets emitted to Android.mk. This
enforces that everything in the Make world to link to the stub providing
only the public APIs of the library. The non-stub variant (i.e.
version:"") isn't exposed, otherwise, others will be able to access
private part of the lib which isn't guaranteed to be stable.
This has been done by unhiding the stub variant when it is known that
the library is actually included in an APEX. Note that stub variants are
by default hidden.
The above mechanism however doesn't work when the shared library is
replaced by a prebuilt and when the APEX is also replaced by a prebuilt.
Then, the fact that the prebuilt library is actually in the APEX gets
lost. In that case, AnyVariantDirectlyInAnyApex() returns false for the
prebuilt library. As a result, the stub variant remains hidden and not
emitted to Android.mk.
This change fixes the problem by checking if the lib isn't available for
the platform at all. If not available for the platform (e.g.
apex_available doesn't have "//apex_available:platform"), the lib is
assumed to be included in an APEX even when it actually didn't go
through the apex mutator (... because it's a prebuilt).
Bug: 175166063
Test: m nothing
Change-Id: I41fabd5b368baecf4dc3c5a080b466f8bcd79d77
diff --git a/android/apex.go b/android/apex.go
index 4a71b40..f6eca86 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -153,13 +153,12 @@
// run.
DirectlyInAnyApex() bool
- // Returns true in the primary variant of a module if _any_ variant of the module is
- // directly in any apex. This includes host, arch, asan, etc. variants. It is unused in any
- // variant that is not the primary variant. Ideally this wouldn't be used, as it incorrectly
- // mixes arch variants if only one arch is in an apex, but a few places depend on it, for
- // example when an ASAN variant is created before the apexMutator. Call this after
- // apex.apexMutator is run.
- AnyVariantDirectlyInAnyApex() bool
+ // NotInPlatform tells whether or not this module is included in an APEX and therefore
+ // shouldn't be exposed to the platform (i.e. outside of the APEX) directly. A module is
+ // considered to be included in an APEX either when there actually is an APEX that
+ // explicitly has the module as its dependency or the module is not available to the
+ // platform, which indicates that the module belongs to at least one or more other APEXes.
+ NotInPlatform() bool
// Tests if this module could have APEX variants. Even when a module type implements
// ApexModule interface, APEX variants are created only for the module instances that return
@@ -221,7 +220,12 @@
// See ApexModule.DirectlyInAnyApex()
DirectlyInAnyApex bool `blueprint:"mutated"`
- // See ApexModule.AnyVariantDirectlyInAnyApex()
+ // AnyVariantDirectlyInAnyApex is true in the primary variant of a module if _any_ variant
+ // of the module is directly in any apex. This includes host, arch, asan, etc. variants. It
+ // is unused in any variant that is not the primary variant. Ideally this wouldn't be used,
+ // as it incorrectly mixes arch variants if only one arch is in an apex, but a few places
+ // depend on it, for example when an ASAN variant is created before the apexMutator. Call
+ // this after apex.apexMutator is run.
AnyVariantDirectlyInAnyApex bool `blueprint:"mutated"`
// See ApexModule.NotAvailableForPlatform()
@@ -302,8 +306,8 @@
}
// Implements ApexModule
-func (m *ApexModuleBase) AnyVariantDirectlyInAnyApex() bool {
- return m.ApexProperties.AnyVariantDirectlyInAnyApex
+func (m *ApexModuleBase) NotInPlatform() bool {
+ return m.ApexProperties.AnyVariantDirectlyInAnyApex || !m.AvailableFor(AvailableToPlatform)
}
// Implements ApexModule