Merge "Move build.prop to ./etc subdir for some partitions"
diff --git a/core/Makefile b/core/Makefile
index 8ac4e0d..2f5b621 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -407,6 +407,16 @@
 
 endef
 
+# -----------------------------------------------------------------
+# Merge an individual apkcerts output into the final apkcerts.txt output.
+# Use a macro to make it compatible with _apkcerts_write_line
+# $1 apkcerts file to be merged
+# $2 output file
+define _apkcerts_merge
+$(hide) cat $1 >> $2
+
+endef
+
 name := $(TARGET_PRODUCT)
 ifeq ($(TARGET_BUILD_TYPE),debug)
   name := $(name)_debug
@@ -415,6 +425,8 @@
 intermediates := \
 	$(call intermediates-dir-for,PACKAGING,apkcerts)
 APKCERTS_FILE := $(intermediates)/$(name).txt
+all_apkcerts_files := $(sort $(foreach p,$(PACKAGES),$(PACKAGES.$(p).APKCERTS_FILE)))
+$(APKCERTS_FILE): $(all_apkcerts_files)
 # We don't need to really build all the modules.
 # TODO: rebuild APKCERTS_FILE if any app change its cert.
 $(APKCERTS_FILE):
@@ -422,9 +434,11 @@
 	@mkdir -p $(dir $@)
 	@rm -f $@
 	$(foreach p,$(sort $(PACKAGES)),\
-	  $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
-	    $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
-	    $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@)))
+	  $(if $(PACKAGES.$(p).APKCERTS_FILE),\
+	    $(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
+	    $(if $(PACKAGES.$(p).EXTERNAL_KEY),\
+	      $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),"EXTERNAL","",$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
+	      $(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@))))
 	# In case value of PACKAGES is empty.
 	$(hide) touch $@
 
diff --git a/core/binary.mk b/core/binary.mk
index 200724a..a70a047 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -286,8 +286,7 @@
 endif
 
 ifneq ($(LOCAL_SDK_VERSION),)
-  my_all_ndk_libraries := \
-      $(NDK_MIGRATED_LIBS) $(addprefix lib,$(NDK_PREBUILT_SHARED_LIBRARIES))
+  my_all_ndk_libraries := $(NDK_KNOWN_LIBS)
   my_ndk_shared_libraries := \
       $(filter $(my_all_ndk_libraries),\
         $(my_shared_libraries) $(my_system_shared_libraries))
