Revert "Remove option to create boot image based on preloaded classes"

This reverts commit 4a0473175e51b0441a0adf3854326e21a9d67e75.

Reason for revert: NDK build broken

Change-Id: Id98bf9d5f82ed72d8c489264cf9d754e8ea1d27e
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 4758c7e..eb735c1 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -286,6 +286,8 @@
 	if profile != nil {
 		cmd.FlagWithArg("--compiler-filter=", "speed-profile")
 		cmd.FlagWithInput("--profile-file=", profile)
+	} else if global.PreloadedClasses.Valid() {
+		cmd.FlagWithInput("--image-classes=", global.PreloadedClasses.Path())
 	}
 
 	if global.DirtyImageObjects.Valid() {
@@ -372,7 +374,7 @@
 func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath {
 	global := dexpreoptGlobalConfig(ctx)
 
-	if ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
+	if !global.UseProfileForBootImage || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
 		return nil
 	}
 	return ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {