Extract the logic of setting Uncompress_dex to a common place.
Bug: 194150908 Test: m nothing Change-Id: Ia33965067586cfd48183e6d17f5d17626eef3c5a
This commit is contained in:
29
java/java.go
29
java/java.go
@@ -532,6 +532,14 @@ func shouldUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter) bo
|
||||
return false
|
||||
}
|
||||
|
||||
// Sets `dexer.dexProperties.Uncompress_dex` to the proper value.
|
||||
func setUncompressDex(ctx android.ModuleContext, dexpreopter *dexpreopter, dexer *dexer) {
|
||||
if dexer.dexProperties.Uncompress_dex == nil {
|
||||
// If the value was not force-set by the user, use reasonable default based on the module.
|
||||
dexer.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, dexpreopter))
|
||||
}
|
||||
}
|
||||
|
||||
func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
j.sdkVersion = j.SdkVersion(ctx)
|
||||
j.minSdkVersion = j.MinSdkVersion(ctx)
|
||||
@@ -545,10 +553,7 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
j.dexpreopter.installPath = j.dexpreopter.getInstallPath(
|
||||
ctx, android.PathForModuleInstall(ctx, "framework", j.Stem()+".jar"))
|
||||
j.dexpreopter.isSDKLibrary = j.deviceProperties.IsSDKLibrary
|
||||
if j.dexProperties.Uncompress_dex == nil {
|
||||
// If the value was not force-set by the user, use reasonable default based on the module.
|
||||
j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))
|
||||
}
|
||||
setUncompressDex(ctx, &j.dexpreopter, &j.dexer)
|
||||
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
|
||||
j.classLoaderContexts = j.usesLibrary.classLoaderContextForUsesLibDeps(ctx)
|
||||
j.compile(ctx, nil)
|
||||
@@ -1401,16 +1406,13 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
installPath := android.PathForModuleInPartitionInstall(ctx, "apex", ai.ApexVariationName, apexRootRelativePathToJavaLib(j.BaseModuleName()))
|
||||
j.dexJarInstallFile = installPath
|
||||
|
||||
// Initialize the hiddenapi structure.
|
||||
j.initHiddenAPI(ctx, dexJarFile, outputFile, nil)
|
||||
|
||||
j.dexpreopter.installPath = j.dexpreopter.getInstallPath(ctx, installPath)
|
||||
if j.dexProperties.Uncompress_dex == nil {
|
||||
// If the value was not force-set by the user, use reasonable default based on the module.
|
||||
j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))
|
||||
}
|
||||
setUncompressDex(ctx, &j.dexpreopter, &j.dexer)
|
||||
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
|
||||
j.dexpreopt(ctx, dexOutputPath)
|
||||
|
||||
// Initialize the hiddenapi structure.
|
||||
j.initHiddenAPI(ctx, dexJarFile, outputFile, j.dexProperties.Uncompress_dex)
|
||||
} else {
|
||||
// This should never happen as a variant for a prebuilt_apex is only created if the
|
||||
// prebuilt_apex has been configured to export the java library dex file.
|
||||
@@ -1430,10 +1432,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
j.dexpreopter.installPath = j.dexpreopter.getInstallPath(
|
||||
ctx, android.PathForModuleInstall(ctx, "framework", jarName))
|
||||
if j.dexProperties.Uncompress_dex == nil {
|
||||
// If the value was not force-set by the user, use reasonable default based on the module.
|
||||
j.dexProperties.Uncompress_dex = proptools.BoolPtr(shouldUncompressDex(ctx, &j.dexpreopter))
|
||||
}
|
||||
setUncompressDex(ctx, &j.dexpreopter, &j.dexer)
|
||||
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
|
||||
|
||||
var dexOutputFile android.OutputPath
|
||||
|
Reference in New Issue
Block a user