Merge "DO NOT MERGE - Merge Pie Bonito/Sargo into master."
diff --git a/CleanSpec.mk b/CleanSpec.mk
index a93e79e..1d0685d 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -632,6 +632,8 @@
 $(call add-clean-step, rm -rf $(HOST_OUT_JAVA_LIBRARIES)/BootSignature.jar)
 $(call add-clean-step, rm -rf $(HOST_OUT_JAVA_LIBRARIES)/VeritySigner.jar)
 $(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/build_verity_metadata.py)
+
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libc_malloc*)
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************
diff --git a/core/board_config.mk b/core/board_config.mk
index 62d779c..597b10e 100644
--- a/core/board_config.mk
+++ b/core/board_config.mk
@@ -534,6 +534,14 @@
   TARGET_VENDOR_TEST_SUFFIX :=
 endif
 
+###########################################
+# APEXes are by default flattened, i.e. non-updatable.
+# It can be unflattened (and updatable) by inheriting from
+# updatable_apex.mk
+ifeq (,$(TARGET_FLATTEN_APEX))
+TARGET_FLATTEN_APEX := true
+endif
+
 ifeq (,$(TARGET_BUILD_APPS))
 ifdef PRODUCT_EXTRA_VNDK_VERSIONS
   $(foreach v,$(PRODUCT_EXTRA_VNDK_VERSIONS),$(call check_vndk_version,$(v)))
diff --git a/core/main.mk b/core/main.mk
index dce78fb..df5c13c 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -1200,31 +1200,44 @@
 # Runtime APEX libraries
 APEX_MODULE_LIBS := \
   libadbconnection.so \
+  libadbconnectiond.so \
   libandroidicu.so \
   libandroidio.so \
   libart-compiler.so \
   libart-dexlayout.so \
+  libart-disassembler.so \
   libart.so \
   libartbase.so \
+  libartbased.so \
+  libartd-compiler.so \
+  libartd-dexlayout.so \
+  libartd.so \
   libartpalette.so \
+  libc.so \
   libdexfile.so \
   libdexfile_external.so \
+  libdexfiled.so \
   libdexfiled_external.so \
+  libdl.so \
   libdt_fd_forward.so \
   libdt_socket.so \
   libicui18n.so \
   libicuuc.so \
   libjavacore.so \
   libjdwp.so \
+  libm.so \
   libnativebridge.so \
   libnativehelper.so \
   libnativeloader.so \
   libnpt.so \
   libopenjdk.so \
   libopenjdkjvm.so \
+  libopenjdkjvmd.so \
   libopenjdkjvmti.so \
+  libopenjdkjvmtid.so \
   libpac.so \
   libprofile.so \
+  libprofiled.so \
   libsigchain.so \
 
 # Conscrypt APEX libraries
@@ -1235,6 +1248,9 @@
 # still may create these libraries in /system (b/129006418).
 DISABLE_APEX_LIBS_ABSENCE_CHECK ?=
 
+# Bionic should not be in /system, except for the bootstrap instance.
+APEX_LIBS_ABSENCE_CHECK_EXCLUDE := lib/bootstrap lib64/bootstrap
+
 # Exclude lib/arm and lib/arm64 which contain the native bridge proxy libs. They
 # are compiled for the guest architecture and used with an entirely different
 # linker config. The native libs are then linked to as usual via exported
@@ -1242,7 +1258,7 @@
 # native architecture.
 # TODO(b/130630776): Introduce a make variable for the appropriate directory
 # when native bridge is active.
-APEX_LIBS_ABSENCE_CHECK_EXCLUDE := lib/arm lib/arm64
+APEX_LIBS_ABSENCE_CHECK_EXCLUDE += lib/arm lib/arm64
 
 # Exclude vndk-* subdirectories which contain prebuilts from older releases.
 APEX_LIBS_ABSENCE_CHECK_EXCLUDE += lib/vndk-% lib64/vndk-%
diff --git a/core/product.mk b/core/product.mk
index 8716e3e..1a566f7 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -302,6 +302,9 @@
 # A flag to override PRODUCT_COMPATIBLE_PROPERTY
 _product_single_value_vars += PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE
 
+# List of extra VNDK versions to be included
+_product_list_vars += PRODUCT_EXTRA_VNDK_VERSIONS
+
 # Whether the whitelist of actionable compatible properties should be disabled or not
 _product_single_value_vars += PRODUCT_ACTIONABLE_COMPATIBLE_PROPERTY_DISABLE
 
diff --git a/target/product/base_system.mk b/target/product/base_system.mk
index 23289f5..606a605 100644
--- a/target/product/base_system.mk
+++ b/target/product/base_system.mk
@@ -122,8 +122,6 @@
     libcamera2ndk \
     libcamera_client \
     libcameraservice \
-    libc_malloc_debug \
-    libc_malloc_hooks \
     libcutils \
     libdl.bootstrap \
     libdrmframework \
diff --git a/target/product/updatable_apex.mk b/target/product/updatable_apex.mk
index 4b31578..038f66e 100644
--- a/target/product/updatable_apex.mk
+++ b/target/product/updatable_apex.mk
@@ -18,3 +18,4 @@
 
 PRODUCT_PROPERTY_OVERRIDES := ro.apex.updatable=true
 PRODUCT_PACKAGES := com.android.apex.cts.shim.v1_prebuilt
+TARGET_FLATTEN_APEX := false
diff --git a/tools/releasetools/merge_target_files.py b/tools/releasetools/merge_target_files.py
index 20a9c64..f03cc1e 100755
--- a/tools/releasetools/merge_target_files.py
+++ b/tools/releasetools/merge_target_files.py
@@ -584,9 +584,9 @@
       system_misc_info_keys=system_misc_info_keys)
 
   process_dynamic_partitions_info_txt(
-      system_target_files_temp_dir=system_target_files_temp_dir,
-      other_target_files_temp_dir=other_target_files_temp_dir,
-      output_target_files_temp_dir=output_target_files_temp_dir)
+      system_target_files_dir=system_target_files_temp_dir,
+      other_target_files_dir=other_target_files_temp_dir,
+      output_target_files_dir=output_target_files_temp_dir)
 
 
 def merge_target_files(temp_dir, system_target_files, system_item_list,