From 38310bb4ac9caf350b3fd79b069295c54b354c62 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 1 Dec 2021 10:34:14 -0800 Subject: [PATCH] Only get dexpreopt config for device modules Calling dexpreopt.GetGlobalConfig can return errors, move the checks that don't depend on dexpreopt.GetGlobalConfig first to avoid breaking all modules when the global config is invalid, for example in a partial branch that is missing the BootProfileImages file. Bug: 207813628 Test: tradefed branch builds Change-Id: Id1689de3f1ef986a41a60622cb357edb9d323b8a --- java/dexpreopt.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/java/dexpreopt.go b/java/dexpreopt.go index 7c081b6e5..f3a53eed9 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -122,13 +122,7 @@ func moduleName(ctx android.BaseModuleContext) string { } func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool { - global := dexpreopt.GetGlobalConfig(ctx) - - if global.DisablePreopt { - return true - } - - if inList(moduleName(ctx), global.DisablePreoptModules) { + if !ctx.Device() { return true } @@ -144,7 +138,17 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool { return true } - if ctx.Host() { + if !android.IsModulePreferred(ctx.Module()) { + return true + } + + global := dexpreopt.GetGlobalConfig(ctx) + + if global.DisablePreopt { + return true + } + + if inList(moduleName(ctx), global.DisablePreoptModules) { return true } @@ -161,10 +165,6 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool { } } - if !android.IsModulePreferred(ctx.Module()) { - return true - } - // TODO: contains no java code return false