Merge "Add SetHostToolLocation."
diff --git a/common/strings.mk b/common/strings.mk
index ba20e27..e560bf0 100644
--- a/common/strings.mk
+++ b/common/strings.mk
@@ -28,7 +28,7 @@
 ###########################################################
 to-upper=$(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1))))))))))))))))))))))))))
 
-# Sanity-check to-lower and to-upper
+# Test to-lower and to-upper
 lower := abcdefghijklmnopqrstuvwxyz-_
 upper := ABCDEFGHIJKLMNOPQRSTUVWXYZ-_
 
diff --git a/core/binary.mk b/core/binary.mk
index 29a78a3..be7dc27 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -594,7 +594,7 @@
 
 $(call track-src-file-gen,$(renderscript_sources),$(rs_generated_cpps))
 
-# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
+# This is just a no-op rule to make sure gmake doesn't skip updating the dependents.
 $(rs_generated_cpps) : $(RenderScript_file_stamp)
 	@echo "Updated RS generated cpp file $@."
 	$(hide) touch $@
diff --git a/core/board_config.mk b/core/board_config.mk
index 4141cee..d4fe618 100644
--- a/core/board_config.mk
+++ b/core/board_config.mk
@@ -16,7 +16,7 @@
 
 # ###############################################################
 # This file includes BoardConfig.mk for the device being built,
-# and sanity-checks the variable defined therein.
+# and checks the variable defined therein.
 # ###############################################################
 
 _board_strip_readonly_list := \
@@ -167,7 +167,7 @@
 TARGET_CPU_VARIANT_RUNTIME := $(or $(TARGET_CPU_VARIANT_RUNTIME),$(TARGET_CPU_VARIANT))
 TARGET_2ND_CPU_VARIANT_RUNTIME := $(or $(TARGET_2ND_CPU_VARIANT_RUNTIME),$(TARGET_2ND_CPU_VARIANT))
 
-# The combo makefiles sanity-check and set defaults for various CPU configuration
+# The combo makefiles check and set defaults for various CPU configuration
 combo_target := TARGET_
 combo_2nd_arch_prefix :=
 include $(BUILD_SYSTEM)/combo/select.mk
@@ -191,7 +191,7 @@
   TARGET_SUPPORTS_32_BIT_APPS := true
 endif
 
-# Sanity check to warn about likely cryptic errors later in the build.
+# Quick check to warn about likely cryptic errors later in the build.
 ifeq ($(TARGET_IS_64_BIT),true)
   ifeq (,$(filter true false,$(TARGET_SUPPORTS_64_BIT_APPS)))
     $(error Building a 32-bit-app-only product on a 64-bit device. \
@@ -649,7 +649,7 @@
   endif
 endif
 
-# Sanity check for building generic OTA packages. Currently it only supports A/B OTAs.
+# Quick check for building generic OTA packages. Currently it only supports A/B OTAs.
 ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
   ifneq ($(AB_OTA_UPDATER),true)
     $(error PRODUCT_BUILD_GENERIC_OTA_PACKAGE with 'AB_OTA_UPDATER != true' is not supported)
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index e2acf96..f87f6b4 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -259,6 +259,7 @@
 LOCAL_SANITIZE_RECOVER:=
 LOCAL_SANITIZE_NO_RECOVER:=
 LOCAL_SANITIZE_BLACKLIST :=
+LOCAL_SANITIZE_BLOCKLIST :=
 LOCAL_SDK_LIBRARIES :=
 LOCAL_SDK_RES_VERSION:=
 LOCAL_SDK_VERSION:=
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk
index cbca1fb..e45c1a6 100644
--- a/core/combo/TARGET_linux-arm.mk
+++ b/core/combo/TARGET_linux-arm.mk
@@ -39,7 +39,7 @@
   TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT := generic
 endif
 
-# This sanity checks TARGET_2ND_ARCH_VARIANT against the lists above.
+# This quickly checks TARGET_2ND_ARCH_VARIANT against the lists above.
 ifneq (,$(filter $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT), $(KNOWN_ARMv82a_CORES)))
   ifeq (,$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT))
     TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := armv8-2a
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk
index c5cb91c..323bb36 100644
--- a/core/config_sanitizers.mk
+++ b/core/config_sanitizers.mk
@@ -147,6 +147,9 @@
   ifneq ($(LOCAL_SANITIZE_BLACKLIST),)
     my_cflags += -fsanitize-blacklist=$(LOCAL_PATH)/$(LOCAL_SANITIZE_BLACKLIST)
   endif
