Always do zipalign with uncompressDex.
Also preserve the alignment with hiddenapi.
Test: conscrypt apex has its conscrypt.jar zipaligned.
Change-Id: I43cc0eadb9548c3d8055e12c077fb7bbe1935fe6
diff --git a/java/dex.go b/java/dex.go
index 2531970..913eee6 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -215,6 +215,11 @@
},
})
}
+ if j.deviceProperties.UncompressDex {
+ alignedJavalibJar := android.PathForModuleOut(ctx, "aligned", jarName)
+ TransformZipAlign(ctx, alignedJavalibJar, javalibJar)
+ javalibJar = alignedJavalibJar
+ }
return javalibJar
}
diff --git a/java/hiddenapi.go b/java/hiddenapi.go
index 6a603cf..a06a666 100644
--- a/java/hiddenapi.go
+++ b/java/hiddenapi.go
@@ -85,23 +85,31 @@
// The encode dex rule requires unzipping and rezipping the classes.dex files, ensure that if it was uncompressed
// in the input it stays uncompressed in the output.
soongZipFlags := ""
+ tmpOutput := output
+ tmpDir := android.PathForModuleOut(ctx, "hiddenapi", "dex")
if uncompressDex {
soongZipFlags = "-L 0"
+ tmpOutput = android.PathForModuleOut(ctx, "hiddenapi", "unaligned", "unaligned.jar")
+ tmpDir = android.PathForModuleOut(ctx, "hiddenapi", "unaligned")
}
ctx.Build(pctx, android.BuildParams{
Rule: hiddenAPIEncodeDexRule,
Description: "hiddenapi encode dex",
Input: dexInput,
- Output: output,
+ Output: tmpOutput,
Implicit: flags,
Args: map[string]string{
"flags": flags.String(),
- "tmpDir": android.PathForModuleOut(ctx, "hiddenapi", "dex").String(),
+ "tmpDir": tmpDir.String(),
"soongZipFlags": soongZipFlags,
},
})
+ if uncompressDex {
+ TransformZipAlign(ctx, output, tmpOutput)
+ }
+
hiddenAPISaveDexInputs(ctx, dexInput)
}
diff --git a/java/java.go b/java/java.go
index f3b47be..1e5c628 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1413,12 +1413,6 @@
j.compile(ctx)
if (Bool(j.properties.Installable) || ctx.Host()) && !android.DirectlyInAnyApex(ctx, ctx.ModuleName()) {
- if j.deviceProperties.UncompressDex {
- alignedOutputFile := android.PathForModuleOut(ctx, "aligned", ctx.ModuleName()+".jar")
- TransformZipAlign(ctx, alignedOutputFile, j.outputFile)
- j.outputFile = alignedOutputFile
- }
-
j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
ctx.ModuleName()+".jar", j.outputFile)
}