Support libraries (not just boot jars) that have hiddenapi
The build assumes (apart from one minor exception) that only modules
that are in the PRODUCT_BOOT_JARS list require processing as part of
the hiddenapi. Unfortunately, that is not true for android.test.base,
at least not when REMOVE_ATB_FROM_BCP=true.
This change adds a white list (containing android.test.base) of
additional modules that should be processed as part of the hiddenapi
and updates the hiddenapi.go file to use it.
It does not matter that android.test.base is a boot jar and in the
white list, the behavior is the same as it would be if it was only
in one.
Bug: 73711752
Test: make REMOVE_ATB_FROM_BCP=true droid and make droid
Change-Id: I1c64272f444e6866136c65fb7c48910d55811844
diff --git a/java/hiddenapi.go b/java/hiddenapi.go
index f199051..01e2c5e 100644
--- a/java/hiddenapi.go
+++ b/java/hiddenapi.go
@@ -59,7 +59,14 @@
if !ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
isBootJar := inList(ctx.ModuleName(), ctx.Config().BootJars())
- if isBootJar || inList(ctx.ModuleName(), config.HiddenAPIExtraAppUsageJars) {
+ // Check to see if this module provides part of the hiddenapi, i.e. is a boot jar or a white listed
+ // library.
+ isProvidingJar := isBootJar || inList(ctx.ModuleName(), config.HiddenAPIProvidingNonBootJars)
+
+ // If this module provides part of the hiddenapi or is a special module that simply provides information
+ // about the hiddenapi then extract information about the hiddenapi from the UnsupportedAppUsage
+ // annotations compiled into the classes.jar.
+ if isProvidingJar || inList(ctx.ModuleName(), config.HiddenAPIExtraAppUsageJars) {
// Derive the greylist from classes jar.
flagsCSV := android.PathForModuleOut(ctx, "hiddenapi", "flags.csv")
metadataCSV := android.PathForModuleOut(ctx, "hiddenapi", "metadata.csv")
@@ -67,7 +74,10 @@
h.flagsCSVPath = flagsCSV
h.metadataCSVPath = metadataCSV
}
- if isBootJar {
+
+ // If this module provides part of the hiddenapi then encode the information about the hiddenapi into
+ // the dex file created for this module.
+ if isProvidingJar {
hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", ctx.ModuleName()+".jar")
h.bootDexJarPath = dexJar
hiddenAPIEncodeDex(ctx, hiddenAPIJar, dexJar, uncompressDex)