+  ifneq ($(LOCAL_SANITIZE_BLOCKLIST),)
+    my_cflags += -fsanitize-blacklist=$(LOCAL_PATH)/$(LOCAL_SANITIZE_BLOCKLIST)
+  endif
 endif
 
 # Disable integer_overflow if LOCAL_NOSANITIZE=integer.
diff --git a/core/java_common.mk b/core/java_common.mk
index 373c5d0..b7f2883 100644
--- a/core/java_common.mk
+++ b/core/java_common.mk
@@ -231,7 +231,7 @@
 
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RMTYPEDEFS := $(LOCAL_RMTYPEDEFS)
 
-# Sanity check class path vars.
+# Quickly check class path vars.
 disallowed_deps := $(foreach sdk,$(TARGET_AVAILABLE_SDK_VERSIONS),$(call resolve-prebuilt-sdk-module,$(sdk)))
 disallowed_deps += $(foreach sdk,$(TARGET_AVAILABLE_SDK_VERSIONS),\
   $(foreach sdk_lib,$(JAVA_SDK_LIBRARIES),$(call resolve-prebuilt-sdk-module,$(sdk),$(sdk_lib))))
diff --git a/core/line_coverage.mk b/core/line_coverage.mk
index babcb30..6bfbb8d 100644
--- a/core/line_coverage.mk
+++ b/core/line_coverage.mk
@@ -12,11 +12,11 @@
 # -----------------------------------------------------------------
 
 # TODO(b/148306195): Due this issue some fuzz targets cannot be built with
-# line coverage instrumentation. For now we just blacklist them.
-blacklisted_fuzz_targets := libneuralnetworks_fuzzer
+# line coverage instrumentation. For now we just block them.
+blocked_fuzz_targets := libneuralnetworks_fuzzer
 
 fuzz_targets := $(ALL_FUZZ_TARGETS)
-fuzz_targets := $(filter-out $(blacklisted_fuzz_targets),$(fuzz_targets))
+fuzz_targets := $(filter-out $(blocked_fuzz_targets),$(fuzz_targets))
 
 
 # Android components that considered critical.
diff --git a/core/main.mk b/core/main.mk
index 90c4cc4..b8b4404 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -1226,7 +1226,7 @@
       # Strip :32 and :64 suffixes
       _modules := $(patsubst %:32,%,$(_modules))
       _modules := $(patsubst %:64,%,$(_modules))
-      # Sanity check all modules in PRODUCT_PACKAGES exist. We check for the
+      # Quickly check all modules in PRODUCT_PACKAGES exist. We check for the
       # existence if either <module> or the <module>_32 variant.
       _nonexistent_modules := $(foreach m,$(_modules), \
         $(if $(or $(ALL_MODULES.$(m).PATH),$(call get-modules-for-2nd-arch,TARGET,$(m))),,$(m)))
diff --git a/core/product_config.mk b/core/product_config.mk
index bb806bb..38926c2 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -166,7 +166,7 @@
   $(if $(filter-out $(makefile),$(PRODUCTS)),$(eval $(call import-products,$(makefile))))\
 )
 
-# Sanity check
+# Quick check
 $(check-all-products)
 
 ifneq ($(filter dump-products, $(MAKECMDGOALS)),)
@@ -201,7 +201,7 @@
 $(call strip-product-vars)
 
 #############################################################################
-# Sanity check and assign default values
+# Quick check and assign default values
 
 TARGET_DEVICE := $(PRODUCT_DEVICE)
 
diff --git a/core/soong_config.mk b/core/soong_config.mk
index 81dbc23..98ab07d 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -216,6 +216,8 @@
 
 $(call add_json_bool, BoardUsesRecoveryAsBoot, $(BOARD_USES_RECOVERY_AS_BOOT))
 
+$(call add_json_list, BoardKernelBinaries, $(BOARD_KERNEL_BINARIES))
+
 $(call json_end)
 
 $(file >$(SOONG_VARIABLES).tmp,$(json_contents))
diff --git a/tools/Android.bp b/tools/Android.bp
index 149d06d..e0f3739 100644
--- a/tools/Android.bp
+++ b/tools/Android.bp
@@ -56,3 +56,23 @@
   test_config: "post_process_props_unittest.xml",
   test_suites: ["general-tests"],
 }
