Merge "Use the apex image when the device config asks for it." am: 56405f8071
am: b32c872116

Change-Id: Ic40b3c44bc9c9d85f532878475f14489d5743069
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 15008b9..f1fa0ff 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -32,6 +32,7 @@
 	OnlyPreoptBootImageAndSystemServer bool // only preopt jars in the boot image or system server
 
 	GenerateApexImage bool // generate an extra boot image only containing jars from the runtime apex
+	UseApexImage      bool // use the apex image by default
 
 	HasSystemOther        bool     // store odex files that match PatternsOnSystemOther on the system_other partition
 	PatternsOnSystemOther []string // patterns (using '%' to denote a prefix match) to put odex on the system_other partition
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index ecb2421..6b93c10 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -98,6 +98,9 @@
 
 	global := dexpreoptGlobalConfig(ctx)
 	bootImage := defaultBootImageConfig(ctx)
+	if global.UseApexImage {
+		bootImage = apexBootImageConfig(ctx)
+	}
 
 	var archs []android.ArchType
 	for _, a := range ctx.MultiTargets() {