Merge "Apply change in prebuilt names for config files"
diff --git a/core/binary.mk b/core/binary.mk
index 6920373..92f9959 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -1721,13 +1721,13 @@
     endif
     # If clang-tidy is not enabled globally, add the -quiet flag.
     ifeq (,$(filter 1 true,$(WITH_TIDY)))
-      my_tidy_flags += -quiet
+      my_tidy_flags += -quiet -extra-arg-before=-fno-caret-diagnostics
     endif
 
     # We might be using the static analyzer through clang-tidy.
     # https://bugs.llvm.org/show_bug.cgi?id=32914
     ifneq ($(my_tidy_checks),)
-      my_tidy_flags += "-extra-arg-before=-D__clang_analyzer__"
+      my_tidy_flags += -extra-arg-before=-D__clang_analyzer__
     endif
   endif
 endif
diff --git a/core/config.mk b/core/config.mk
index 3743c7c..b03f21f 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -67,7 +67,7 @@
 $(KATI_obsolete_var ANDROID_PRODUCT_OUT,Use PRODUCT_OUT instead. See $(CHANGES_URL)#ANDROID_PRODUCT_OUT)
 $(KATI_obsolete_var ANDROID_HOST_OUT_TESTCASES,Use HOST_OUT_TESTCASES instead. See $(CHANGES_URL)#ANDROID_HOST_OUT_TESTCASES)
 $(KATI_obsolete_var ANDROID_TARGET_OUT_TESTCASES,Use TARGET_OUT_TESTCASES instead. See $(CHANGES_URL)#ANDROID_TARGET_OUT_TESTCASES)
-$(KATI_deprecated_var ANDROID_BUILD_TOP,Use '.' instead. See $(CHANGES_URL)#ANDROID_BUILD_TOP)
+$(KATI_obsolete_var ANDROID_BUILD_TOP,Use '.' instead. See $(CHANGES_URL)#ANDROID_BUILD_TOP)
 $(KATI_obsolete_var \
   ANDROID_TOOLCHAIN \
   ANDROID_TOOLCHAIN_2ND_ARCH \
@@ -705,7 +705,11 @@
 COLUMN:= column
 
 ifeq ($(EXPERIMENTAL_USE_OPENJDK9),)
+ifeq ($(RUN_ERROR_PRONE),true)
 USE_OPENJDK9 :=
+else
+USE_OPENJDK9 := true
+endif
 TARGET_OPENJDK9 :=
 else ifeq ($(EXPERIMENTAL_USE_OPENJDK9),false)
 USE_OPENJDK9 :=
diff --git a/target/product/embedded.mk b/target/product/embedded.mk
index 55ee6dc..20f0ebf 100644
--- a/target/product/embedded.mk
+++ b/target/product/embedded.mk
@@ -23,6 +23,7 @@
     android.hardware.configstore@1.0-service \
     android.hidl.allocator@1.0-service \
     android.hidl.memory@1.0-impl \
+    android.hidl.memory@1.0-impl.vendor \
     atrace \
     bootanimation \
     bootstat \
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 11a0055..3bb8b9c 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -384,17 +384,25 @@
 
   Returns:
     The check result.
+
+  Raises:
+    AssertionError: On invalid input.
   """
+  assert ext4fs_output is not None
+  assert prop_dict.get('fs_type', '').startswith('ext4')
+  assert 'partition_headroom' in prop_dict
+  assert 'mount_point' in prop_dict
+
   ext4fs_stats = re.compile(
       r'Created filesystem with .* (?P<used_blocks>[0-9]+)/'
       r'(?P<total_blocks>[0-9]+) blocks')
   m = ext4fs_stats.match(ext4fs_output.strip().split('\n')[-1])
   used_blocks = int(m.groupdict().get('used_blocks'))
   total_blocks = int(m.groupdict().get('total_blocks'))
-  headroom_blocks = int(prop_dict.get('partition_headroom')) / BLOCK_SIZE
+  headroom_blocks = int(prop_dict['partition_headroom']) / BLOCK_SIZE
   adjusted_blocks = total_blocks - headroom_blocks
   if used_blocks > adjusted_blocks:
-    mount_point = prop_dict.get("mount_point")
+    mount_point = prop_dict["mount_point"]
     print("Error: Not enough room on %s (total: %d blocks, used: %d blocks, "
           "headroom: %d blocks, available: %d blocks)" % (
               mount_point, total_blocks, used_blocks, headroom_blocks,
@@ -578,7 +586,6 @@
 
   # Check if there's enough headroom space available for ext4 image.
   if "partition_headroom" in prop_dict and fs_type.startswith("ext4"):
-    assert ext4fs_output is not None
     if not CheckHeadroom(ext4fs_output, prop_dict):
       return False
 
diff --git a/tools/releasetools/test_build_image.py b/tools/releasetools/test_build_image.py
index 6566a5a..161faff 100644
--- a/tools/releasetools/test_build_image.py
+++ b/tools/releasetools/test_build_image.py
@@ -14,52 +14,81 @@
 # limitations under the License.
 #
 
-import shutil
-import tempfile
 import unittest
 
+import common
 from build_image import CheckHeadroom, RunCommand
 
 
 class BuildImageTest(unittest.TestCase):
 
+  # Available: 1000 blocks.
+  EXT4FS_OUTPUT = (
+      "Created filesystem with 2777/129024 inodes and 515099/516099 blocks")
+
   def test_CheckHeadroom_SizeUnderLimit(self):
-    ext4fs_output = ("Created filesystem with 2777/129024 inodes and "
-                     "508140/516099 blocks")
+    # Required headroom: 1000 blocks.
     prop_dict = {
-        'partition_headroom' : '4194304',
+        'fs_type' : 'ext4',
+        'partition_headroom' : '4096000',
         'mount_point' : 'system',
     }
-    self.assertTrue(CheckHeadroom(ext4fs_output, prop_dict))
+    self.assertTrue(CheckHeadroom(self.EXT4FS_OUTPUT, prop_dict))
 
   def test_CheckHeadroom_InsufficientHeadroom(self):
-    ext4fs_output = ("Created filesystem with 2777/129024 inodes and "
-                     "515099/516099 blocks")
+    # Required headroom: 1001 blocks.
     prop_dict = {
+        'fs_type' : 'ext4',
         'partition_headroom' : '4100096',
         'mount_point' : 'system',
     }
-    self.assertFalse(CheckHeadroom(ext4fs_output, prop_dict))
+    self.assertFalse(CheckHeadroom(self.EXT4FS_OUTPUT, prop_dict))
+
+  def test_CheckHeadroom_WrongFsType(self):
+    prop_dict = {
+        'fs_type' : 'f2fs',
+        'partition_headroom' : '4100096',
+        'mount_point' : 'system',
+    }
+    self.assertRaises(
+        AssertionError, CheckHeadroom, self.EXT4FS_OUTPUT, prop_dict)
+
+  def test_CheckHeadroom_MissingProperties(self):
+    prop_dict = {
+        'fs_type' : 'ext4',
+        'partition_headroom' : '4100096',
+    }
+    self.assertRaises(
+        AssertionError, CheckHeadroom, self.EXT4FS_OUTPUT, prop_dict)
+
+    prop_dict = {
+        'fs_type' : 'ext4',
+        'mount_point' : 'system',
+    }
+    self.assertRaises(
+        AssertionError, CheckHeadroom, self.EXT4FS_OUTPUT, prop_dict)
 
   def test_CheckHeadroom_WithMke2fsOutput(self):
     """Tests the result parsing from actual call to mke2fs."""
-    input_dir = tempfile.mkdtemp()
-    output_image = tempfile.NamedTemporaryFile(suffix='.img')
-    command = ['mkuserimg_mke2fs.sh', input_dir, output_image.name, 'ext4',
+    input_dir = common.MakeTempDir()
+    output_image = common.MakeTempFile(suffix='.img')
+    command = ['mkuserimg_mke2fs.sh', input_dir, output_image, 'ext4',
                '/system', '409600', '-j', '0']
     ext4fs_output, exit_code = RunCommand(command)
     self.assertEqual(0, exit_code)
 
     prop_dict = {
+        'fs_type' : 'ext4',
         'partition_headroom' : '40960',
         'mount_point' : 'system',
     }
     self.assertTrue(CheckHeadroom(ext4fs_output, prop_dict))
 
     prop_dict = {
+        'fs_type' : 'ext4',
         'partition_headroom' : '413696',
         'mount_point' : 'system',
     }
     self.assertFalse(CheckHeadroom(ext4fs_output, prop_dict))
 
-    shutil.rmtree(input_dir)
+    common.Cleanup()