Merge "Adds --output-img flag to enable building the IMG package."
diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk
index 8017486..180edaf 100644
--- a/core/dex_preopt.mk
+++ b/core/dex_preopt.mk
@@ -22,19 +22,28 @@
 $(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE :=
 $(foreach my_boot_image_name,$(DEXPREOPT_IMAGE_NAMES),$(eval include $(BUILD_SYSTEM)/dex_preopt_libart.mk))
 
-boot_profile_jars_zip := $(PRODUCT_OUT)/boot_profile_jars.zip
+# Build the boot.zip which contains the boot jars and their compilation output
+# We can do this only if preopt is enabled and if the product uses libart config (which sets the
+# default properties for preopting).
+ifeq ($(WITH_DEXPREOPT), true)
+ifeq ($(PRODUCT_USES_ART), true)
+
+boot_zip := $(PRODUCT_OUT)/boot.zip
 bootclasspath_jars := $(DEXPREOPT_BOOTCLASSPATH_DEX_FILES)
 system_server_jars := $(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),$(PRODUCT_OUT)/system/framework/$(m).jar)
 
-$(boot_profile_jars_zip): PRIVATE_BOOTCLASSPATH_JARS := $(bootclasspath_jars)
-$(boot_profile_jars_zip): PRIVATE_SYSTEM_SERVER_JARS := $(system_server_jars)
-$(boot_profile_jars_zip): $(bootclasspath_jars) $(system_server_jars) $(SOONG_ZIP)
-	@echo "Create boot profiles package: $@"
+$(boot_zip): PRIVATE_BOOTCLASSPATH_JARS := $(bootclasspath_jars)
+$(boot_zip): PRIVATE_SYSTEM_SERVER_JARS := $(system_server_jars)
+$(boot_zip): $(bootclasspath_jars) $(system_server_jars) $(SOONG_ZIP) $(MERGE_ZIPS) $(DEXPREOPT_IMAGE_ZIP_boot)
+	@echo "Create boot package: $@"
 	rm -f $@
-	$(SOONG_ZIP) -o $@ \
+	$(SOONG_ZIP) -o $@.tmp \
 	  -C $(dir $(firstword $(PRIVATE_BOOTCLASSPATH_JARS)))/.. $(addprefix -f ,$(PRIVATE_BOOTCLASSPATH_JARS)) \
 	  -C $(PRODUCT_OUT) $(addprefix -f ,$(PRIVATE_SYSTEM_SERVER_JARS))
+	$(MERGE_ZIPS) $@ $@.tmp $(DEXPREOPT_IMAGE_ZIP_boot)
+	rm -f $@.tmp
 
-ifeq ($(PRODUCT_DIST_BOOT_AND_SYSTEM_JARS),true)
-$(call dist-for-goals, droidcore, $(boot_profile_jars_zip))
-endif
+$(call dist-for-goals, droidcore, $(boot_zip))
+
+endif  #PRODUCT_USES_ART
+endif  #WITH_DEXPREOPT
diff --git a/core/force_aapt2.mk b/core/force_aapt2.mk
index 816138a..25b45e4 100644
--- a/core/force_aapt2.mk
+++ b/core/force_aapt2.mk
@@ -39,8 +39,8 @@
 endif
 
 # AAPT2 is pickier about missing resources.  Support library may have references to resources
-# added in current, so always treat LOCAL_SDK_VERSION as LOCAL_SDK_RES_VERSION := current.
-ifdef LOCAL_SDK_VERSION
+# added in current, so always treat LOCAL_SDK_VERSION := <number> as LOCAL_SDK_RES_VERSION := current.
+ifneq (,$(filter-out current system_current test_current core_current,$(LOCAL_SDK_VERSION)))
   LOCAL_SDK_RES_VERSION := current
 endif
 
diff --git a/core/product.mk b/core/product.mk
index 777d2bc..192d58c 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -245,6 +245,7 @@
 _product_var_list += \
     PRODUCT_USE_PROFILE_FOR_BOOT_IMAGE \
     PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION \
+    PRODUCT_USES_ART \
 
 _product_var_list += PRODUCT_SYSTEM_SERVER_COMPILER_FILTER
 # Per-module sanitizer configs
diff --git a/core/soong_config.mk b/core/soong_config.mk
index c01fc98..46e026a 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -165,7 +165,7 @@
 $(call add_json_list, ProductHiddenAPIStubsSystem,       $(PRODUCT_HIDDENAPI_STUBS_SYSTEM))
 $(call add_json_list, ProductHiddenAPIStubsTest,         $(PRODUCT_HIDDENAPI_STUBS_TEST))
 
