Revert submission 1191937-art_apex_available
Original Commit Message:
"""
Rename modules that are APEX-only
The renamed modules are only available for APEXes, but not for the
platform. Use the <module_name>.<apex_name> syntax to correctly install
the APEX variant of the modules.
"""
Reason for revert: Build Cop - Breaks about 15 AOSP targets, with high confidence due to these changes being the only non-robot changes in those builds.
Reverted Changes:
I190ce2d10:Use apex_available property
I990e0a67e:Use apex_available property
I0d1295683:Revert "Avoid duplicated classes for boot dex jars...
I5fb725403:Find the jar libraries in APEX from the correct pa...
I322b1efcc:Rename modules that are APEX-only
Ifa2bd0f8f:Use apex_available property
Iac6533177:Use apex_available property
Ie999602c6:Use apex_available property
I2a3d73397:Use apex_available property
Ic91bcbb9a:Use apex_available property
Ia6c324eed:Use apex_available property
I964d0125c:Use apex_available property
Change-Id: I48b998629b0676cd7353e6844fd87585e0e42989
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index ad84cde..e9e4a45 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -16,6 +16,7 @@
import (
"fmt"
+ "strings"
"android/soong/android"
)
@@ -152,11 +153,23 @@
// Collect dex jar paths for modules that had hiddenapi encode called on them.
if h, ok := module.(hiddenAPIIntf); ok {
if jar := h.bootDexJar(); jar != nil {
- // 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() {
+ // Don't add multiple variants of the same library to bootDexJars, otherwise
+ // hiddenapi tool will complain about duplicated classes. Such multiple variants
+ // of the same library can happen when the library is included in one or more APEXes.
+ // TODO(b/146308764): remove this heuristic
+ if a, ok := module.(android.ApexModule); ok && android.InAnyApex(module.Name()) {
+ if a.AvailableFor("//apex_available:platform") && !a.IsForPlatform() {
+ // skip the apex variants if the jar is available for the platform
+ return
+ }
+ apexName := a.ApexName()
+ if strings.Contains(apexName, "test") {
+ // skip the if the jar is in test APEX
+ return
+ }
+
+ if strings.Contains(apexName, "com.android.art") && apexName != "com.android.art.release" {
+ // skip the ART APEX variants other than com.android.art.release
return
}
}