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
diff --git a/java/java.go b/java/java.go
index 2ac5a5b..49095ca 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1172,12 +1172,25 @@
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 @@
j.dexJarFile = dexOutputFile
+ // Dexpreopting
j.dexpreopter.isInstallable = Bool(j.properties.Installable)
j.dexpreopter.uncompressedDex = j.deviceProperties.UncompressDex
dexOutputFile = j.dexpreopt(ctx, dexOutputFile)