Merge "emulator: add check_emu_boot.mk, again"
diff --git a/core/Makefile b/core/Makefile
index 85ae96e..a3fbe33 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -2312,9 +2312,7 @@
 $(BUILT_TARGET_FILES_PACKAGE): PRIVATE_TOOL_EXTENSION := $(tool_extension)
 
 ifeq ($(AB_OTA_UPDATER),true)
-# Build zlib fingerprint if using the AB Updater.
-updater_dep := $(TARGET_OUT_COMMON_GEN)/zlib_fingerprint
-updater_dep += system/update_engine/update_engine.conf
+updater_dep := system/update_engine/update_engine.conf
 else
 # Build OTA tools if not using the AB Updater.
 updater_dep := $(built_ota_tools)
@@ -2547,7 +2545,6 @@
 ifeq ($(AB_OTA_UPDATER),true)
 	@# When using the A/B updater, include the updater config files in the zip.
 	$(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
-	$(hide) cp $(TARGET_OUT_COMMON_GEN)/zlib_fingerprint $(zip_root)/META/zlib_fingerprint.txt
 	$(hide) for part in $(AB_OTA_PARTITIONS); do \
 	  echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
 	done
diff --git a/core/config.mk b/core/config.mk
index 5fc0101..43eaf01 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -817,7 +817,12 @@
   DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
 endif
 
-FRAMEWORK_MANIFEST_FILE := system/libhidl/manifest.xml
+FRAMEWORK_MANIFEST_INPUT_FILES := system/libhidl/manifest.xml
+ifdef DEVICE_FRAMEWORK_MANIFEST_FILE
+  FRAMEWORK_MANIFEST_INPUT_FILES += $(DEVICE_FRAMEWORK_MANIFEST_FILE)
+endif
+$(.KATI_obsolete_var DEVICE_FRAMEWORK_MANIFEST_FILE,No one should ever need to use this.)
+
 FRAMEWORK_COMPATIBILITY_MATRIX_FILES := $(wildcard hardware/interfaces/compatibility_matrix.*.xml)
 
 BUILD_NUMBER_FROM_FILE := $$(cat $(OUT_DIR)/build_number.txt)
diff --git a/core/tasks/vndk.mk b/core/tasks/vndk.mk
index 1bbd3b0..fd7a696 100644
--- a/core/tasks/vndk.mk
+++ b/core/tasks/vndk.mk
@@ -17,6 +17,9 @@
 # BOARD_VNDK_VERSION must be set to 'current' in order to generate a VNDK snapshot.
 ifeq ($(BOARD_VNDK_VERSION),current)
 
+# PLATFORM_VNDK_VERSION must be set.
+ifneq (,$(PLATFORM_VNDK_VERSION))
+
 # Returns arch-specific libclang_rt.ubsan* library name.
 # Because VNDK_CORE_LIBRARIES includes all arch variants for libclang_rt.ubsan*
 # libs, the arch-specific libs are selected separately.
@@ -233,6 +236,15 @@
 # vndk_snapshot_arch_2ND :=
 # endif
 
+else # PLATFORM_VNDK_VERSION is NOT set
+
+.PHONY: vndk
+vndk:
+	$(call echo-error,$(current_makefile),CANNOT generate VNDK snapshot. PLATFORM_VNDK_VERSION must be set.)
+	exit 1
+
+endif # PLATFORM_VNDK_VERSION
+
 else # BOARD_VNDK_VERSION is NOT set to 'current'
 
 .PHONY: vndk
diff --git a/target/board/Android.mk b/target/board/Android.mk
index fc32cd9..f4d6b93 100644
--- a/target/board/Android.mk
+++ b/target/board/Android.mk
@@ -89,8 +89,11 @@
 endif
 endif
 
-$(GEN): $(FRAMEWORK_MANIFEST_FILE) $(HOST_OUT_EXECUTABLES)/assemble_vintf
-	BOARD_SEPOLICY_VERS=$(BOARD_SEPOLICY_VERS) $(HOST_OUT_EXECUTABLES)/assemble_vintf -i $< -o $@ $(PRIVATE_FLAGS)
+$(GEN): PRIVATE_FRAMEWORK_MANIFEST_INPUT_FILES := $(FRAMEWORK_MANIFEST_INPUT_FILES)
+$(GEN): $(FRAMEWORK_MANIFEST_INPUT_FILES) $(HOST_OUT_EXECUTABLES)/assemble_vintf
+	BOARD_SEPOLICY_VERS=$(BOARD_SEPOLICY_VERS) $(HOST_OUT_EXECUTABLES)/assemble_vintf \
+		-i $(call normalize-path-list,$(PRIVATE_FRAMEWORK_MANIFEST_INPUT_FILES)) \
+		-o $@ $(PRIVATE_FLAGS)
 
 LOCAL_PREBUILT_MODULE_FILE := $(GEN)
 include $(BUILD_PREBUILT)
diff --git a/target/product/treble_common.mk b/target/product/treble_common.mk
index 7ff5acb..c385352 100644
--- a/target/product/treble_common.mk
+++ b/target/product/treble_common.mk
@@ -87,3 +87,7 @@
     system/core/rootdir/etc/ld.config.txt:system/etc/ld.config.noenforce.txt \
     build/make/target/product/vndk/init.gsi.rc:system/etc/init/init.gsi.rc \
     build/make/target/product/vndk/init.noenforce.rc:system/etc/init/gsi/init.noenforce.rc
+
+#Set current VNDK version for GSI
+PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \
+    ro.gsi.vndk.version=$(PLATFORM_VNDK_VERSION)
diff --git a/target/product/vndk/init.noenforce.rc b/target/product/vndk/init.noenforce.rc
index 9371cc8..6cf1df7 100644
--- a/target/product/vndk/init.noenforce.rc
+++ b/target/product/vndk/init.noenforce.rc
@@ -1,3 +1,5 @@
 on early-init
     # If ro.vndk.version is not set, use ld.config.nonenforce.txt
     export LD_CONFIG_FILE /system/etc/ld.config.noenforce.txt
+    # To use current VNDK libs, set ro.vndk.version to system vndk version
+    setprop ro.vndk.version ${ro.gsi.vndk.version}
diff --git a/tools/auto_gen_test_config.py b/tools/auto_gen_test_config.py
index fa018f4..da4443c 100755
--- a/tools/auto_gen_test_config.py
+++ b/tools/auto_gen_test_config.py
@@ -24,7 +24,7 @@
 
 ATTRIBUTE_LABEL = 'android:label'
 ATTRIBUTE_RUNNER = 'android:name'
-ATTRIBUTE_TARGET_PACKAGE = 'android:targetPackage'
+ATTRIBUTE_PACKAGE = 'package'
 
 PLACEHOLDER_LABEL = '{LABEL}'
 PLACEHOLDER_MODULE = '{MODULE}'
@@ -54,20 +54,22 @@
 
   manifest = parse(android_manifest)
   instrumentation_elements = manifest.getElementsByTagName('instrumentation')
-  if len(instrumentation_elements) != 1:
-    # Failed to locate instrumentation element in AndroidManifest file.
-    # Empty test config file will be created.
+  manifest_elements = manifest.getElementsByTagName('manifest')
+  if len(instrumentation_elements) != 1 or len(manifest_elements) != 1:
+    # Failed to locate instrumentation or manifest element in AndroidManifest.
+    # file. Empty test config file will be created.
     shutil.copyfile(empty_config, target_config)
     return 0
 
   module = os.path.splitext(os.path.basename(target_config))[0]
   instrumentation = instrumentation_elements[0]
+  manifest = manifest_elements[0]
   if instrumentation.attributes.has_key(ATTRIBUTE_LABEL):
     label = instrumentation.attributes[ATTRIBUTE_LABEL].value
   else:
     label = module
   runner = instrumentation.attributes[ATTRIBUTE_RUNNER].value
-  package = instrumentation.attributes[ATTRIBUTE_TARGET_PACKAGE].value
+  package = manifest.attributes[ATTRIBUTE_PACKAGE].value
   test_type = ('AndroidJUnitTest' if runner.endswith('.AndroidJUnitRunner')
                else 'InstrumentationTest')
 
diff --git a/tools/auto_gen_test_config_test.py b/tools/auto_gen_test_config_test.py
index a438b73..e70eff8 100644
--- a/tools/auto_gen_test_config_test.py
+++ b/tools/auto_gen_test_config_test.py
@@ -31,7 +31,8 @@
 """
 
 MANIFEST_JUNIT_TEST = """<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+  package="com.android.my.tests.x">
     <instrumentation
         android:name="android.support.test.runner.AndroidJUnitRunner"
         android:targetPackage="com.android.my.tests" />
@@ -39,7 +40,8 @@
 """
 
 MANIFEST_INSTRUMENTATION_TEST = """<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+  package="com.android.my.tests.x">
     <instrumentation
         android:name="android.test.InstrumentationTestRunner"
         android:targetPackage="com.android.my.tests"
@@ -69,7 +71,7 @@
     </target_preparer>
 
     <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
-        <option name="package" value="com.android.my.tests" />
+        <option name="package" value="com.android.my.tests.x" />
         <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
     </test>
 </configuration>
@@ -97,16 +99,17 @@
     </target_preparer>
 
     <test class="com.android.tradefed.testtype.InstrumentationTest" >
-        <option name="package" value="com.android.my.tests" />
+        <option name="package" value="com.android.my.tests.x" />
         <option name="runner" value="android.test.InstrumentationTestRunner" />
     </test>
 </configuration>
 """
 
-MAKE_ROOT = os.path.dirname(os.path.dirname(__file__))
-EMPTY_TEST_CONFIG = os.path.join(MAKE_ROOT, 'core', 'empty_test_config.xml')
+TOOLS_DIR = os.path.dirname(os.path.dirname(__file__))
+EMPTY_TEST_CONFIG = os.path.join(
+    TOOLS_DIR, '..', 'core', 'empty_test_config.xml')
 INSTRUMENTATION_TEST_CONFIG_TEMPLATE = os.path.join(
-    MAKE_ROOT, 'core', 'instrumentation_test_config_template.xml')
+    TOOLS_DIR, '..', 'core', 'instrumentation_test_config_template.xml')
 
 
 class AutoGenTestConfigUnittests(unittest.TestCase):