-$(call add_json_str,  TargetFSConfigGen,                 $(TARGET_FS_CONFIG_GEN))
+$(call add_json_list, TargetFSConfigGen,                 $(TARGET_FS_CONFIG_GEN))
 
 $(call add_json_map, VendorVars)
 $(foreach namespace,$(SOONG_CONFIG_NAMESPACES),\
diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk
index e08b56b..5aa2114 100644
--- a/target/product/runtime_libart.mk
+++ b/target/product/runtime_libart.mk
@@ -91,3 +91,9 @@
 PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \
     dalvik.vm.minidebuginfo=true \
     dalvik.vm.dex2oat-minidebuginfo=true
+
+# Disable iorapd by default
+PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \
+    ro.iorapd.enable=false
+
+PRODUCT_USES_ART := true
diff --git a/tools/fs_config/Android.bp b/tools/fs_config/Android.bp
index d6fae2d..d9a48d7 100644
--- a/tools/fs_config/Android.bp
+++ b/tools/fs_config/Android.bp
@@ -42,7 +42,7 @@
 genrule {
     name: "oemaids_header_gen",
     tool_files: ["fs_config_generator.py"],
-    cmd: "$(location fs_config_generator.py) oemaid --aid-header=$(location :android_filesystem_config_header) $(location :target_fs_config_gen) >$(out)",
+    cmd: "$(location fs_config_generator.py) oemaid --aid-header=$(location :android_filesystem_config_header) $(locations :target_fs_config_gen) >$(out)",
     srcs: [
         ":target_fs_config_gen",
         ":android_filesystem_config_header",
@@ -62,7 +62,7 @@
 genrule {
     name: "passwd_gen",
     tool_files: ["fs_config_generator.py"],
-    cmd: "$(location fs_config_generator.py) passwd --required-prefix=vendor_ --aid-header=$(location :android_filesystem_config_header) $(location :target_fs_config_gen) >$(out)",
+    cmd: "$(location fs_config_generator.py) passwd --required-prefix=vendor_ --aid-header=$(location :android_filesystem_config_header) $(locations :target_fs_config_gen) >$(out)",
     srcs: [
         ":target_fs_config_gen",
         ":android_filesystem_config_header",
@@ -82,7 +82,7 @@
 genrule {
     name: "group_gen",
     tool_files: ["fs_config_generator.py"],
-    cmd: "$(location fs_config_generator.py) group --required-prefix=vendor_ --aid-header=$(location :android_filesystem_config_header) $(location :target_fs_config_gen) >$(out)",
+    cmd: "$(location fs_config_generator.py) group --required-prefix=vendor_ --aid-header=$(location :android_filesystem_config_header) $(locations :target_fs_config_gen) >$(out)",
     srcs: [
         ":target_fs_config_gen",
         ":android_filesystem_config_header",
diff --git a/tools/fs_config/fs_config.go b/tools/fs_config/fs_config.go
index 869cb3d..16bcefa 100644
--- a/tools/fs_config/fs_config.go
+++ b/tools/fs_config/fs_config.go
@@ -24,7 +24,7 @@
 	android.RegisterModuleType("target_fs_config_gen_filegroup", targetFSConfigGenFactory)
 }
 
-// target_fs_config_gen_filegroup is used to expose the file pointed to by TARGET_FS_CONFIG_GEN to
+// target_fs_config_gen_filegroup is used to expose the files pointed to by TARGET_FS_CONFIG_GEN to
 // genrules in Soong. If TARGET_FS_CONFIG_GEN is empty, it will export an empty file instead.
 func targetFSConfigGenFactory() android.Module {
 	module := &targetFSConfigGen{}
@@ -36,17 +36,17 @@
 
 type targetFSConfigGen struct {
 	android.ModuleBase
-	path android.Path
+	paths android.Paths
 }
 
 func (targetFSConfigGen) DepsMutator(ctx android.BottomUpMutatorContext) {}
 
 func (t *targetFSConfigGen) GenerateAndroidBuildActions(ctx android.ModuleContext) {
-	if ret := ctx.DeviceConfig().TargetFSConfigGen(); ret != nil && *ret != "" {
-		t.path = android.PathForSource(ctx, *ret)
+	if ret := ctx.DeviceConfig().TargetFSConfigGen(); len(ret) != 0 {
+		t.paths = android.PathsForSource(ctx, ret)
 	} else {
 		path := android.PathForModuleGen(ctx, "empty")
-		t.path = path
+		t.paths = android.Paths{path}
 
 		rule := android.NewRuleBuilder()
 		rule.Command().Text("rm -rf").Output(path)
@@ -56,5 +56,5 @@
 }
 
 func (t *targetFSConfigGen) Srcs() android.Paths {
-	return android.Paths{t.path}
+	return t.paths
 }