diff options
author | Paul Duffin <paulduffin@google.com> | 2019-02-28 16:13:20 +0000 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2019-02-28 16:13:20 +0000 |
commit | d2acecaeb72c2bb82db25b853370e5b620cdc323 (patch) | |
tree | 1a6245283b3264556b001c8e6132e5ae409b39b5 /java/hiddenapi.go | |
parent | 724c5fd8138d46193adf6de74aba79a37627f897 (diff) | |
download | build_soong-d2acecaeb72c2bb82db25b853370e5b620cdc323.tar.gz build_soong-d2acecaeb72c2bb82db25b853370e5b620cdc323.tar.bz2 build_soong-d2acecaeb72c2bb82db25b853370e5b620cdc323.zip |
Improve hiddenapi processing so it does not require white list
Rather than have a special white list to contain the names of modules
that provide additional hiddenapi for modules on the bootclasspath
this defines a convention that such modules must have a name which is
of the format <x>-hiddenapi, where <x> is the name of the module on the
bootclasspath.
Bug: 73711752
Test: make droid && flashall -w && atest -p cts/tests/signature
Change-Id: Ib2d69dea9541b60a9bb81496f00edb65036d1ebb
Diffstat (limited to 'java/hiddenapi.go')
-rw-r--r-- | java/hiddenapi.go | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/java/hiddenapi.go b/java/hiddenapi.go index 51ed3dda..6020aba6 100644 --- a/java/hiddenapi.go +++ b/java/hiddenapi.go @@ -15,10 +15,11 @@ package java import ( + "strings" + "github.com/google/blueprint" "android/soong/android" - "android/soong/java/config" ) var hiddenAPIGenerateCSVRule = pctx.AndroidStaticRule("hiddenAPIGenerateCSV", blueprint.RuleParams{ @@ -56,20 +57,39 @@ func (h *hiddenAPI) hiddenAPI(ctx android.ModuleContext, dexJar android.ModuleOu uncompressDex bool) android.ModuleOutPath { if !ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") { - isBootJar := inList(ctx.ModuleName(), ctx.Config().BootJars()) - if isBootJar || inList(ctx.ModuleName(), config.HiddenAPIExtraAppUsageJars) { + name := ctx.ModuleName() + + // Modules whose names are of the format <x>-hiddenapi provide hiddenapi information + // for the boot jar module <x>. Otherwise, the module provides information for itself. + // Either way extract the name of the boot jar module. + bootJarName := strings.TrimSuffix(name, "-hiddenapi") + + // If this module is on the boot jars list (or providing information for a module + // on the list) then extract the hiddenapi information from it, and if necessary + // encode that information in the generated dex file. + // + // It is important that hiddenapi information is only gathered for/from modules on + // that are actually on the boot jars list because the runtime only enforces access + // to the hidden API for the bootclassloader. If information is gathered for modules + // not on the list then that will cause failures in the CtsHiddenApiBlacklist... + // tests. + if inList(bootJarName, ctx.Config().BootJars()) { // Derive the greylist from classes jar. flagsCSV := android.PathForModuleOut(ctx, "hiddenapi", "flags.csv") metadataCSV := android.PathForModuleOut(ctx, "hiddenapi", "metadata.csv") hiddenAPIGenerateCSV(ctx, flagsCSV, metadataCSV, implementationJar) h.flagsCSVPath = flagsCSV h.metadataCSVPath = metadataCSV - } - if isBootJar { - hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", ctx.ModuleName()+".jar") - h.bootDexJarPath = dexJar - hiddenAPIEncodeDex(ctx, hiddenAPIJar, dexJar, uncompressDex) - dexJar = hiddenAPIJar + + // If this module is actually on the boot jars list and not providing + // hiddenapi information for a module on the boot jars list then encode + // the gathered information in the generated dex file. + if name == bootJarName { + hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", name+".jar") + h.bootDexJarPath = dexJar + hiddenAPIEncodeDex(ctx, hiddenAPIJar, dexJar, uncompressDex) + dexJar = hiddenAPIJar + } } } |