@@ -1354,7 +1353,7 @@
 # lists and use addprefix.
 my_ndk_shared_libraries_fullpath := \
     $(foreach _lib,$(my_ndk_shared_libraries),\
-        $(if $(filter $(NDK_MIGRATED_LIBS),$(_lib)),\
+        $(if $(filter $(NDK_KNOWN_LIBS),$(_lib)),\
             $(my_built_ndk_libs)/$(_lib)$(so_suffix),\
             $(my_ndk_sysroot_lib)/$(_lib)$(so_suffix)))
 
@@ -1555,7 +1554,7 @@
 my_allowed_ldlibs :=
 ifndef LOCAL_IS_HOST_MODULE
   ifneq ($(LOCAL_SDK_VERSION),)
-    my_allowed_ldlibs := $(addprefix -l,$(NDK_PREBUILT_SHARED_LIBRARIES))
+    my_allowed_ldlibs := $(NDK_KNOWN_LIBS:lib%=-l%)
   endif
 else
   my_allowed_ldlibs := $($(my_prefix)AVAILABLE_LIBRARIES)
diff --git a/core/cc_prebuilt_internal.mk b/core/cc_prebuilt_internal.mk
index 99b7d0f..e8e01d8 100644
--- a/core/cc_prebuilt_internal.mk
+++ b/core/cc_prebuilt_internal.mk
@@ -65,7 +65,7 @@
   built_module := $(linked_module)
 
   ifneq ($(LOCAL_SDK_VERSION),)
-    # binary.mk filters out NDK_MIGRATED_LIBS from my_shared_libs, thus those NDK libs are not added
+    # binary.mk filters out NDK_KNOWN_LIBS from my_shared_libs, thus those NDK libs are not added
     # to DEPENDENCIES_ON_SHARED_LIBRARIES. Assign $(my_ndk_shared_libraries_fullpath) to
     # my_check_elf_file_shared_lib_files so that check_elf_file.py can see those NDK stub libs.
     my_check_elf_file_shared_lib_files := $(my_ndk_shared_libraries_fullpath)
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index c88a1cd..20319a8 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -22,6 +22,7 @@
 LOCAL_APIDIFF_OLDAPI:=
 LOCAL_APK_LIBRARIES:=
 LOCAL_APK_SET_MASTER_FILE:=
+LOCAL_APKCERTS_FILE:=
 LOCAL_ARM_MODE:=
 LOCAL_ASFLAGS:=
 LOCAL_ASSET_DIR:=
diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk
index 440ffd9..f738c3e 100644
--- a/core/dex_preopt_odex_install.mk
+++ b/core/dex_preopt_odex_install.mk
@@ -189,8 +189,8 @@
   my_filtered_optional_uses_libraries := $(filter-out $(INTERNAL_PLATFORM_MISSING_USES_LIBRARIES), \
     $(LOCAL_OPTIONAL_USES_LIBRARIES))
 
-  # dexpreopt needs the paths to the dex jars of these libraries in case
-  # construct_context.sh needs to pass them to dex2oat.
+  # dexpreopt needs the paths to the dex jars of these libraries in order to
+  # construct class loader context for dex2oat.
   my_extra_dexpreopt_libs := \
     org.apache.http.legacy \
     android.hidl.base-V1.0-java \
diff --git a/core/java.mk b/core/java.mk
index 9d42775..2f18ad9 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -393,7 +393,7 @@
 else
   # For platform build, we can't just raise to the "current" SDK,
   # that would break apps that use APIs removed from the current SDK.
-  my_proguard_sdk_raise := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES))
+  my_proguard_sdk_raise := $(call java-lib-header-files,$(LEGACY_CORE_PLATFORM_BOOTCLASSPATH_LIBRARIES) $(FRAMEWORK_LIBRARIES))
 endif
 ifdef BOARD_SYSTEMSDK_VERSIONS
 ifneq (,$(filter true,$(LOCAL_VENDOR_MODULE) $(LOCAL_ODM_MODULE) $(LOCAL_PROPRIETARY_MODULE)))
diff --git a/core/java_common.mk b/core/java_common.mk
index b218c0d..658296d 100644
--- a/core/java_common.mk
+++ b/core/java_common.mk
@@ -265,11 +265,11 @@
       # Most users of LOCAL_NO_STANDARD_LIBRARIES really mean no framework libs,
       # and manually add back the core libs.  The ones that don't are in soong
       # now, so just always assume that they want the default system modules
-      my_system_modules := $(DEFAULT_SYSTEM_MODULES)
+      my_system_modules := $(LEGACY_CORE_PLATFORM_SYSTEM_MODULES)
     else  # LOCAL_NO_STANDARD_LIBRARIES
-      full_java_bootclasspath_libs := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES))
-      LOCAL_JAVA_LIBRARIES := $(filter-out $(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES),$(LOCAL_JAVA_LIBRARIES))
-      my_system_modules := $(DEFAULT_SYSTEM_MODULES)
+      full_java_bootclasspath_libs := $(call java-lib-header-files,$(LEGACY_CORE_PLATFORM_BOOTCLASSPATH_LIBRARIES) $(FRAMEWORK_LIBRARIES))
+      LOCAL_JAVA_LIBRARIES := $(filter-out $(LEGACY_CORE_PLATFORM_BOOTCLASSPATH_LIBRARIES) $(FRAMEWORK_LIBRARIES),$(LOCAL_JAVA_LIBRARIES))
+      my_system_modules := $(LEGACY_CORE_PLATFORM_SYSTEM_MODULES)
     endif  # LOCAL_NO_STANDARD_LIBRARIES
 
     ifneq (,$(TARGET_BUILD_APPS_USE_PREBUILT_SDK))
