Merge "Respect LOCAL_MIN_SDK_VERSION for dx"
diff --git a/target/product/treble_common.mk b/target/product/treble_common.mk
index 76ee015..220c734 100644
--- a/target/product/treble_common.mk
+++ b/target/product/treble_common.mk
@@ -17,174 +17,11 @@
 # Split selinux policy
 PRODUCT_FULL_TREBLE_OVERRIDE := true
 
-# HAL interfaces:
-#   Some of HAL interface libraries are automatically added by the dependencies
-#   from the framework. However, we list them all here to make it explicit and
-#   prevent possible mistake.
-PRODUCT_PACKAGES := \
-    android.frameworks.displayservice@1.0 \
-    android.frameworks.schedulerservice@1.0 \
-    android.frameworks.sensorservice@1.0 \
-    android.frameworks.vr.composer@1.0 \
-    android.hardware.audio@2.0 \
-    android.hardware.audio.common@2.0 \
-    android.hardware.audio.common@2.0-util \
-    android.hardware.audio.effect@2.0 \
-    android.hardware.automotive.evs@1.0 \
-    android.hardware.automotive.vehicle@2.0 \
-    android.hardware.automotive.vehicle@2.0-manager-lib-shared \
-    android.hardware.automotive.vehicle@2.1 \
-    android.hardware.biometrics.fingerprint@2.1 \
-    android.hardware.bluetooth@1.0 \
-    android.hardware.boot@1.0 \
-    android.hardware.broadcastradio@1.0 \
-    android.hardware.broadcastradio@1.1 \
-    android.hardware.camera.common@1.0 \
-    android.hardware.camera.device@1.0 \
-    android.hardware.camera.device@3.2 \
-    android.hardware.camera.metadata@3.2 \
-    android.hardware.camera.provider@2.4 \
-    android.hardware.configstore-utils \
-    android.hardware.configstore@1.0 \
-    android.hardware.configstore@1.1 \
-    android.hardware.contexthub@1.0 \
-    android.hardware.drm@1.0 \
-    android.hardware.dumpstate@1.0 \
-    android.hardware.gatekeeper@1.0 \
-    android.hardware.gnss@1.0 \
-    android.hardware.graphics.allocator@2.0 \
-    android.hardware.graphics.bufferqueue@1.0 \
-    android.hardware.graphics.common@1.0 \
-    android.hardware.graphics.composer@2.1 \
-    android.hardware.graphics.mapper@2.0 \
-    android.hardware.health@1.0 \
-    android.hardware.ir@1.0 \
-    android.hardware.keymaster@3.0 \
-    android.hardware.light@2.0 \
-    android.hardware.media@1.0 \
-    android.hardware.media.omx@1.0-utils \
-    android.hardware.media.omx@1.0 \
-    android.hardware.memtrack@1.0 \
-    android.hardware.nfc@1.0 \
-    android.hardware.oemlock@1.0 \
-    android.hardware.power@1.0 \
-    android.hardware.radio@1.0 \
-    android.hardware.radio.deprecated@1.0 \
-    android.hardware.sensors@1.0 \
-    android.hardware.soundtrigger@2.0 \
-    android.hardware.thermal@1.0 \
-    android.hardware.tv.cec@1.0 \
-    android.hardware.tv.input@1.0 \
-    android.hardware.usb@1.0 \
-    android.hardware.usb@1.1 \
-    android.hardware.vibrator@1.0 \
-    android.hardware.vr@1.0 \
-    android.hardware.weaver@1.0 \
-    android.hardware.wifi@1.0 \
-    android.hardware.wifi.supplicant@1.0 \
-    android.hidl.allocator@1.0 \
-    android.hidl.manager@1.0 \
-    android.hidl.memory@1.0 \
-    android.hidl.token@1.0 \
-    android.system.wifi.keystore@1.0 \
-
-# VNDK:
-#   Some VNDK shared objects are automatically included indirectly.
-#   We list them all here to make it explicit and prevent possible mistakes.
-#   An example of one such mistake was libcurl, which is included in A/B
-#   devices because of update_engine, but not in non-A/B devices.
-PRODUCT_PACKAGES += \
-    libaudioroute \
-    libaudioutils \
-    libbinder \
-    libcamera_metadata \
-    libcap \
-    libcrypto \
-    libcrypto_utils \
-    libcups \
-    libcurl \
-    libdiskconfig \
-    libdumpstateutil \
-    libevent \
-    libexif \
-    libexpat \
-    libfmq \
-    libgatekeeper \
-    libgui \
-    libhardware_legacy \
-    libhidlmemory \
-    libicui18n \
-    libicuuc \
-    libjpeg \
-    libkeymaster1 \
-    libkeymaster_messages \
-    libldacBT_abr \
-    libldacBT_enc \
-    liblz4 \
-    liblzma \
-    libmdnssd \
-    libmemtrack \
-    libmemunreachable \
-    libmetricslogger \
-    libminijail \
-    libnetutils \
-    libnl \
-    libopus \
-    libpagemap \
-    libpcap \
-    libpcre2 \
-    libpcrecpp \
-    libpdfium \
-    libpiex \
-    libpower \
-    libprocessgroup \
-    libprocinfo \
-    libprotobuf-cpp-full \
-    libprotobuf-cpp-lite \
-    libradio_metadata \
-    libsoftkeymasterdevice \
-    libsonic \
-    libsonivox \
-    libspeexresampler \
-    libsqlite \
-    libssl \
-    libsuspend \
-    libsysutils \
-    libtinyalsa \
-    libtinyxml2 \
-    libui \
-    libusbhost \
-    libvixl-arm \
-    libvixl-arm64 \
-    libvorbisidec \
-    libwebrtc_audio_preprocessing \
-    libxml2 \
-    libyuv \
-    libziparchive \
-
-# VNDK-SP:
-PRODUCT_PACKAGES += \
-    vndk-sp \
-
-# LL-VNDK:
-PRODUCT_PACKAGES += \
-    libandroid_net \
-    libc \
-    libdl \
-    liblog \
-    libm \
-    libstdc++ \
-    libvndksupport \
-    libz \
+# All VNDK libraries (HAL interfaces, VNDK, VNDK-SP, LL-NDK)
+PRODUCT_PACKAGES += vndk_package
 
 # SP-NDK:
 PRODUCT_PACKAGES += \
