Allow the user to explicitly set the java Uncompress_dex property.
ART tests need to explicitly control the compression.
Bug: 157239179
Test: "atest ArtGtestsTarget" with http://go/aog/1302773
Change-Id: I4490aa0a61fa71f830feb6a46dffd8d20fccfc66
Merged-In: I4490aa0a61fa71f830feb6a46dffd8d20fccfc66
diff --git a/java/app.go b/java/app.go
index 215b07b..402428d 100755
--- a/java/app.go
+++ b/java/app.go
@@ -568,16 +568,17 @@
installDir = filepath.Join("app", a.installApkName)
}
a.dexpreopter.installPath = android.PathForModuleInstall(ctx, installDir, a.installApkName+".apk")
- a.dexpreopter.uncompressedDex = a.shouldUncompressDex(ctx)
-
+ if a.deviceProperties.Uncompress_dex == nil {
+ // If the value was not force-set by the user, use reasonable default based on the module.
+ a.deviceProperties.Uncompress_dex = proptools.BoolPtr(a.shouldUncompressDex(ctx))
+ }
+ a.dexpreopter.uncompressedDex = *a.deviceProperties.Uncompress_dex
a.dexpreopter.enforceUsesLibs = a.usesLibrary.enforceUsesLibraries()
a.dexpreopter.usesLibs = a.usesLibrary.usesLibraryProperties.Uses_libs
a.dexpreopter.optionalUsesLibs = a.usesLibrary.presentOptionalUsesLibs(ctx)
a.dexpreopter.libraryPaths = a.usesLibrary.usesLibraryPaths(ctx)
a.dexpreopter.manifestFile = a.mergedManifestFile
- a.deviceProperties.UncompressDex = a.dexpreopter.uncompressedDex
-
if ctx.ModuleName() != "framework-res" {
a.Module.compile(ctx, a.aaptSrcJar)
}
diff --git a/java/app_test.go b/java/app_test.go
index 2195afd..e2d0c5e 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -2722,6 +2722,32 @@
uncompressedPlatform: true,
uncompressedUnbundled: true,
},
+ {
+ name: "normal_uncompress_dex_true",
+ bp: `
+ android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ uncompress_dex: true,
+ }
+ `,
+ uncompressedPlatform: true,
+ uncompressedUnbundled: true,
+ },
+ {
+ name: "normal_uncompress_dex_false",
+ bp: `
+ android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ uncompress_dex: false,
+ }
+ `,
+ uncompressedPlatform: false,
+ uncompressedUnbundled: false,
+ },
}
test := func(t *testing.T, bp string, want bool, unbundled bool) {
diff --git a/java/dex.go b/java/dex.go
index 27ec6ee..e2a8e7e 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -18,6 +18,7 @@
"strings"
"github.com/google/blueprint"
+ "github.com/google/blueprint/proptools"
"android/soong/android"
"android/soong/remoteexec"
@@ -188,7 +189,7 @@
outDir := android.PathForModuleOut(ctx, "dex")
zipFlags := "--ignore_missing_files"
- if j.deviceProperties.UncompressDex {
+ if proptools.Bool(j.deviceProperties.Uncompress_dex) {
zipFlags += " -L 0"
}
@@ -235,7 +236,7 @@
},
})
}
- if j.deviceProperties.UncompressDex {
+ if proptools.Bool(j.deviceProperties.Uncompress_dex) {
alignedJavalibJar := android.PathForModuleOut(ctx, "aligned", jarName)
TransformZipAlign(ctx, alignedJavalibJar, javalibJar)
javalibJar = alignedJavalibJar
diff --git a/java/java.go b/java/java.go
index 5b1dcd7..4e57e1c 100644
--- a/java/java.go
+++ b/java/java.go
@@ -342,8 +342,13 @@
// set the name of the output
Stem *string
- UncompressDex bool `blueprint:"mutated"`
- IsSDKLibrary bool `blueprint:"mutated"`
+ // Keep the data uncompressed. We always need uncompressed dex for execution,
+ // so this might actually save space by avoiding storing the same data twice.
+ // This defaults to reasonable value based on module and should not be set.
+ // It exists only to support ART tests.
+ Uncompress_dex *bool
+
+ IsSDKLibrary bool `blueprint:"mutated"`
}
func (me *CompilerDeviceProperties) EffectiveOptimizeEnabled() bool {
@@ -1556,7 +1561,7 @@
// Hidden API CSV generation and dex encoding
dexOutputFile = j.hiddenAPI.hiddenAPI(ctx, dexOutputFile, j.implementationJarFile,
- j.deviceProperties.UncompressDex)
+ proptools.Bool(j.deviceProperties.Uncompress_dex))
// merge dex jar with resources if necessary
if j.resourceJar != nil {
@@ -1564,7 +1569,7 @@
combinedJar := android.PathForModuleOut(ctx, "dex-withres", jarName)
TransformJarsToJar(ctx, combinedJar, "for dex resources", jars, android.OptionalPath{},
false, nil, nil)
- if j.deviceProperties.UncompressDex {
+ if *j.deviceProperties.Uncompress_dex {
combinedAlignedJar := android.PathForModuleOut(ctx, "dex-withres-aligned", jarName)
TransformZipAlign(ctx, combinedAlignedJar, combinedJar)
dexOutputFile = combinedAlignedJar
@@ -1841,8 +1846,11 @@
j.checkSdkVersions(ctx)
j.dexpreopter.installPath = android.PathForModuleInstall(ctx, "framework", j.Stem()+".jar")
j.dexpreopter.isSDKLibrary = j.deviceProperties.IsSDKLibrary
- j.dexpreopter.uncompressedDex = shouldUncompressDex(ctx, &j.dexpreopter)
- j.deviceProperties.UncompressDex = j.dexpreopter.uncompressedDex
+ if j.deviceProperties.Uncompress_dex == nil {
+ // If the value was not force-set by the user, use reasonable default based on the module.
+ j.deviceProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))
+ }
+ j.dexpreopter.uncompressedDex = *j.deviceProperties.Uncompress_dex
j.compile(ctx, nil)
exclusivelyForApex := android.InAnyApex(ctx.ModuleName()) && !j.IsForPlatform()