+
+python_binary_host {
+  name: "extract_kernel",
+  srcs: ["extract_kernel.py"],
+  version: {
+    py2: {
+      enabled: true,
+    },
+    py3: {
+      enabled: false,
+    },
+  },
+}
+
+genrule_defaults {
+  name: "extract_kernel_release_defaults",
+  tools: ["extract_kernel", "lz4"],
+  out: ["kernel_release.txt"],
+  cmd: "$(location) --tools lz4:$(location lz4) --input $(in) --output-release > $(out)"
+}
diff --git a/tools/extract_kernel.py b/tools/extract_kernel.py
index 8ca11d1..92a647b 100755
--- a/tools/extract_kernel.py
+++ b/tools/extract_kernel.py
@@ -40,10 +40,10 @@
 # LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n";
 LINUX_BANNER_PREFIX = b'Linux version '
 LINUX_BANNER_REGEX = LINUX_BANNER_PREFIX + \
-    r'([0-9]+[.][0-9]+[.][0-9]+).* \(.*@.*\) \(.*\) .*\n'
+    r'(?P<release>(?P<version>[0-9]+[.][0-9]+[.][0-9]+).*) \(.*@.*\) \(.*\) .*\n'
 
 
-def get_version(input_bytes, start_idx):
+def get_from_release(input_bytes, start_idx, key):
   null_idx = input_bytes.find('\x00', start_idx)
   if null_idx < 0:
     return None
@@ -53,24 +53,43 @@
     return None
   mo = re.match(LINUX_BANNER_REGEX, linux_banner)
   if mo:
-    return mo.group(1)
+    return mo.group(key)
   return None
 
 
-def dump_version(input_bytes):
+def dump_from_release(input_bytes, key):
+  """
+  Helper of dump_version and dump_release
+  """
   idx = 0
   while True:
     idx = input_bytes.find(LINUX_BANNER_PREFIX, idx)
     if idx < 0:
       return None
 
-    version = get_version(input_bytes, idx)
-    if version:
-      return version
+    value = get_from_release(input_bytes, idx, key)
+    if value:
+      return value
 
     idx += len(LINUX_BANNER_PREFIX)
 
 
