Merge "Allow system server jars for WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY" into oc-mr1-dev
diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk
index c30ddff..cfcfca5 100644
--- a/core/dex_preopt_odex_install.mk
+++ b/core/dex_preopt_odex_install.mk
@@ -145,16 +145,19 @@
 ifndef LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING
 $(call pretty-error,Must have specified class listing (LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING))
 endif
+ifeq (,$(dex_preopt_profile_src_file))
+$(call pretty-error, Internal error: dex_preopt_profile_src_file must be set)
+endif
 my_built_profile := $(dir $(LOCAL_BUILT_MODULE))/profile.prof
 my_dex_location := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
 $(built_odex): $(my_built_profile)
 $(built_odex): PRIVATE_PROFILE_PREOPT_FLAGS := --profile-file=$(my_built_profile)
-$(my_built_profile): PRIVATE_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
+$(my_built_profile): PRIVATE_BUILT_MODULE := $(dex_preopt_profile_src_file)
 $(my_built_profile): PRIVATE_DEX_LOCATION := $(my_dex_location)
 $(my_built_profile): PRIVATE_SOURCE_CLASSES := $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)
 $(my_built_profile): $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)
 $(my_built_profile): $(PROFMAN)
-$(my_built_profile): $(LOCAL_BUILT_MODULE)
+$(my_built_profile): $(dex_preopt_profile_src_file)
 $(my_built_profile):
 	$(hide) mkdir -p $(dir $@)
 	ANDROID_LOG_TAGS="*:e" $(PROFMAN) \
@@ -162,6 +165,7 @@
 		--apk=$(PRIVATE_BUILT_MODULE) \
 		--dex-location=$(PRIVATE_DEX_LOCATION) \
 		--reference-profile-file=$@
+dex_preopt_profile_src_file:=
 my_installed_profile := $(LOCAL_INSTALLED_MODULE).prof
 $(eval $(call copy-one-file,$(my_built_profile),$(my_installed_profile)))
 build_installed_profile:=$(my_built_profile):$(my_installed_profile)
diff --git a/core/java.mk b/core/java.mk
index 8fde7c2..3601292 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -381,6 +381,19 @@
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_RS_SOURCES := $(if $(renderscript_sources),true)
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RS_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/renderscript
 
+# Set the profile source so that the odex / profile code included from java.mk
+# can find it.
+#
+# TODO: b/64896089, this is broken when called from package_internal.mk, since the file
+# we preopt from is a temporary file. This will be addressed in a follow up, possibly
+# by disabling stripping for profile guided preopt (which may be desirable for other
+# reasons anyway).
+#
+# Note that we set this only when called from package_internal.mk and not in other cases.
+ifneq (,$(called_from_package_internal)
+dex_preopt_profile_src_file := $(LOCAL_BUILT_MODULE)
+endif
+
 #######################################
 # defines built_odex along with rule to install odex
 include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
diff --git a/core/java_library.mk b/core/java_library.mk
index 0aad84c..84f4419 100644
--- a/core/java_library.mk
+++ b/core/java_library.mk
@@ -44,6 +44,7 @@
 # java libraries produce javalib.jar, so we will copy classes.jar there too.
 intermediates.COMMON := $(call local-intermediates-dir,COMMON)
 common_javalib.jar := $(intermediates.COMMON)/javalib.jar
+dex_preopt_profile_src_file := $(common_javalib.jar)
 LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar)
 
 ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
diff --git a/core/package_internal.mk b/core/package_internal.mk
index 2eb806c..87a15d2 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -327,9 +327,11 @@
 
 include $(BUILD_SYSTEM)/android_manifest.mk
 
+called_from_package_internal := true
 #################################
 include $(BUILD_SYSTEM)/java.mk
 #################################
+called_from_package_internal :=
 
 LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
 ifeq ($(LOCAL_SDK_RES_VERSION),)
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index 48593a5..a9c0bc2 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -283,6 +283,8 @@
 my_extract_apk :=
 endif
 
+dex_preopt_profile_src_file := $(my_prebuilt_src_file)
+
 rs_compatibility_jni_libs :=
 include $(BUILD_SYSTEM)/install_jni_libs.mk
 
diff --git a/target/board/Android.mk b/target/board/Android.mk
index 331367f..5504c52 100644
--- a/target/board/Android.mk
+++ b/target/board/Android.mk
@@ -131,12 +131,17 @@
 endif
 
 # All kernel versions that the system image works with.
-$(GEN): test/vts-testcase/kernel/config/data/android-3.18/android-base.cfg
-$(GEN): test/vts-testcase/kernel/config/data/android-4.4/android-base.cfg
-$(GEN): test/vts-testcase/kernel/config/data/android-4.9/android-base.cfg
-$(GEN): PRIVATE_FLAGS += --kernel=3.18:test/vts-testcase/kernel/config/data/android-3.18/android-base.cfg
-$(GEN): PRIVATE_FLAGS += --kernel=4.4:test/vts-testcase/kernel/config/data/android-4.4/android-base.cfg
-$(GEN): PRIVATE_FLAGS += --kernel=4.9:test/vts-testcase/kernel/config/data/android-4.9/android-base.cfg
+KERNEL_VERSIONS := 3.18 4.4 4.9
+KERNEL_CONFIG_DATA := test/vts-testcase/kernel/config/data
+
+$(GEN): $(foreach version,$(KERNEL_VERSIONS),\
+	$(wildcard $(KERNEL_CONFIG_DATA)/android-$(version)/android-base*.cfg))
+$(GEN): PRIVATE_FLAGS += $(foreach version,$(KERNEL_VERSIONS),\
+	--kernel=$(version):$(call normalize-path-list,\
+		$(wildcard $(KERNEL_CONFIG_DATA)/android-$(version)/android-base*.cfg)))
+
+KERNEL_VERSIONS :=
+KERNEL_CONFIG_DATA :=
 
 $(GEN): $(FRAMEWORK_COMPATIBILITY_MATRIX_FILE) $(HOST_OUT_EXECUTABLES)/assemble_vintf
 	# TODO(b/37405869) (b/37715375) inject avb versions as well for devices that have avb enabled.
diff --git a/target/product/treble_common.mk b/target/product/treble_common.mk
index 2488653..070486d 100644
--- a/target/product/treble_common.mk
+++ b/target/product/treble_common.mk
@@ -54,6 +54,13 @@
 PRODUCT_PACKAGES += \
     netutils-wrapper-1.0
 
+# A workaround solution for some projects which require
+# TimeZoneRulesManagerService by overlaying resource property
+# "config_enableUpdateableTimeZoneRules"
+PRODUCT_PACKAGES += \
+    TimeZoneUpdater \
+    TimeZoneData \
+
 # Android Verified Boot (AVB):
 #   Builds a special vbmeta.img that disables AVB verification.
 #   Otherwise, AVB will prevent the device from booting the generic system.img.