@@ -352,10 +352,10 @@
     ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
       empty_bootclasspath := ""
     else
-      full_java_bootclasspath_libs := $(call java-lib-header-files,$(addsuffix -hostdex,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES)),true)
+      full_java_bootclasspath_libs := $(call java-lib-header-files,$(addsuffix -hostdex,$(LEGACY_CORE_PLATFORM_BOOTCLASSPATH_LIBRARIES)),true)
     endif
 
-    my_system_modules := $(DEFAULT_SYSTEM_MODULES)
+    my_system_modules := $(LEGACY_CORE_PLATFORM_SYSTEM_MODULES)
     full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),true)
     full_shared_java_header_libs := $(call java-lib-header-files,$(LOCAL_JAVA_LIBRARIES),true)
   else # !USE_CORE_LIB_BOOTCLASSPATH
diff --git a/core/main.mk b/core/main.mk
index cc7cf72..812cce0 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -779,10 +779,13 @@
     $(eval req_files := )\
     $(foreach req_mod,$(req_mods), \
       $(eval req_file := $(filter $(TARGET_OUT_ROOT)/%, $(call module-installed-files,$(req_mod)))) \
-      $(if $(strip $(req_file)),\
-        ,\
-        $(error $(m).LOCAL_TARGET_REQUIRED_MODULES : illegal value $(req_mod) : not a device module. If you want to specify host modules to be required to be installed along with your host module, add those module names to LOCAL_REQUIRED_MODULES instead)\
-      )\
+      $(if $(filter true,$(ALLOW_MISSING_DEPENDENCIES)), \
+        , \
+        $(if $(strip $(req_file)), \
+          , \
+          $(error $(m).LOCAL_TARGET_REQUIRED_MODULES : illegal value $(req_mod) : not a device module. If you want to specify host modules to be required to be installed along with your host module, add those module names to LOCAL_REQUIRED_MODULES instead) \
+        ) \
+      ) \
       $(eval req_files := $(req_files)$(space)$(req_file))\
     )\
     $(eval req_files := $(strip $(req_files)))\
@@ -805,10 +808,13 @@
     $(eval req_files := )\
     $(foreach req_mod,$(req_mods), \
       $(eval req_file := $(filter $(HOST_OUT)/%, $(call module-installed-files,$(req_mod)))) \
-      $(if $(strip $(req_file)),\
-        ,\
-        $(error $(m).LOCAL_HOST_REQUIRED_MODULES : illegal value $(req_mod) : not a host module. If you want to specify target modules to be required to be installed along with your target module, add those module names to LOCAL_REQUIRED_MODULES instead)\
-      )\
+      $(if $(filter true,$(ALLOW_MISSING_DEPENDENCIES)), \
+        , \
+        $(if $(strip $(req_file)), \
+          , \
+          $(error $(m).LOCAL_HOST_REQUIRED_MODULES : illegal value $(req_mod) : not a host module. If you want to specify target modules to be required to be installed along with your target module, add those module names to LOCAL_REQUIRED_MODULES instead) \
+        ) \
+      ) \
       $(eval req_files := $(req_files)$(space)$(req_file))\
     )\
     $(eval req_files := $(strip $(req_files)))\
@@ -1671,7 +1677,11 @@
     $(INSTALLED_FILES_JSON_SYSTEMOTHER) \
     $(INSTALLED_FILES_FILE_RECOVERY) \
     $(INSTALLED_FILES_JSON_RECOVERY) \
