Always do zipalign with uncompressDex.

Also preserve the alignment with hiddenapi.

Test: conscrypt apex has its conscrypt.jar zipaligned.
Change-Id: I43cc0eadb9548c3d8055e12c077fb7bbe1935fe6
This commit is contained in:
Nicolas Geoffray
2019-01-21 23:20:23 +00:00
parent e153382e17
commit 65fd8ba2fe
3 changed files with 15 additions and 8 deletions

View File

@@ -215,6 +215,11 @@ func (j *Module) compileDex(ctx android.ModuleContext, flags javaBuilderFlags,
},
})
}
if j.deviceProperties.UncompressDex {
alignedJavalibJar := android.PathForModuleOut(ctx, "aligned", jarName)
TransformZipAlign(ctx, alignedJavalibJar, javalibJar)
javalibJar = alignedJavalibJar
}
return javalibJar
}

View File

@@ -85,23 +85,31 @@ func hiddenAPIEncodeDex(ctx android.ModuleContext, output android.WritablePath,
// 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)
}

View File

@@ -1413,12 +1413,6 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
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)
}