Merge "Moving debug ramdisk resources under / of the ramdisk"
diff --git a/core/Makefile b/core/Makefile
index e0cc3f9..38302a7 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -5319,6 +5319,26 @@
 	$(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
 	$(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
 
+DEXPREOPT_CONFIG_ZIP := $(PRODUCT_OUT)/dexpreopt_config.zip
+$(DEXPREOPT_CONFIG_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
+	    $(INTERNAL_RAMDISK_FILES) \
+	    $(INTERNAL_USERDATAIMAGE_FILES) \
+	    $(INTERNAL_VENDORIMAGE_FILES) \
+	    $(INTERNAL_PRODUCTIMAGE_FILES) \
+	    $(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
+	    $(DEX_PREOPT_CONFIG_FOR_MAKE) \
+	    $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE)
+
+$(DEXPREOPT_CONFIG_ZIP): $(SOONG_ZIP)
+	$(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/dexpreopt_config
+ifneq (,$(DEX_PREOPT_CONFIG_FOR_MAKE))
+	$(hide) cp $(DEX_PREOPT_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
+endif
+ifneq (,$(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE))
+	$(hide) cp $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
+endif
+	$(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/dexpreopt_config -D $(PRODUCT_OUT)/dexpreopt_config
+
 # -----------------------------------------------------------------
 # A zip of the symbols directory.  Keep the full paths to make it
 # more obvious where these files came from.
diff --git a/core/base_rules.mk b/core/base_rules.mk
index a42d702..5f654a6 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -573,9 +573,14 @@
 my_vintf_pairs:=
 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
 ifndef LOCAL_IS_HOST_MODULE
-ifneq ($(strip $(LOCAL_VINTF_FRAGMENTS)),)
+ifneq ($(strip $(LOCAL_FULL_VINTF_FRAGMENTS)),)
+my_vintf_fragments := $(LOCAL_FULL_VINTF_FRAGMENTS)
+else
+my_vintf_fragments := $(foreach xml,$(LOCAL_VINTF_FRAGMENTS),$(LOCAL_PATH)/$(xml))
+endif
+ifneq ($(strip $(my_vintf_fragments)),)
 
-my_vintf_pairs := $(foreach xml,$(LOCAL_VINTF_FRAGMENTS),$(LOCAL_PATH)/$(xml):$(TARGET_OUT$(partition_tag)_ETC)/vintf/manifest/$(notdir $(xml)))
+my_vintf_pairs := $(foreach xml,$(my_vintf_fragments),$(xml):$(TARGET_OUT$(partition_tag)_ETC)/vintf/manifest/$(notdir $(xml)))
 my_vintf_installed := $(foreach xml,$(my_vintf_pairs),$(call word-colon,2,$(xml)))
 
 # Only set up copy rules once, even if another arch variant shares it
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index faca97a..e2acb67 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -109,6 +109,7 @@
 LOCAL_FULL_LIBS_MANIFEST_FILES:=
 LOCAL_FULL_MANIFEST_FILE:=
 LOCAL_FULL_TEST_CONFIG:=
+LOCAL_FULL_VINTF_FRAGMENTS:=
 LOCAL_FUZZ_ENGINE:=
 LOCAL_FUZZ_INSTALLED_SHARED_DEPS:=
 LOCAL_GCNO_FILES:=
diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk
index c6cc60d..a23bae2 100644
--- a/core/dex_preopt_odex_install.mk
+++ b/core/dex_preopt_odex_install.mk
@@ -399,6 +399,7 @@
   $(call json_end)
 
   my_dexpreopt_config := $(intermediates)/dexpreopt.config
+  my_dexpreopt_config_for_postprocessing := $(PRODUCT_OUT)/dexpreopt_config/$(LOCAL_MODULE)_dexpreopt.config
   my_dexpreopt_script := $(intermediates)/dexpreopt.sh
   my_dexpreopt_zip := $(intermediates)/dexpreopt.zip
   my_dexpreopt_config_merger := $(BUILD_SYSTEM)/dex_preopt_config_merger.py
@@ -428,6 +429,8 @@
 	-dexpreopt_script $@ \
 	-out_dir $(OUT_DIR)
 
+  $(eval $(call copy-one-file,$(my_dexpreopt_config),$(my_dexpreopt_config_for_postprocessing)))
+
   my_dexpreopt_deps := $(my_dex_jar)
   my_dexpreopt_deps += $(if $(my_process_profile),$(LOCAL_DEX_PREOPT_PROFILE))
   my_dexpreopt_deps += \
@@ -463,10 +466,12 @@
 
   $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
   $(LOCAL_INSTALLED_MODULE): $(my_dexpreopt_zip)
+  $(LOCAL_INSTALLED_MODULE): $(my_dexpreopt_config_for_postprocessing)
 
   $(my_all_targets): $(my_dexpreopt_zip)
 
   my_dexpreopt_config :=
   my_dexpreopt_script :=
   my_dexpreopt_zip :=
+  my_dexpreopt_config_for_postprocessing :=
 endif # LOCAL_DEX_PREOPT
diff --git a/core/main.mk b/core/main.mk
index 05203bb..c9fa148 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -1708,6 +1708,7 @@
     $(PROGUARD_USAGE_ZIP) \
     $(COVERAGE_ZIP) \
     $(APPCOMPAT_ZIP) \
+    $(DEXPREOPT_CONFIG_ZIP) \
     $(INSTALLED_FILES_FILE) \
     $(INSTALLED_FILES_JSON) \
     $(INSTALLED_FILES_FILE_VENDOR) \
diff --git a/core/product_config.mk b/core/product_config.mk
index d703ee3..eb6f69f 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -359,6 +359,14 @@
   endif
 endif
 
+ifeq ($(PRODUCT_SET_DEBUGFS_RESTRICTIONS),)
+  ifdef PRODUCT_SHIPPING_API_LEVEL
+    ifeq (true,$(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),31))
+      PRODUCT_SET_DEBUGFS_RESTRICTIONS := true
+    endif
+  endif
+endif
+
 ifdef PRODUCT_SHIPPING_API_LEVEL
   ifneq (,$(call math_gt_or_eq,29,$(PRODUCT_SHIPPING_API_LEVEL)))
     PRODUCT_PACKAGES += $(PRODUCT_PACKAGES_SHIPPING_API_LEVEL_29)
diff --git a/core/soong_app_prebuilt.mk b/core/soong_app_prebuilt.mk
index ce7b142..b7c21b8 100644
--- a/core/soong_app_prebuilt.mk
+++ b/core/soong_app_prebuilt.mk
@@ -13,6 +13,7 @@
 # LOCAL_SOONG_JNI_LIBS_$(TARGET_ARCH)
 # LOCAL_SOONG_JNI_LIBS_$(TARGET_2ND_ARCH)
 # LOCAL_SOONG_JNI_LIBS_SYMBOLS
+# LOCAL_SOONG_DEXPREOPT_CONFIG
 
 ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
   $(call pretty-error,soong_app_prebuilt.mk may only be used from Soong)
@@ -49,6 +50,14 @@
   .PHONY: javac-check-$(LOCAL_MODULE)
 endif
 
+ifdef LOCAL_SOONG_DEXPREOPT_CONFIG
+  my_dexpreopt_config := $(PRODUCT_OUT)/dexpreopt_config/$(LOCAL_MODULE)_dexpreopt.config
+  $(eval $(call copy-one-file,$(LOCAL_SOONG_DEXPREOPT_CONFIG), $(my_dexpreopt_config)))
+  $(LOCAL_BUILT_MODULE): $(my_dexpreopt_config)
+endif
+
+
+
 # Run veridex on product, system_ext and vendor modules.
 # We skip it for unbundled app builds where we cannot build veridex.
 module_run_appcompat :=
diff --git a/core/soong_java_prebuilt.mk b/core/soong_java_prebuilt.mk
index 0922def..1ebbf14 100644
--- a/core/soong_java_prebuilt.mk
+++ b/core/soong_java_prebuilt.mk
@@ -161,6 +161,9 @@
 # modules can find them.
 ifdef LOCAL_SOONG_DEXPREOPT_CONFIG
   $(eval $(call copy-one-file,$(LOCAL_SOONG_DEXPREOPT_CONFIG), $(call local-intermediates-dir,)/dexpreopt.config))
+  my_dexpreopt_config := $(PRODUCT_OUT)/dexpreopt_config/$(LOCAL_MODULE)_dexpreopt.config
+  $(eval $(call copy-one-file,$(LOCAL_SOONG_DEXPREOPT_CONFIG), $(my_dexpreopt_config)))
+  $(LOCAL_BUILT_MODULE): $(my_dexpreopt_config)
 endif
 
 ifdef LOCAL_SOONG_CLASSES_JAR
diff --git a/envsetup.sh b/envsetup.sh
index a2f7227..b5c729d 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -608,7 +608,7 @@
 {
     local uname=$(uname)
     local choices
-    choices=$(TARGET_BUILD_APPS= get_build_var COMMON_LUNCH_CHOICES 2>/dev/null)
+    choices=$(TARGET_BUILD_APPS= TARGET_PRODUCT= TARGET_BUILD_VARIANT= get_build_var COMMON_LUNCH_CHOICES 2>/dev/null)
     local ret=$?
 
     echo
diff --git a/target/product/updatable_apex.mk b/target/product/updatable_apex.mk
index d606e00..c8dc8b0 100644
--- a/target/product/updatable_apex.mk
+++ b/target/product/updatable_apex.mk
@@ -22,9 +22,4 @@
   PRODUCT_PACKAGES += com.android.apex.cts.shim.v1_prebuilt
   PRODUCT_VENDOR_PROPERTIES := ro.apex.updatable=true
   TARGET_FLATTEN_APEX := false
-  # Use compressed apexes in pre-installed partitions.
-  # Note: this doesn't mean that all pre-installed apexes will be compressed.
-  #  Whether an apex is compressed or not is controlled at apex Soong module
-  #  via compresible property.
-  PRODUCT_COMPRESSED_APEX := true
 endif
diff --git a/tools/releasetools/build_super_image.py b/tools/releasetools/build_super_image.py
index fb31415..ac61e60 100755
--- a/tools/releasetools/build_super_image.py
+++ b/tools/releasetools/build_super_image.py
@@ -194,10 +194,8 @@
       return BuildSuperImageFromTargetFiles(inp, out)
 
     if os.path.isfile(inp):
-      with open(inp) as f:
-        lines = f.read()
       logger.info("Building super image from info dict...")
-      return BuildSuperImageFromDict(common.LoadDictionaryFromLines(lines.split("\n")), out)
+      return BuildSuperImageFromDict(common.LoadDictionaryFromFile(inp), out)
 
   raise ValueError("{} is not a dictionary or a valid path".format(inp))
 
diff --git a/tools/releasetools/img_from_target_files.py b/tools/releasetools/img_from_target_files.py
index 5409194..cbb51e1 100755
--- a/tools/releasetools/img_from_target_files.py
+++ b/tools/releasetools/img_from_target_files.py
@@ -187,6 +187,9 @@
   Raises:
     ValueError: On invalid input.
   """
+  if not os.path.exists(input_file):
+    raise ValueError('%s is not exist' % input_file)
+
   if not zipfile.is_zipfile(input_file):
     raise ValueError('%s is not a valid zipfile' % input_file)
 
diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py
index 22c6ac4..313d1e6 100755
--- a/tools/releasetools/sign_target_files_apks.py
+++ b/tools/releasetools/sign_target_files_apks.py
@@ -799,7 +799,7 @@
         value = "/".join(pieces)
       elif key == "ro.build.description":
         pieces = value.split(" ")
-        assert len(pieces) == 5
+        assert pieces[-1].endswith("-keys")
         pieces[-1] = EditTags(pieces[-1])
         value = " ".join(pieces)
       elif key.startswith("ro.") and key.endswith(".build.tags"):
diff --git a/tools/warn.py b/tools/warn.py
index 22ac872..5f796f5 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 #
 # Copyright (C) 2019 The Android Open Source Project
 #
@@ -28,7 +28,7 @@
 
 def main():
   os.environ['PYTHONPATH'] = os.path.dirname(os.path.abspath(__file__))
-  subprocess.check_call(['/usr/bin/python', '-m', 'warn.warn'] + sys.argv[1:])
+  subprocess.check_call(['/usr/bin/python3', '-m', 'warn.warn'] + sys.argv[1:])
 
 
 if __name__ == '__main__':
diff --git a/tools/warn/html_writer.py b/tools/warn/html_writer.py
index 026a6d0..be71b55 100644
--- a/tools/warn/html_writer.py
+++ b/tools/warn/html_writer.py
@@ -52,8 +52,8 @@
 #   emit_js_data():
 
 from __future__ import print_function
-import cgi
 import csv
+import html
 import sys
 
 # pylint:disable=relative-beyond-top-level
@@ -582,10 +582,7 @@
 def emit_const_html_string_array(name, array, writer):
   writer('const ' + name + ' = [')
   for s in array:
-    # Not using html.escape yet, to work for both python 2 and 3,
-    # until all users switch to python 3.
-    # pylint:disable=deprecated-method
-    writer('"' + cgi.escape(strip_escape_string(s)) + '",')
+    writer('"' + html.escape(strip_escape_string(s)) + '",')
   writer('];')
 
 
diff --git a/tools/warn/warn.py b/tools/warn/warn.py
index 56e8787..cb5daec 100755
--- a/tools/warn/warn.py
+++ b/tools/warn/warn.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python3
 #
 # Copyright (C) 2019 The Android Open Source Project
 #