Don't strip when dexpreopt is disabled
If dexpreopt is disabled for a module then classes.dex must not be stripped. Bug: 121377197 Test: m WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY=true Change-Id: Icfa48804cf02291874ac6623c9b9297821ac8ce6
This commit is contained in:
parent
6cf911150a
commit
cbed657b74
|
@ -95,22 +95,6 @@ func GenerateDexpreoptRule(global GlobalConfig, module ModuleConfig) (rule *Rule
|
|||
|
||||
rule = &Rule{}
|
||||
|
||||
dexpreoptDisabled := contains(global.DisablePreoptModules, module.Name)
|
||||
|
||||
if contains(global.BootJars, module.Name) {
|
||||
// Don't preopt individual boot jars, they will be preopted together
|
||||
dexpreoptDisabled = true
|
||||
}
|
||||
|
||||
// If OnlyPreoptBootImageAndSystemServer=true and module is not in boot class path skip
|
||||
// Also preopt system server jars since selinux prevents system server from loading anything from
|
||||
// /data. If we don't do this they will need to be extracted which is not favorable for RAM usage
|
||||
// or performance. If PreoptExtractedApk is true, we ignore the only preopt boot image options.
|
||||
if global.OnlyPreoptBootImageAndSystemServer && !contains(global.BootJars, module.Name) &&
|
||||
!contains(global.SystemServerJars, module.Name) && !module.PreoptExtractedApk {
|
||||
dexpreoptDisabled = true
|
||||
}
|
||||
|
||||
generateProfile := module.ProfileClassListing != "" && !global.DisableGenerateProfile
|
||||
|
||||
var profile string
|
||||
|
@ -118,7 +102,10 @@ func GenerateDexpreoptRule(global GlobalConfig, module ModuleConfig) (rule *Rule
|
|||
profile = profileCommand(global, module, rule)
|
||||
}
|
||||
|
||||
if !dexpreoptDisabled {
|
||||
if !dexpreoptDisabled(global, module) {
|
||||
// Don't preopt individual boot jars, they will be preopted together.
|
||||
// This check is outside dexpreoptDisabled because they still need to be stripped.
|
||||
if !contains(global.BootJars, module.Name) {
|
||||
appImage := (generateProfile || module.ForceCreateAppImage || global.DefaultAppImages) &&
|
||||
!module.NoCreateAppImage
|
||||
|
||||
|
@ -132,10 +119,28 @@ func GenerateDexpreoptRule(global GlobalConfig, module ModuleConfig) (rule *Rule
|
|||
dexpreoptCommand(global, module, rule, profile, arch, imageLocation, appImage, generateDM)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rule, nil
|
||||
}
|
||||
|
||||
func dexpreoptDisabled(global GlobalConfig, module ModuleConfig) bool {
|
||||
if contains(global.DisablePreoptModules, module.Name) {
|
||||
return true
|
||||
}
|
||||
|
||||
// If OnlyPreoptBootImageAndSystemServer=true and module is not in boot class path skip
|
||||
// Also preopt system server jars since selinux prevents system server from loading anything from
|
||||
// /data. If we don't do this they will need to be extracted which is not favorable for RAM usage
|
||||
// or performance. If PreoptExtractedApk is true, we ignore the only preopt boot image options.
|
||||
if global.OnlyPreoptBootImageAndSystemServer && !contains(global.BootJars, module.Name) &&
|
||||
!contains(global.SystemServerJars, module.Name) && !module.PreoptExtractedApk {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func profileCommand(global GlobalConfig, module ModuleConfig, rule *Rule) string {
|
||||
profilePath := filepath.Join(filepath.Dir(module.BuildPath), "profile.prof")
|
||||
profileInstalledPath := module.DexLocation + ".prof"
|
||||
|
@ -445,6 +450,10 @@ func dexpreoptCommand(global GlobalConfig, module ModuleConfig, rule *Rule, prof
|
|||
func shouldStripDex(module ModuleConfig, global GlobalConfig) bool {
|
||||
strip := !global.DefaultNoStripping
|
||||
|
||||
if dexpreoptDisabled(global, module) {
|
||||
strip = false
|
||||
}
|
||||
|
||||
// Don't strip modules that are not on the system partition in case the oat/vdex version in system ROM
|
||||
// doesn't match the one in other partitions. It needs to be able to fall back to the APK for that case.
|
||||
if !strings.HasPrefix(module.DexLocation, SystemPartition) {
|
||||
|
|
Loading…
Reference in New Issue