From 4de94504335e614efcdc4d0d86f1cfad758f83e8 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Sun, 16 May 2021 05:21:16 +0100 Subject: [PATCH] Move hidden API encoding after resource merging Previously, the hidden API encoding was done before resource merging. However, hidden API modularization requires that the encoding be done by the bootclasspath_fragment/platform_bootclasspath modules which will be after the resource merging. Therefore, this change moves the hidden API encoding after to match the future behavior. It also moves the initHiddenAPI() method call after resource merging too and passes it the result of the resource merging so it is available for the bootclasspath modules via bootDexJar(). Although the resource merging was not always done when it was done it would reorder the entries in the generated jar to match java ordering, which puts the MANIFEST.MF first. This change preserves that behavior by adding -j to the call to MergeZipCmds. This does mean that jars which did not require resource merging now have a different order but as both orders work that is not a significant change. Bug: 179354495 Test: m com.android.art com.android.ipsec com.android.os.statsd com.android.conscrypt - verify that apart from the ordering change in the jars that this does not change the contents of the apex files Change-Id: If74baad5659301ca6ca9c0f6484374420dda8c34 --- java/base.go | 12 ++++++------ java/hiddenapi.go | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/java/base.go b/java/base.go index 0d2f1ac55..f7989b8a2 100644 --- a/java/base.go +++ b/java/base.go @@ -1217,12 +1217,6 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { return } - // Initialize the hiddenapi structure. - j.initHiddenAPI(ctx, dexOutputFile, j.implementationJarFile, j.dexProperties.Uncompress_dex) - - // Encode hidden API flags in dex file. - dexOutputFile = j.hiddenAPIEncodeDex(ctx, dexOutputFile) - // merge dex jar with resources if necessary if j.resourceJar != nil { jars := android.Paths{dexOutputFile, j.resourceJar} @@ -1238,6 +1232,12 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { } } + // Initialize the hiddenapi structure. + j.initHiddenAPI(ctx, dexOutputFile, j.implementationJarFile, j.dexProperties.Uncompress_dex) + + // Encode hidden API flags in dex file, if needed. + dexOutputFile = j.hiddenAPIEncodeDex(ctx, dexOutputFile) + j.dexJarFile = dexOutputFile // Dexpreopting diff --git a/java/hiddenapi.go b/java/hiddenapi.go index 1e838247b..c9e3c29a3 100644 --- a/java/hiddenapi.go +++ b/java/hiddenapi.go @@ -235,7 +235,7 @@ var hiddenAPIEncodeDexRule = pctx.AndroidStaticRule("hiddenAPIEncodeDex", bluepr echo "--output-dex=$tmpDir/dex-output/$$(basename $${INPUT_DEX})"; done | xargs ${config.HiddenAPI} encode --api-flags=$flagsCsv $hiddenapiFlags && ${config.SoongZipCmd} $soongZipFlags -o $tmpDir/dex.jar -C $tmpDir/dex-output -f "$tmpDir/dex-output/classes*.dex" && - ${config.MergeZipsCmd} -D -zipToNotStrip $tmpDir/dex.jar -stripFile "classes*.dex" -stripFile "**/*.uau" $out $tmpDir/dex.jar $in`, + ${config.MergeZipsCmd} -j -D -zipToNotStrip $tmpDir/dex.jar -stripFile "classes*.dex" -stripFile "**/*.uau" $out $tmpDir/dex.jar $in`, CommandDeps: []string{ "${config.HiddenAPI}", "${config.SoongZipCmd}",