-    $(INSTALLED_BUILD_PROP_TARGET) \
+    $(INSTALLED_BUILD_PROP_TARGET):build.prop \
+    $(INSTALLED_VENDOR_BUILD_PROP_TARGET):build.prop-vendor \
+    $(INSTALLED_PRODUCT_BUILD_PROP_TARGET):build.prop-product \
+    $(INSTALLED_ODM_BUILD_PROP_TARGET):build.prop-odm \
+    $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET):build.prop-system_ext \
     $(BUILT_TARGET_FILES_PACKAGE) \
     $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
     $(INSTALLED_MISC_INFO_TARGET) \
diff --git a/core/soong_android_app_set.mk b/core/soong_android_app_set.mk
index eb8e5e7..c884894 100644
--- a/core/soong_android_app_set.mk
+++ b/core/soong_android_app_set.mk
@@ -31,17 +31,9 @@
 $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
 PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
 
-# android_app_set modules are always presigned
-PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
 PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
-
-ifneq ($(LOCAL_MODULE_STEM),)
-  PACKAGES.$(LOCAL_MODULE).STEM := $(LOCAL_MODULE_STEM)
-else
-  PACKAGES.$(LOCAL_MODULE).STEM := $(LOCAL_MODULE)
-endif
-
-# Set a actual_partition_tag (calculated in base_rules.mk) for the package.
-PACKAGES.$(LOCAL_MODULE).PARTITION := $(actual_partition_tag)
+# We can't know exactly what apk files would be outputted yet.
+# Let extract_apks generate apkcerts.txt and merge it later.
+PACKAGES.$(LOCAL_MODULE).APKCERTS_FILE := $(LOCAL_APKCERTS_FILE)
 
 SOONG_ALREADY_CONV += $(LOCAL_MODULE)
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
index d375780..8ebfdd8 100644
--- a/core/version_defaults.mk
+++ b/core/version_defaults.mk
@@ -237,7 +237,7 @@
     #  It must be of the form "YYYY-MM-DD" on production devices.
     #  It must match one of the Android Security Patch Level strings of the Public Security Bulletins.
     #  If there is no $PLATFORM_SECURITY_PATCH set, keep it empty.
-      PLATFORM_SECURITY_PATCH := 2020-06-05
+      PLATFORM_SECURITY_PATCH := 2020-07-05
 endif
 .KATI_READONLY := PLATFORM_SECURITY_PATCH
 
