Move hiddenapi to Soong

Perform hiddenapi CSV generation and dex encoding for Soong modules
in Soong.  This fixes an issue where dexpreopting was happening on
a different jar than was being installed.

Bug: 122856783
Test: m checkbuild
Test: no change out/target/common/obj/PACKAGING/hiddenapi-flags.csv
Test: only ordering change to out/target/common/obj/PACKAGING/hiddenapi-greylist.csv
Test: cts/tests/signature/runSignatureTests.sh
Change-Id: I4fc481efc29e73cb2bdaacf672e86d5f6f0075ae
This commit is contained in:
Colin Cross
2019-01-16 15:15:52 -08:00
parent 56abb83628
commit 8faf8fc060
7 changed files with 188 additions and 0 deletions

View File

@@ -1172,12 +1172,25 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
j.implementationAndResourcesJar = implementationAndResourcesJar
if ctx.Device() && (Bool(j.properties.Installable) || Bool(j.deviceProperties.Compile_dex)) {
// Dex compilation
var dexOutputFile android.ModuleOutPath
dexOutputFile = j.compileDex(ctx, flags, outputFile, jarName)
if ctx.Failed() {
return
}
// Hidden API CSV generation and dex encoding
isBootJar := inList(ctx.ModuleName(), ctx.Config().BootJars())
if isBootJar || inList(ctx.ModuleName(), ctx.Config().HiddenAPIExtraAppUsageJars()) {
// Derive the greylist from classes jar.
hiddenAPIGenerateCSV(ctx, j.implementationJarFile)
}
if isBootJar {
hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", jarName)
hiddenAPIEncodeDex(ctx, hiddenAPIJar, dexOutputFile)
dexOutputFile = hiddenAPIJar
}
// merge dex jar with resources if necessary
if j.resourceJar != nil {
jars := android.Paths{dexOutputFile, j.resourceJar}
@@ -1189,6 +1202,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
j.dexJarFile = dexOutputFile
// Dexpreopting
j.dexpreopter.isInstallable = Bool(j.properties.Installable)
j.dexpreopter.uncompressedDex = j.deviceProperties.UncompressDex
dexOutputFile = j.dexpreopt(ctx, dexOutputFile)