-    libEGL \
-    libGLESv1_CM \
-    libGLESv2 \
-    libGLESv3 \
-    libnativewindow \
-    libsync \
     libvulkan \
 
 PRODUCT_SYSTEM_VERITY_PARTITION := /dev/block/bootdevice/by-name/system
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index 52d3918..91213ba 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -53,6 +53,7 @@
 
 import datetime
 import errno
+import hashlib
 import os
 import shlex
 import shutil
@@ -532,6 +533,17 @@
 
   has_recovery = (OPTIONS.info_dict.get("no_recovery") != "true")
 
+  if OPTIONS.info_dict.get("avb_enable") == "true":
+    fp = None
+    if "build.prop" in OPTIONS.info_dict:
+      build_prop = OPTIONS.info_dict["build.prop"]
+      if "ro.build.fingerprint" in build_prop:
+        fp = build_prop["ro.build.fingerprint"]
+      elif "ro.build.thumbprint" in build_prop:
+        fp = build_prop["ro.build.thumbprint"]
+    if fp:
+      OPTIONS.info_dict["avb_salt"] = hashlib.sha256(fp).hexdigest()
+
   def banner(s):
     print("\n\n++++ " + s + " ++++\n\n")
 
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index d2c9f59..94626d7 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -126,7 +126,7 @@
     return int(output)
 
 def AVBAddFooter(image_path, avbtool, footer_type, partition_size,
-                 partition_name, key_path, algorithm,
+                 partition_name, key_path, algorithm, salt,
                  additional_args):
   """Adds dm-verity hashtree and AVB metadata to an image.
 
@@ -138,6 +138,7 @@
     partition_name: The name of the partition - will be embedded in metadata.
     key_path: Path to key to use or None.
     algorithm: Name of algorithm to use or None.
+    salt: The salt to use (a hexadecimal string) or None.
     additional_args: Additional arguments to pass to 'avbtool
       add_hashtree_image'.
   Returns:
@@ -150,6 +151,8 @@
 
   if key_path and algorithm:
     cmd.extend(["--key", key_path, "--algorithm", algorithm])
+  if salt:
+    cmd.extend(["--salt", salt])
 
   cmd.extend(shlex.split(additional_args))
 
@@ -592,10 +595,11 @@
     # key_path and algorithm are only available when chain partition is used.
     key_path = prop_dict.get("avb_key_path")
     algorithm = prop_dict.get("avb_algorithm")
+    salt = prop_dict.get("avb_salt")
     # avb_add_hash_footer_args or avb_add_hashtree_footer_args
     additional_args = prop_dict["avb_add_" + avb_footer_type + "_footer_args"]
     if not AVBAddFooter(out_file, avbtool, avb_footer_type, original_partition_size,
-                        partition_name, key_path, algorithm, additional_args):
+                        partition_name, key_path, algorithm, salt, additional_args):
       return False
 
   if run_fsck and prop_dict.get("skip_fsck") != "true":
@@ -641,8 +645,9 @@
       "verity_signer_cmd",
       "verity_fec",
       "avb_enable",
-      "avb_avbtool"
-      )
+      "avb_avbtool",
+      "avb_salt",
+  )
   for p in common_props:
     copy_prop(p, p)
 
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 789fefe..9726125 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -353,6 +353,10 @@
   algorithm = OPTIONS.info_dict.get("avb_" + partition + "_algorithm")
   if key_path and algorithm:
     cmd.extend(["--key", key_path, "--algorithm", algorithm])
+  avb_salt = OPTIONS.info_dict.get("avb_salt")
+  # make_vbmeta_image doesn't like "--salt" (and it's not needed).
+  if avb_salt and partition != "vbmeta":
+    cmd.extend(["--salt", avb_salt])
 
 
 def _BuildBootableImage(sourcedir, fs_config_file, info_dict=None,