diff --git a/rbesetup.sh b/rbesetup.sh
index 7e9b2ea..145e1e8 100644
--- a/rbesetup.sh
+++ b/rbesetup.sh
@@ -4,7 +4,7 @@
 # for the build to be executed with RBE.
 function use_rbe() {
   local RBE_LOG_DIR="/tmp"
-  local RBE_BINARIES_DIR="prebuilts/remoteexecution-client/latest/"
+  local RBE_BINARIES_DIR="prebuilts/remoteexecution-client/latest"
   local DOCKER_IMAGE="gcr.io/androidbuild-re-dockerimage/android-build-remoteexec-image@sha256:582efb38f0c229ea39952fff9e132ccbe183e14869b39888010dacf56b360d62"
 
   # Do not set an invocation-ID and let reproxy auto-generate one.
diff --git a/target/product/gsi/current.txt b/target/product/gsi/current.txt
index cd4d750..d66136e 100644
--- a/target/product/gsi/current.txt
+++ b/target/product/gsi/current.txt
@@ -50,172 +50,29 @@
 VNDK-SP: libutils.so
 VNDK-SP: libutilscallstack.so
 VNDK-SP: libz.so
-VNDK-core: android.frameworks.cameraservice.common@2.0.so
-VNDK-core: android.frameworks.cameraservice.device@2.0.so
-VNDK-core: android.frameworks.cameraservice.service@2.0.so
-VNDK-core: android.frameworks.displayservice@1.0.so
-VNDK-core: android.frameworks.schedulerservice@1.0.so
-VNDK-core: android.frameworks.sensorservice@1.0.so
-VNDK-core: android.frameworks.stats@1.0.so
-VNDK-core: android.hardware.atrace@1.0.so
 VNDK-core: android.hardware.audio.common@2.0.so
-VNDK-core: android.hardware.audio.common@4.0.so
-VNDK-core: android.hardware.audio.common@5.0.so
-VNDK-core: android.hardware.audio.common@6.0.so
-VNDK-core: android.hardware.audio.effect@2.0.so
-VNDK-core: android.hardware.audio.effect@4.0.so
-VNDK-core: android.hardware.audio.effect@5.0.so
-VNDK-core: android.hardware.audio.effect@6.0.so
-VNDK-core: android.hardware.audio@2.0.so
-VNDK-core: android.hardware.audio@4.0.so
-VNDK-core: android.hardware.audio@5.0.so
-VNDK-core: android.hardware.audio@6.0.so
-VNDK-core: android.hardware.authsecret@1.0.so
-VNDK-core: android.hardware.automotive.audiocontrol@1.0.so
-VNDK-core: android.hardware.automotive.evs@1.0.so
-VNDK-core: android.hardware.automotive.vehicle@2.0.so
-VNDK-core: android.hardware.biometrics.face@1.0.so
-VNDK-core: android.hardware.biometrics.fingerprint@2.1.so
-VNDK-core: android.hardware.bluetooth.a2dp@1.0.so
-VNDK-core: android.hardware.bluetooth.audio@2.0.so
-VNDK-core: android.hardware.bluetooth@1.0.so
-VNDK-core: android.hardware.bluetooth@1.1.so
-VNDK-core: android.hardware.boot@1.0.so
-VNDK-core: android.hardware.boot@1.1.so
-VNDK-core: android.hardware.broadcastradio@1.0.so
-VNDK-core: android.hardware.broadcastradio@1.1.so
-VNDK-core: android.hardware.broadcastradio@2.0.so
-VNDK-core: android.hardware.camera.common@1.0.so
-VNDK-core: android.hardware.camera.device@1.0.so
-VNDK-core: android.hardware.camera.device@3.2.so
-VNDK-core: android.hardware.camera.device@3.3.so
-VNDK-core: android.hardware.camera.device@3.4.so
-VNDK-core: android.hardware.camera.device@3.5.so
-VNDK-core: android.hardware.camera.metadata@3.2.so
-VNDK-core: android.hardware.camera.metadata@3.3.so
-VNDK-core: android.hardware.camera.metadata@3.4.so
-VNDK-core: android.hardware.camera.provider@2.4.so
-VNDK-core: android.hardware.camera.provider@2.5.so
-VNDK-core: android.hardware.cas.native@1.0.so
-VNDK-core: android.hardware.cas@1.0.so
-VNDK-core: android.hardware.cas@1.1.so
-VNDK-core: android.hardware.cas@1.2.so
 VNDK-core: android.hardware.configstore-utils.so
 VNDK-core: android.hardware.configstore@1.0.so
 VNDK-core: android.hardware.configstore@1.1.so
 VNDK-core: android.hardware.confirmationui-support-lib.so
-VNDK-core: android.hardware.confirmationui@1.0.so
-VNDK-core: android.hardware.contexthub@1.0.so
-VNDK-core: android.hardware.drm@1.0.so
-VNDK-core: android.hardware.drm@1.1.so
-VNDK-core: android.hardware.drm@1.2.so
-VNDK-core: android.hardware.dumpstate@1.0.so
-VNDK-core: android.hardware.dumpstate@1.1.so
-VNDK-core: android.hardware.fastboot@1.0.so
-VNDK-core: android.hardware.gatekeeper@1.0.so
-VNDK-core: android.hardware.gnss.measurement_corrections@1.0.so
-VNDK-core: android.hardware.gnss.visibility_control@1.0.so
-VNDK-core: android.hardware.gnss@1.0.so
-VNDK-core: android.hardware.gnss@1.1.so
-VNDK-core: android.hardware.gnss@2.0.so
 VNDK-core: android.hardware.graphics.allocator@2.0.so
 VNDK-core: android.hardware.graphics.allocator@3.0.so
 VNDK-core: android.hardware.graphics.bufferqueue@1.0.so
 VNDK-core: android.hardware.graphics.bufferqueue@2.0.so
-VNDK-core: android.hardware.graphics.composer@2.1.so
-VNDK-core: android.hardware.graphics.composer@2.2.so
-VNDK-core: android.hardware.graphics.composer@2.3.so
-VNDK-core: android.hardware.health.storage@1.0.so
-VNDK-core: android.hardware.health@1.0.so
-VNDK-core: android.hardware.health@2.0.so
-VNDK-core: android.hardware.health@2.1.so
 VNDK-core: android.hardware.identity-V2-ndk_platform.so
-VNDK-core: android.hardware.input.classifier@1.0.so
-VNDK-core: android.hardware.input.common@1.0.so
-VNDK-core: android.hardware.ir@1.0.so
 VNDK-core: android.hardware.keymaster-V2-ndk_platform.so
-VNDK-core: android.hardware.keymaster@3.0.so
-VNDK-core: android.hardware.keymaster@4.0.so
-VNDK-core: android.hardware.keymaster@4.1.so
 VNDK-core: android.hardware.light-V1-ndk_platform.so
-VNDK-core: android.hardware.light@2.0.so
-VNDK-core: android.hardware.media.bufferpool@1.0.so
 VNDK-core: android.hardware.media.bufferpool@2.0.so
-VNDK-core: android.hardware.media.c2@1.0.so
 VNDK-core: android.hardware.media.omx@1.0.so
 VNDK-core: android.hardware.media@1.0.so
 VNDK-core: android.hardware.memtrack@1.0.so
-VNDK-core: android.hardware.neuralnetworks@1.0.so
-VNDK-core: android.hardware.neuralnetworks@1.1.so
-VNDK-core: android.hardware.neuralnetworks@1.2.so
-VNDK-core: android.hardware.neuralnetworks@1.3.so
-VNDK-core: android.hardware.nfc@1.0.so
-VNDK-core: android.hardware.nfc@1.1.so
-VNDK-core: android.hardware.nfc@1.2.so
-VNDK-core: android.hardware.oemlock@1.0.so
 VNDK-core: android.hardware.power-V1-ndk_platform.so
-VNDK-core: android.hardware.power.stats@1.0.so
-VNDK-core: android.hardware.power@1.0.so
-VNDK-core: android.hardware.power@1.1.so
-VNDK-core: android.hardware.power@1.2.so
-VNDK-core: android.hardware.power@1.3.so
-VNDK-core: android.hardware.radio.config@1.0.so
-VNDK-core: android.hardware.radio.config@1.1.so
-VNDK-core: android.hardware.radio.config@1.2.so
-VNDK-core: android.hardware.radio.deprecated@1.0.so
-VNDK-core: android.hardware.radio@1.0.so
-VNDK-core: android.hardware.radio@1.1.so
-VNDK-core: android.hardware.radio@1.2.so
-VNDK-core: android.hardware.radio@1.3.so
-VNDK-core: android.hardware.radio@1.4.so
-VNDK-core: android.hardware.radio@1.5.so
-VNDK-core: android.hardware.secure_element@1.0.so
-VNDK-core: android.hardware.secure_element@1.1.so
-VNDK-core: android.hardware.secure_element@1.2.so
-VNDK-core: android.hardware.sensors@1.0.so
-VNDK-core: android.hardware.sensors@2.0.so
 VNDK-core: android.hardware.soundtrigger@2.0-core.so
 VNDK-core: android.hardware.soundtrigger@2.0.so
-VNDK-core: android.hardware.soundtrigger@2.1.so
-VNDK-core: android.hardware.soundtrigger@2.2.so
-VNDK-core: android.hardware.tetheroffload.config@1.0.so
-VNDK-core: android.hardware.tetheroffload.control@1.0.so
-VNDK-core: android.hardware.thermal@1.0.so
-VNDK-core: android.hardware.thermal@1.1.so
-VNDK-core: android.hardware.thermal@2.0.so
-VNDK-core: android.hardware.tv.cec@1.0.so
-VNDK-core: android.hardware.tv.cec@2.0.so
-VNDK-core: android.hardware.tv.input@1.0.so
-VNDK-core: android.hardware.tv.tuner@1.0.so
-VNDK-core: android.hardware.usb.gadget@1.0.so
-VNDK-core: android.hardware.usb@1.0.so
-VNDK-core: android.hardware.usb@1.1.so
-VNDK-core: android.hardware.usb@1.2.so
 VNDK-core: android.hardware.vibrator-V1-ndk_platform.so
-VNDK-core: android.hardware.vibrator@1.0.so
-VNDK-core: android.hardware.vibrator@1.1.so
-VNDK-core: android.hardware.vibrator@1.2.so
-VNDK-core: android.hardware.vibrator@1.3.so
-VNDK-core: android.hardware.vr@1.0.so
-VNDK-core: android.hardware.weaver@1.0.so
-VNDK-core: android.hardware.wifi.hostapd@1.0.so
-VNDK-core: android.hardware.wifi.hostapd@1.1.so
-VNDK-core: android.hardware.wifi.offload@1.0.so
-VNDK-core: android.hardware.wifi.supplicant@1.0.so
-VNDK-core: android.hardware.wifi.supplicant@1.1.so
-VNDK-core: android.hardware.wifi.supplicant@1.2.so
-VNDK-core: android.hardware.wifi@1.0.so
-VNDK-core: android.hardware.wifi@1.1.so
-VNDK-core: android.hardware.wifi@1.2.so
-VNDK-core: android.hardware.wifi@1.3.so
-VNDK-core: android.hidl.allocator@1.0.so
-VNDK-core: android.hidl.memory.block@1.0.so
 VNDK-core: android.hidl.token@1.0-utils.so
 VNDK-core: android.hidl.token@1.0.so
-VNDK-core: android.system.net.netd@1.0.so
-VNDK-core: android.system.net.netd@1.1.so
 VNDK-core: android.system.suspend@1.0.so
-VNDK-core: android.system.wifi.keystore@1.0.so
 VNDK-core: libadf.so
 VNDK-core: libaudioroute.so
 VNDK-core: libaudioutils.so
diff --git a/tools/releasetools/edify_generator.py b/tools/releasetools/edify_generator.py
index 99e21f1..b9c9b19 100644
--- a/tools/releasetools/edify_generator.py
+++ b/tools/releasetools/edify_generator.py
@@ -374,12 +374,12 @@
 
   def _CheckSecondTokenNotSlotSuffixed(self, s, fn):
     lst = s.split(':')
-    assert(len(s) == 4), "{} does not contain 4 tokens".format(s)
+    assert(len(lst) == 4), "{} does not contain 4 tokens".format(s)
     if self.fstab:
-      entry = common.GetEntryForDevice(s[1])
+      entry = common.GetEntryForDevice(self.fstab, lst[1])
       if entry is not None:
         assert not entry.slotselect, \
-          "Use %s because %s is slot suffixed" % (fn, s[1])
+          "Use %s because %s is slot suffixed" % (fn, lst[1])
 
   def WriteRawImage(self, mount_point, fn, mapfn=None):
     """Write the given package file into the partition for the given
diff --git a/tools/releasetools/test_validate_target_files.py b/tools/releasetools/test_validate_target_files.py
index 6504515..ca70ca8 100644
--- a/tools/releasetools/test_validate_target_files.py
+++ b/tools/releasetools/test_validate_target_files.py
@@ -25,10 +25,9 @@
 import test_utils
 from rangelib import RangeSet
 from validate_target_files import (ValidateVerifiedBootImages,
-                                   ValidateFileConsistency)
+                                   ValidateFileConsistency, CheckBuildPropDuplicity)
 from verity_utils import CreateVerityImageBuilder
 
-
 class ValidateTargetFilesTest(test_utils.ReleaseToolsTestCase):
 
   def setUp(self):
@@ -329,3 +328,38 @@
     with zipfile.ZipFile(input_file) as input_zip:
       info_dict = {'extfs_sparse_flag': '-s'}
       ValidateFileConsistency(input_zip, input_tmp, info_dict)
+
+  @staticmethod
+  def make_build_prop(build_prop):
+    input_tmp = common.MakeTempDir()
+    system_dir = os.path.join(input_tmp, 'SYSTEM')
+    os.makedirs(system_dir)
+    prop_file = os.path.join(system_dir, 'build.prop')
+    with open(prop_file, 'w') as output_file:
+      output_file.write("\n".join(build_prop))
+    return input_tmp
+
+  def test_checkDuplicateProps_noDuplicate(self):
+    build_prop = [
+        'ro.odm.build.date.utc=1578430045',
+        'ro.odm.build.fingerprint='
+        'google/coral/coral:10/RP1A.200325.001/6337676:user/dev-keys',
+        'ro.product.odm.device=coral',
+    ]
+    input_tmp = ValidateTargetFilesTest.make_build_prop(build_prop)
+    CheckBuildPropDuplicity(input_tmp)
+
+  def test_checkDuplicateProps_withDuplicate(self):
+    build_prop = [
+        'ro.odm.build.date.utc=1578430045',
+        'ro.odm.build.date.utc=1578430049',
+        'ro.odm.build.fingerprint='
+        'google/coral/coral:10/RP1A.200325.001/6337676:user/dev-keys',
+        'ro.product.odm.device=coral',
+    ]
+    input_tmp = ValidateTargetFilesTest.make_build_prop({
+        'ODM/etc/build.prop': '\n'.join(build_prop),
+    })
+
+    self.assertRaises(ValueError, CheckBuildPropDuplicity,
+                        input_tmp)
diff --git a/tools/releasetools/validate_target_files.py b/tools/releasetools/validate_target_files.py
index ac469eb..8763825 100755
--- a/tools/releasetools/validate_target_files.py
+++ b/tools/releasetools/validate_target_files.py
@@ -408,6 +408,34 @@
           'Verified %s with avbtool (key: %s):\n%s', image, key,
           stdoutdata.rstrip())
 
+def CheckDataDuplicity(lines):
+    build_prop = {}
+    for line in lines:
+      if line.startswith("import") or line.startswith("#"):
+        continue
+      key, value = line.split("=", 1)
+      if key in build_prop:
+        return key
+      build_prop[key] = value
+
+def CheckBuildPropDuplicity(input_tmp):
+  """Check all buld.prop files inside directory input_tmp, raise error
+  if they contain duplicates"""
+
+  if not os.path.isdir(input_tmp):
+    raise ValueError("Expect {} to be a directory".format(input_tmp))
+  for name in os.listdir(input_tmp):
+    if not name.isupper():
+      continue
+    for prop_file in ['build.prop', 'etc/build.prop']:
+      path = os.path.join(input_tmp, name, prop_file)
+      if not os.path.exists(path):
+        continue
+      logging.info("Checking {}".format(path))
+      with open(path, 'r') as fp:
+        dupKey = CheckDataDuplicity(fp.readlines())
+        if dupKey:
+          raise ValueError("{} contains duplicate keys for {}", path, dupKey)
 
 def main():
   parser = argparse.ArgumentParser(
@@ -447,6 +475,8 @@
   with zipfile.ZipFile(args.target_files, 'r') as input_zip:
     ValidateFileConsistency(input_zip, input_tmp, info_dict)
 
+  CheckBuildPropDuplicity(input_tmp)
+
   ValidateInstallRecoveryScript(input_tmp, info_dict)
 
   ValidateVerifiedBootImages(input_tmp, info_dict, options)