+def dump_version(input_bytes):
+  """
+  Dump kernel version, w.x.y, from input_bytes. Search for the string
+  "Linux version " and do pattern matching after it. See LINUX_BANNER_REGEX.
+  """
+  return dump_from_release(input_bytes, "version")
+
+
+def dump_release(input_bytes):
+  """
+  Dump kernel release, w.x.y-..., from input_bytes. Search for the string
+  "Linux version " and do pattern matching after it. See LINUX_BANNER_REGEX.
+  """
+  return dump_from_release(input_bytes, "release")
+
+
 def dump_configs(input_bytes):
   """
   Dump kernel configuration from input_bytes. This can be done when
@@ -140,6 +159,23 @@
       if o:
         return o
 
+
+def dump_to_file(f, dump_fn, input_bytes, desc):
+  """
+  Call decompress_dump(dump_fn, input_bytes) and write to f. If it fails, return
+  False; otherwise return True.
+  """
+  if f is not None:
+    o = decompress_dump(dump_fn, input_bytes)
+    if o:
+      f.write(o)
+    else:
+      sys.stderr.write(
+          "Cannot extract kernel {}".format(desc))
+      return False
+  return True
+
+
 def main():
   parser = argparse.ArgumentParser(
       formatter_class=argparse.RawTextHelpFormatter,
@@ -165,6 +201,13 @@
                       nargs='?',
                       type=argparse.FileType('wb'),
                       const=sys.stdout)
+  parser.add_argument('--output-release',
+                      help='If specified, write kernel release. Use stdout if '
+                           'no file is specified.',
+                      metavar='FILE',
+                      nargs='?',
+                      type=argparse.FileType('wb'),
+                      const=sys.stdout)
   parser.add_argument('--tools',
                       help='Decompression tools to use. If not specified, PATH '
                            'is searched.',
@@ -181,25 +224,18 @@
   input_bytes = args.input.read()
 
   ret = 0
-  if args.output_configs is not None:
-    o = decompress_dump(dump_configs, input_bytes)
-    if o:
-      args.output_configs.write(o)
-    else:
-      sys.stderr.write(
-          "Cannot extract kernel configs in {}".format(args.input.name))
-      ret = 1
-  if args.output_version is not None:
-    o = decompress_dump(dump_version, input_bytes)
-    if o:
-      args.output_version.write(o)
-    else:
-      sys.stderr.write(
-          "Cannot extract kernel versions in {}".format(args.input.name))
-      ret = 1
+  if not dump_to_file(args.output_configs, dump_configs, input_bytes,
+                      "configs in {}".format(args.input.name)):
+    ret = 1
+  if not dump_to_file(args.output_version, dump_version, input_bytes,
+                      "version in {}".format(args.input.name)):
+    ret = 1
+  if not dump_to_file(args.output_release, dump_release, input_bytes,
+                      "kernel release in {}".format(args.input.name)):
+    ret = 1
 
   return ret
 
 
 if __name__ == '__main__':
-  exit(main())
+  sys.exit(main())
diff --git a/tools/fs_config/fs_config_generator.py b/tools/fs_config/fs_config_generator.py
index 1405fd3..940a398 100755
--- a/tools/fs_config/fs_config_generator.py
+++ b/tools/fs_config/fs_config_generator.py
@@ -299,11 +299,10 @@
     Parses a C header file and extracts lines starting with #define AID_<name>
     while capturing the OEM defined ranges and ignoring other ranges. It also
     skips some hardcoded AIDs it doesn't need to generate a mapping for.
-    It provides some basic sanity checks. The information extracted from this
-    file can later be used to sanity check other things (like oem ranges) as
-    well as generating a mapping of names to uids. It was primarily designed to
-    parse the private/android_filesystem_config.h, but any C header should
-    work.
+    It provides some basic checks. The information extracted from this file can
+    later be used to quickly check other things (like oem ranges) as well as
+    generating a mapping of names to uids. It was primarily designed to parse
+    the private/android_filesystem_config.h, but any C header should work.
     """
 
     _SKIP_AIDS = [
@@ -394,7 +393,7 @@
     def _handle_aid(self, identifier, value):
         """Handle an AID C #define.
 
-        Handles an AID, sanity checking, generating the friendly name and
+        Handles an AID, quick checking, generating the friendly name and
         adding it to the internal maps. Internal use only.
 
         Args:
@@ -422,7 +421,7 @@
         """Process, check and populate internal data structures.
 
         After parsing and generating the internal data structures, this method
-        is responsible for sanity checking ALL of the acquired data.
+        is responsible for quickly checking ALL of the acquired data.
 
         Raises:
             ValueError: With the message set to indicate the specific error.
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 5dfd12b..1846a67 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -614,7 +614,7 @@
 def LoadInfoDict(input_file, repacking=False):
   """Loads the key/value pairs from the given input target_files.
 
-  It reads `META/misc_info.txt` file in the target_files input, does sanity
+  It reads `META/misc_info.txt` file in the target_files input, does validation
   checks and returns the parsed key/value pairs for to the given build. It's
   usually called early when working on input target_files files, e.g. when
   generating OTAs, or signing builds. Note that the function may be called
diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py
index 1cb9a4f..b4646b7 100755
--- a/tools/releasetools/sign_target_files_apks.py
+++ b/tools/releasetools/sign_target_files_apks.py
@@ -1149,7 +1149,7 @@
       apex_name, key = a.split("=")
       OPTIONS.extra_apex_payload_keys[apex_name] = key
     elif o == "--skip_apks_with_path_prefix":
-      # Sanity check the prefix, which must be in all upper case.
+      # Check the prefix, which must be in all upper case.
       prefix = a.split('/')[0]
       if not prefix or prefix != prefix.upper():
         raise ValueError("Invalid path prefix '%s'" % (a,))
diff --git a/tools/releasetools/test_check_target_files_vintf.py b/tools/releasetools/test_check_target_files_vintf.py
index d326229..8725dd6 100644
--- a/tools/releasetools/test_check_target_files_vintf.py
+++ b/tools/releasetools/test_check_target_files_vintf.py
@@ -87,8 +87,8 @@
     return test_dir
 
   @test_utils.SkipIfExternalToolsUnavailable()
-  def test_CheckVintf_sanity(self):
-    msg = 'Sanity check with skeleton target files failed.'
+  def test_CheckVintf_skeleton(self):
+    msg = 'vintf check with skeleton target files failed.'
     test_dir = self.prepare_test_dir('does-not-exist')
     self.assertTrue(CheckVintf(test_dir), msg=msg)
 
diff --git a/tools/releasetools/test_verity_utils.py b/tools/releasetools/test_verity_utils.py
index cfc4942..a850390 100644
--- a/tools/releasetools/test_verity_utils.py
+++ b/tools/releasetools/test_verity_utils.py
@@ -233,7 +233,7 @@
         os.path.join(get_testdata_dir(), 'testkey_mincrypt'))
 
   @SkipIfExternalToolsUnavailable()
-  def test_Build_SanityCheck(self):
+  def test_Build_ValidationCheck(self):
     # A validity check for the test itself: the image shouldn't be verifiable
     # with wrong key.
     self.assertRaises(