Merge changes Ie3d82cfa,I2f808896,I587f400d

* changes:
  fat16copy: Fix allocation logic when extending directories.
  fat16copy: Sort new directory entries.
  Make fat16copy.py add . and .. entries to directories
diff --git a/core/Makefile b/core/Makefile
index 8fc3527..a1d483b 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -516,38 +516,16 @@
 	$(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
 	--kernel $(INSTALLED_KERNEL_TARGET)
 
-INTERNAL_BVBTOOL_MAKE_BOOT_IMAGE_ARGS := \
-	--kernel $(INSTALLED_KERNEL_TARGET) \
-	--rootfs_with_hashes $(PRODUCT_OUT)/system.img
-
-ifdef BOARD_BVB_ROLLBACK_INDEX
-INTERNAL_BVBTOOL_MAKE_BOOT_IMAGE_ARGS += \
-	--rollback_index $(BOARD_BVB_ROLLBACK_INDEX)
-endif
-
-ifndef BOARD_BVB_KEY_PATH
-# If key path isn't specified, use the 4096-bit test key.
-INTERNAL_BVBTOOL_SIGN_BOOT_IMAGE_ARGS := --algorithm SHA256_RSA4096 \
-	--key external/bvb/test/testkey_rsa4096.pem
-else
-INTERNAL_BVBTOOL_SIGN_BOOT_IMAGE_ARGS := \
-	--algorithm $(BOARD_BVB_ALGORITHM) --key $(BOARD_BVB_KEY_PATH)
-endif
-
-
 ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true)
 INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
-INTERNAL_BVBTOOL_MAKE_BOOT_IMAGE_ARGS += --initrd $(INSTALLED_RAMDISK_TARGET)
 endif
 
 INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
 
-BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
 ifdef BOARD_KERNEL_BASE
   INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
 endif
 
-BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
 ifdef BOARD_KERNEL_PAGESIZE
   INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
 endif
@@ -559,9 +537,9 @@
 endif
 endif
 
-BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
-ifdef BOARD_KERNEL_CMDLINE
-INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
+INTERNAL_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
+ifdef INTERNAL_KERNEL_CMDLINE
+INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
 endif
 
 INTERNAL_MKBOOTIMG_VERSION_ARGS := \
@@ -577,28 +555,35 @@
 endif
 endif
 
-ifeq ($(BOARD_BVB_ENABLE),true)
-
-$(INSTALLED_BOOTIMAGE_TARGET): $(BVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/system.img
-	$(call pretty,"Target boot image: $@")
-	$(hide) $(BVBTOOL) make_boot_image $(INTERNAL_BVBTOOL_MAKE_BOOT_IMAGE_ARGS) $(BOARD_BVB_MAKE_BOOT_IMAGE_ARGS) --output $@
-	$(hide) $(BVBTOOL) sign_boot_image $(INTERNAL_BVBTOOL_SIGN_BOOT_IMAGE_ARGS) $(BOARD_BVB_SIGN_BOOT_IMAGE_ARGS) --image $@
-	$(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
-
-.PHONY: bootimage-nodeps
-bootimage-nodeps: $(BVBTOOL)
-	@echo "make $@: ignoring dependencies"
-	$(hide) $(BVBTOOL) make_boot_image $(INTERNAL_BVBTOOL_MAKE_BOOT_IMAGE_ARGS) $(BOARD_BVB_MAKE_BOOT_IMAGE_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
-	$(hide) $(BVBTOOL) sign_boot_image $(INTERNAL_BVBTOOL_SIGN_BOOT_IMAGE_ARGS) $(BOARD_BVB_SIGN_BOOT_IMAGE_ARGS) --image $(INSTALLED_BOOTIMAGE_TARGET)
-	$(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
-
-else # BOARD_BVB_ENABLE
-
 # We build recovery as boot image if BOARD_USES_RECOVERY_AS_BOOT is true.
 ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
 ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
 $(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
-else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)) # TARGET_BOOTIMAGE_USE_EXT2 != true
+
+else ifeq (true,$(BOARD_AVB_ENABLE)) # TARGET_BOOTIMAGE_USE_EXT2 != true
+
+$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES)
+	$(call pretty,"Target boot image: $@")
+	$(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@
+	$(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE))
+	$(hide) $(AVBTOOL) add_hash_footer \
+	  --image $@ \
+	  --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
+	  --partition_name boot $(INTERNAL_AVB_SIGNING_ARGS) \
+	  $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
+
+.PHONY: bootimage-nodeps
+bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL)
+	@echo "make $@: ignoring dependencies"
+	$(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET)
+	$(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE))
+	$(hide) $(AVBTOOL) add_hash_footer \
+	  --image $@ \
+	  --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
+	  --partition_name boot $(INTERNAL_AVB_SIGNING_ARGS) \
+	  $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
+
+else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)) # BOARD_AVB_ENABLE != true
 
 $(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER)
 	$(call pretty,"Target boot image: $@")
@@ -643,9 +628,9 @@
 
 endif # TARGET_BOOTIMAGE_USE_EXT2
 endif # BOARD_USES_RECOVERY_AS_BOOT
-endif # BOARD_BVB_ENABLE
 
 else	# TARGET_NO_KERNEL
+INTERNAL_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
 # HACK: The top-level targets depend on the bootimage.  Not all targets
 # can produce a bootimage, though, and emulator targets need the ramdisk
 # instead.  Fake it out by calling the ramdisk the bootimage.
@@ -887,6 +872,10 @@
 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(FUTILITY)" >> $(1))
 $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
+$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_signing_args=$(INTERNAL_AVB_SIGNING_ARGS)" >> $(1))
+$(if $(BOARD_AVB_ENABLE),$(hide) echo "avb_avbtool=$(AVBTOOL)" >> $(1))
+$(if $(BOARD_AVB_ENABLE),$(hide) echo "system_avb_enable=$(BOARD_AVB_ENABLE)" >> $(1))
+$(if $(BOARD_AVB_ENABLE),$(hide) echo "system_avb_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1))
 $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
     $(hide) echo "recovery_as_boot=true" >> $(1))
 $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\
@@ -987,13 +976,12 @@
 	--ramdisk $(recovery_ramdisk)
 
 # Assumes this has already been stripped
-ifdef BOARD_KERNEL_CMDLINE
-  INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
+ifdef INTERNAL_KERNEL_CMDLINE
+  INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
 endif
 ifdef BOARD_KERNEL_BASE
   INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
 endif
-BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
 ifdef BOARD_KERNEL_PAGESIZE
   INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
 endif
@@ -1055,6 +1043,12 @@
     $(BOOT_SIGNER) /recovery $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1))
   $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \
     $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1))
+  $(if $(and $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),$(filter true,$(BOARD_AVB_ENABLE))), \
+      $(hide) $(AVBTOOL) add_hash_footer \
+        --image $(1) \
+        --partition_size $(BOARD_BOOTIMAGE_PARTITION_SIZE) \
+        --partition_name boot $(INTERNAL_AVB_SIGNING_ARGS) \
+        $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS))
   $(if $(filter true,BOARD_USES_RECOVERY_AS_BOOT), \
     $(hide) $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE)), \
     $(hide) $(call assert-max-image-size,$(1),$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)))
@@ -1194,13 +1188,8 @@
            fi; \
            mkdir -p $(DIST_DIR); cp $(INSTALLED_FILES_FILE) $(DIST_DIR)/installed-files-rescued.txt; \
            exit 1 )
-  $(if $(BOARD_BVB_ENABLE), $(hide) $(BVBTOOL) add_image_hashes $(BOARD_BVB_ADD_IMAGE_HASHES_ARGS) --image $(1))
 endef
 
-ifeq ($(BOARD_BVB_ENABLE),true)
-FULL_SYSTEMIMAGE_DEPS += $(BVBTOOL)
-endif
-
 $(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE) $(BUILD_IMAGE_SRCS)
 	$(call build-systemimage-target,$@)
 
@@ -1361,7 +1350,7 @@
     $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
     $(hide) mkdir -p $(PRODUCT_OUT)/boot
     $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
-    $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
+    $(hide) echo $(INTERNAL_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
     $(hide) $(MKTARBALL) $(FS_GET_STATS) \
                  $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
                  $(INSTALLED_BOOTTARBALL_TARGET) $(TARGET_OUT)
@@ -1515,6 +1504,60 @@
 
 endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
 
+# -----------------------------------------------------------------
+# vbmeta image
+ifeq ($(BOARD_AVB_ENABLE),true)
+
+BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
+
+INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS := \
+    --include_descriptors_from_image $(INSTALLED_BOOTIMAGE_TARGET) \
+    --include_descriptors_from_image $(INSTALLED_SYSTEMIMAGE) \
+    --generate_dm_verity_cmdline_from_hashtree $(INSTALLED_SYSTEMIMAGE)
+
+ifdef BOARD_AVB_ROLLBACK_INDEX
+INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
+endif
+
+ifndef BOARD_AVB_KEY_PATH
+# If key path isn't specified, use the 4096-bit test key.
+INTERNAL_AVB_SIGNING_ARGS := \
+    --algorithm SHA256_RSA4096 \
+    --key external/avb/test/data/testkey_rsa4096.pem
+else
+INTERNAL_AVB_SIGNING_ARGS := \
+    --algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
+endif
+
+ifndef BOARD_BOOTIMAGE_PARTITION_SIZE
+  $(error BOARD_BOOTIMAGE_PARTITION_SIZE must be set for BOARD_AVB_ENABLE)
+endif
+
+ifndef BOARD_SYSTEMIMAGE_PARTITION_SIZE
+  $(error BOARD_SYSTEMIMAGE_PARTITION_SIZE must be set for BOARD_AVB_ENABLE)
+endif
+
+define build-vbmetaimage-target
+  $(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
+  $(hide) $(AVBTOOL) make_vbmeta_image \
+    $(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
+    $(INTERNAL_AVB_SIGNING_ARGS) \
+    $(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
+    --output $@
+endef
+
+INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
+$(INSTALLED_VBMETAIMAGE_TARGET): $(AVBTOOL) $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE)
+	$(build-vbmetaimage-target)
+
+.PHONY: vbmetaimage-nodeps
+vbmetaimage-nodeps:
+	$(build-vbmetaimage-target)
+
+# We need $(AVBTOOL) for system.img generation.
+FULL_SYSTEMIMAGE_DEPS += $(AVBTOOL)
+
+endif # BOARD_AVB_ENABLE
 
 # -----------------------------------------------------------------
 # vendor partition image
@@ -1773,8 +1816,8 @@
 	$(hide) $(ACP) \
 		$(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
 endif
-ifdef BOARD_KERNEL_CMDLINE
-	$(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
+ifdef INTERNAL_KERNEL_CMDLINE
+	$(hide) echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
 endif
 ifdef BOARD_KERNEL_BASE
 	$(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
@@ -1802,8 +1845,8 @@
 	$(hide) $(ACP) \
 		$(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
 endif
-ifdef BOARD_KERNEL_CMDLINE
-	$(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
+ifdef INTERNAL_KERNEL_CMDLINE
+	$(hide) echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
 endif
 ifdef BOARD_KERNEL_BASE
 	$(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
@@ -1898,14 +1941,14 @@
 ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
 	$(hide) echo "full_recovery_image=true" >> $(zip_root)/META/misc_info.txt
 endif
-ifeq ($(BOARD_BVB_ENABLE),true)
-	$(hide) echo "board_bvb_enable=true" >> $(zip_root)/META/misc_info.txt
-	$(hide) echo "board_bvb_make_boot_image_args=$(BOARD_BVB_MAKE_BOOT_IMAGE_ARGS)" >> $(zip_root)/META/misc_info.txt
-	$(hide) echo "board_bvb_sign_boot_image_args=$(BOARD_BVB_SIGN_BOOT_IMAGE_ARGS)" >> $(zip_root)/META/misc_info.txt
-	$(hide) echo "board_bvb_algorithm=$(BOARD_BVB_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
-	$(hide) echo "board_bvb_key_path=$(BOARD_BVB_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
-	$(hide) echo "board_bvb_rollback_index=$(BOARD_BVB_ROLLBACK_INDEX)" >> $(zip_root)/META/misc_info.txt
-	$(hide) echo "board_bvb_add_image_hashes_args=$(BOARD_BVB_ADD_IMAGE_HASHES_ARGS)" >> $(zip_root)/META/misc_info.txt
+ifeq ($(BOARD_AVB_ENABLE),true)
+	$(hide) echo "board_avb_enable=true" >> $(zip_root)/META/misc_info.txt
+	$(hide) echo "board_avb_rollback_index=$(BOARD_AVB_ROLLBACK_INDEX)" >> $(zip_root)/META/misc_info.txt
+	$(hide) echo "board_avb_key_path=$(BOARD_AVB_KEY_PATH)" >> $(zip_root)/META/misc_info.txt
+	$(hide) echo "board_avb_algorithm=$(BOARD_AVB_ALGORITHM)" >> $(zip_root)/META/misc_info.txt
+	$(hide) echo "board_avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $(zip_root)/META/misc_info.txt
+	$(hide) echo "board_avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(zip_root)/META/misc_info.txt
+	$(hide) echo "board_avb_make_vbmeta_image_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $(zip_root)/META/misc_info.txt
 endif
 ifdef BOARD_BPT_INPUT_FILES
 	$(hide) echo "board_bpt_enable=true" >> $(zip_root)/META/misc_info.txt
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 56df2a9..13d20e0 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -269,9 +269,6 @@
 # dependent binaries of a .toc file will be rebuilt only when the content of
 # the .toc file is changed.
 ###########################################################
-ifndef LOCAL_IS_HOST_MODULE
-# Disable .toc optimization for host modules: we may run the host binaries during the build process
-# and the libraries' implementation matters.
 ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
 LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE).toc
 $(LOCAL_BUILT_MODULE).toc: $(LOCAL_BUILT_MODULE)
@@ -283,7 +280,6 @@
 # Build .toc file when using mm, mma, or make $(my_register_name)
 $(my_all_targets): $(LOCAL_BUILT_MODULE).toc
 endif
-endif
 
 ###########################################################
 ## logtags: Add .logtags files to global list
diff --git a/core/binary.mk b/core/binary.mk
index e11ab89..c682d4e 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -56,6 +56,7 @@
 my_generated_sources := $(LOCAL_GENERATED_SOURCES)
 my_additional_dependencies := $(LOCAL_ADDITIONAL_DEPENDENCIES)
 my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
+my_export_c_include_deps := $(LOCAL_EXPORT_C_INCLUDE_DEPS)
 
 ifneq (,$(foreach dir,$(COVERAGE_PATHS),$(filter $(dir)%,$(LOCAL_PATH))))
   my_native_coverage := true
@@ -102,9 +103,7 @@
   # missing API levels to existing ones where necessary, but we're not doing
   # that for the generated libraries. Clip the API level to the minimum where
   # appropriate.
-  my_ndk_api := \
-    $(shell if [ $(LOCAL_SDK_VERSION) -lt $(my_min_sdk_version) ]; then \
-        echo $(my_min_sdk_version); else echo $(LOCAL_SDK_VERSION); fi)
+  my_ndk_api := $(call math_max,$(LOCAL_SDK_VERSION),$(my_min_sdk_version))
 
   # Traditionally this has come from android/api-level.h, but with the libc
   # headers unified it must be set by the build system since we don't have
@@ -561,10 +560,6 @@
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
     $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
 
-ifeq ($(strip $(WITH_SYNTAX_CHECK)),)
-  LOCAL_NO_SYNTAX_CHECK := true
-endif
-
 ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
   LOCAL_NO_STATIC_ANALYZER := true
 endif
@@ -593,10 +588,6 @@
 ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
   my_cc := CCC_CC=$(CLANG) CLANG=$(CLANG) \
            $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer
-else
-ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
-  my_cc := $(my_cc) -fsyntax-only
-endif
 endif
 
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
@@ -613,10 +604,6 @@
 ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
   my_cxx := CCC_CXX=$(CLANG_CXX) CLANG_CXX=$(CLANG_CXX) \
             $(SYNTAX_TOOLS_PREFIX)/c++-analyzer
-else
-ifneq ($(LOCAL_NO_SYNTAX_CHECK),true)
-  my_cxx := $(my_cxx) -fsyntax-only
-endif
 endif
 
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LINKER := $(my_linker)
@@ -1520,13 +1507,7 @@
     $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
       $(addsuffix $(so_suffix), \
         $(installed_shared_library_module_names)))
-ifdef LOCAL_IS_HOST_MODULE
-# Disable .toc optimization for host modules: we may run the host binaries during the build process
-# and the libraries' implementation matters.
-built_shared_library_deps := $(built_shared_libraries)
-else
 built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries))
-endif
 my_system_shared_libraries_fullpath :=
 endif
 
@@ -1615,6 +1596,16 @@
     my_cflags += -DANDROID_STRICT
 endif
 
+# Add -Werror if LOCAL_PATH is in the WARNING_DISALLOWED project list,
+# or not in the WARNING_ALLOWED project list.
+ifneq (,$(strip $(call find_warning_disallowed_projects,$(LOCAL_PATH))))
+  my_cflags_no_override += -Werror
+else
+  ifeq (,$(strip $(call find_warning_allowed_projects,$(LOCAL_PATH))))
+    my_cflags_no_override += -Werror
+  endif
+endif
+
 # Disable clang-tidy if it is not found.
 ifeq ($(PATH_TO_CLANG_TIDY),)
   my_tidy_enabled := false
@@ -1739,7 +1730,7 @@
 $(export_includes): PRIVATE_REEXPORTED_INCLUDES := $(export_include_deps)
 # By adding $(my_generated_sources) it makes sure the headers get generated
 # before any dependent source files get compiled.
-$(export_includes) : $(my_generated_sources) $(export_include_deps)
+$(export_includes) : $(my_export_c_include_deps) $(my_generated_sources) $(export_include_deps)
 	@echo Export includes file: $< -- $@
 	$(hide) mkdir -p $(dir $@) && rm -f $@.tmp && touch $@.tmp
 ifdef my_export_c_include_dirs
diff --git a/core/clang/tidy.mk b/core/clang/tidy.mk
index 7ec9378..a081056 100644
--- a/core/clang/tidy.mk
+++ b/core/clang/tidy.mk
@@ -18,7 +18,7 @@
 # Global tidy checks include only google*, performance*,
 # and misc-macro-parentheses, but not google-readability*
 # or google-runtime-references.
-DEFAULT_GLOBAL_TIDY_CHECKS := \
+DEFAULT_GLOBAL_TIDY_CHECKS ?= \
   $(subst $(space),, \
     -*,google* \
     ,misc-macro-parentheses \
@@ -29,7 +29,7 @@
 
 # There are too many clang-tidy warnings in external and vendor projects.
 # Enable only some google checks for these projects.
-DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS := \
+DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS ?= \
   $(subst $(space),, \
     -*,google* \
     ,-google-build-using-namespace \
@@ -51,6 +51,7 @@
   hardware/qcom:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
   vendor/:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
   vendor/google:$(DEFAULT_GLOBAL_TIDY_CHECKS) \
+  vendor/google_devices:$(DEFAULT_EXTERNAL_VENDOR_TIDY_CHECKS) \
 
 # Returns 2nd word of $(1) if $(2) has prefix of the 1st word of $(1).
 define find_default_local_tidy_check2
@@ -78,6 +79,7 @@
 # Do not give warnings to external or vendor header files,
 # which contain too many warnings.
 DEFAULT_TIDY_HEADER_DIRS := \
+  $(subst $(space),, \
      art/ \
     |bionic/ \
     |bootable/ \
@@ -89,7 +91,8 @@
     |frameworks/ \
     |libcore/ \
     |libnativehelper/ \
-    |system/
+    |system/ \
+  )
 
 # Default filter contains current directory $1 and DEFAULT_TIDY_HEADER_DIRS.
 define default_tidy_header_filter
diff --git a/core/clang/versions.mk b/core/clang/versions.mk
index 44fdb1a..03341d9 100644
--- a/core/clang/versions.mk
+++ b/core/clang/versions.mk
@@ -1,5 +1,5 @@
 ## Clang/LLVM release versions.
 
 LLVM_RELEASE_VERSION := 3.8
-LLVM_PREBUILTS_VERSION ?= clang-3217047
+LLVM_PREBUILTS_VERSION ?= clang-3289846
 LLVM_PREBUILTS_BASE ?= prebuilts/clang/host
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 4f0c839..faf18e3 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -56,6 +56,7 @@
 LOCAL_CONLYFLAGS:=
 LOCAL_RTTI_FLAG:=
 LOCAL_C_INCLUDES:=
+LOCAL_EXPORT_C_INCLUDE_DEPS:=
 LOCAL_EXPORT_C_INCLUDE_DIRS:=
 LOCAL_LDFLAGS:=
 LOCAL_CLANG_LDFLAGS:=
@@ -172,7 +173,6 @@
 LOCAL_POST_INSTALL_CMD:=
 LOCAL_HAL_STATIC_LIBRARIES:=
 LOCAL_RMTYPEDEFS:=
-LOCAL_NO_SYNTAX_CHECK:=
 LOCAL_NO_STATIC_ANALYZER:=
 LOCAL_TIDY:=
 LOCAL_TIDY_CHECKS:=
@@ -197,6 +197,7 @@
 LOCAL_DPI_FILE_STEM:=
 LOCAL_SANITIZE:=
 LOCAL_SANITIZE_RECOVER:=
+LOCAL_SANITIZE_DIAG:=
 LOCAL_NOSANITIZE:=
 LOCAL_DATA_BINDING:=
 LOCAL_DBUS_PROXY_PREFIX:=
@@ -375,7 +376,6 @@
 LOCAL_MODULE_SYMLINKS_32:=
 LOCAL_MODULE_SYMLINKS_64:=
 LOCAL_JAVA_LANGUAGE_VERSION:=
-LOCAL_CTS_GTEST_LIST_EXECUTABLE:=
 
 LOCAL_IS_AUX_MODULE :=
 LOCAL_AUX_TOOLCHAIN :=
diff --git a/core/config.mk b/core/config.mk
index 525b639..c35bfda 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -148,7 +148,7 @@
 
 # Pruned directory options used when using findleaves.py
 # See envsetup.mk for a description of SCAN_EXCLUDE_DIRS
-FIND_LEAVES_EXCLUDES := $(addprefix --prune=, $(OUT_DIR) $(SCAN_EXCLUDE_DIRS) .repo .git)
+FIND_LEAVES_EXCLUDES := $(addprefix --prune=, $(SCAN_EXCLUDE_DIRS) .repo .git)
 
 # The build system exposes several variables for where to find the kernel
 # headers:
@@ -216,6 +216,9 @@
 endif
 TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))
 
+BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
+BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
+
 # Commands to generate .toc file common to ELF .so files.
 define _gen_toc_command_for_elf
 $(hide) ($($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) -d $(1) | grep SONAME || echo "No SONAME for $1") > $(2)
@@ -225,7 +228,7 @@
 # Commands to generate .toc file from Darwin dynamic library.
 define _gen_toc_command_for_macho
 $(hide) otool -l $(1) | grep LC_ID_DYLIB -A 5 > $(2)
-$(hide) nm -gP $(1) | cut -f1-2 -d" " | grep -v U$$ >> $(2)
+$(hide) nm -gP $(1) | cut -f1-2 -d" " | (grep -v U$$ >> $(2) || true)
 endef
 
 combo_target := HOST_
@@ -333,13 +336,10 @@
 2ND_TARGET_GCC_VERSION := 4.9
 endif
 
-# Normalize WITH_STATIC_ANALYZER and WITH_SYNTAX_CHECK
+# Normalize WITH_STATIC_ANALYZER
 ifeq ($(strip $(WITH_STATIC_ANALYZER)),0)
   WITH_STATIC_ANALYZER :=
 endif
-ifeq ($(strip $(WITH_SYNTAX_CHECK)),0)
-  WITH_SYNTAX_CHECK :=
-endif
 
 # define clang/llvm versions and base directory.
 include $(BUILD_SYSTEM)/clang/versions.mk
@@ -358,7 +358,7 @@
   PATH_TO_CLANG_TIDY :=
 endif
 
-# Disable WITH_STATIC_ANALYZER and WITH_SYNTAX_CHECK if tool can't be found
+# Disable WITH_STATIC_ANALYZER if tool can't be found
 SYNTAX_TOOLS_PREFIX := \
     $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/tools/scan-build/libexec
 ifneq ($(strip $(WITH_STATIC_ANALYZER)),)
@@ -368,14 +368,6 @@
   endif
 endif
 
-# WITH_STATIC_ANALYZER trumps WITH_SYNTAX_CHECK
-ifneq ($(strip $(WITH_STATIC_ANALYZER)),)
-  ifneq ($(strip $(WITH_SYNTAX_CHECK)),)
-    $(warning *** Disable WITH_SYNTAX_CHECK in the presence of static analyzer WITH_STATIC_ANALYZER)
-    WITH_SYNTAX_CHECK :=
-  endif
-endif
-
 # Pick a Java compiler.
 include $(BUILD_SYSTEM)/combo/javac.mk
 
@@ -474,7 +466,11 @@
 
 # Always use prebuilts for ckati and makeparallel
 prebuilt_build_tools := prebuilts/build-tools
+ifeq ($(filter address,$(SANITIZE_HOST)),)
 prebuilt_build_tools_bin := $(prebuilt_build_tools)/$(HOST_PREBUILT_TAG)/bin
+else
+prebuilt_build_tools_bin := $(prebuilt_build_tools)/$(HOST_PREBUILT_TAG)/asan/bin
+endif
 ACP := $(prebuilt_build_tools_bin)/acp
 CKATI := $(prebuilt_build_tools_bin)/ckati
 IJAR := $(prebuilt_build_tools_bin)/ijar
@@ -549,10 +545,10 @@
 else
 BPTTOOL := $(BOARD_CUSTOM_BPTTOOL)
 endif
-ifeq (,$(strip $(BOARD_CUSTOM_BVBTOOL)))
-BVBTOOL := $(HOST_OUT_EXECUTABLES)/bvbtool$(HOST_EXECUTABLE_SUFFIX)
+ifeq (,$(strip $(BOARD_CUSTOM_AVBTOOL)))
+AVBTOOL := $(HOST_OUT_EXECUTABLES)/avbtool$(HOST_EXECUTABLE_SUFFIX)
 else
-BVBTOOL := $(BOARD_CUSTOM_BVBTOOL)
+AVBTOOL := $(BOARD_CUSTOM_AVBTOOL)
 endif
 APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX)
 FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
@@ -794,4 +790,39 @@
 export PATH:=$(abspath $(BUILD_SYSTEM)/no_java_path):$(PATH)
 endif
 
+# Projects clean of compiler warnings should be compiled with -Werror.
+# If most modules in a directory such as external/ have warnings,
+# the directory should be in ANDROID_WARNING_ALLOWED_PROJECTS list.
+# When some of its subdirectories are cleaned up, the subdirectories
+# can be added into ANDROID_WARNING_DISALLOWED_PROJECTS list, e.g.
+# external/fio/.
+ANDROID_WARNING_DISALLOWED_PROJECTS := \
+    art/% \
+    bionic/% \
+    external/fio/% \
+
+define find_warning_disallowed_projects
+    $(filter $(ANDROID_WARNING_DISALLOWED_PROJECTS),$(1)/)
+endef
+
+# Projects with compiler warnings are compiled without -Werror.
+ANDROID_WARNING_ALLOWED_PROJECTS := \
+    bootable/% \
+    cts/% \
+    dalvik/% \
+    development/% \
+    device/% \
+    external/% \
+    frameworks/% \
+    hardware/% \
+    packages/% \
+    system/% \
+    test/vts/% \
+    tools/adt/idea/android/ultimate/get_modification_time/jni/% \
+    vendor/% \
+
+define find_warning_allowed_projects
+    $(filter $(ANDROID_WARNING_ALLOWED_PROJECTS),$(1)/)
+endef
+
 include $(BUILD_SYSTEM)/dumpvar.mk
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk
index ac3e4fc..2e14fef 100644
--- a/core/config_sanitizers.mk
+++ b/core/config_sanitizers.mk
@@ -133,6 +133,11 @@
   endif
 endif
 
+ifneq ($(filter cfi,$(my_sanitize)),)
+  my_cflags += -flto -fsanitize-cfi-cross-dso -fvisibility=default
+  my_ldflags += -flto -fsanitize-cfi-cross-dso -fsanitize=cfi -Wl,-plugin-opt,O1 -Wl,-export-dynamic-symbol=__cfi_check
+endif
+
 # If local or global modules need ASAN, add linker flags.
 ifneq ($(filter address,$(my_global_sanitize) $(my_sanitize)),)
   my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
@@ -187,3 +192,13 @@
   recover_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_RECOVER)),
   my_cflags += -fsanitize-recover=$(recover_arg)
 endif
+
+ifneq ($(strip $(LOCAL_SANITIZE_DIAG)),)
+  notrap_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_DIAG)),
+  my_cflags += -fno-sanitize-trap=$(notrap_arg)
+  # Diagnostic requires a runtime library, unless ASan or TSan are also enabled.
+  ifeq ($(filter address thread,$(my_sanitize)),)
+    # Does not have to be the first DT_NEEDED unlike ASan.
+    my_shared_libraries += $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_RUNTIME_LIBRARY)
+  endif
+endif
diff --git a/core/definitions.mk b/core/definitions.mk
index 83f7efc..61e0461 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -718,15 +718,6 @@
 endef
 
 ###########################################################
-## Run rot13 on a string
-## $(1): the string.  Must be one line.
-###########################################################
-define rot13
-$(shell echo $(1) | tr 'a-zA-Z' 'n-za-mN-ZA-M')
-endef
-
-
-###########################################################
 ## Returns true if $(1) and $(2) are equal.  Returns
 ## the empty string if they are not equal.
 ###########################################################
@@ -3170,6 +3161,55 @@
 endef
 
 ###########################################################
+# Basic math functions for positive integers <= 100
+#
+# (SDK versions for example)
+###########################################################
+__MATH_NUMBERS :=  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 \
+                  21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
+                  41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
+                  61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 \
+                  81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
+
+# Returns true if $(1) is a positive integer <= 100, otherwise returns nothing.
+define math_is_number
+$(strip \
+  $(if $(1),,$(error Argument missing)) \
+  $(if $(word 2,$(1)),$(error Multiple words in a single argument: $(1))) \
+  $(if $(filter $(1),$(__MATH_NUMBERS)),true))
+endef
+
+#$(warning true == $(call math_is_number,2))
+#$(warning == $(call math_is_number,foo))
+#$(call math_is_number,1 2)
+#$(call math_is_number,no 2)
+
+define _math_check_valid
+$(if $(call math_is_number,$(1)),,$(error Only positive integers <= 100 are supported (not $(1))))
+endef
+
+#$(call _math_check_valid,0)
+#$(call _math_check_valid,1)
+#$(call _math_check_valid,100)
+#$(call _math_check_valid,101)
+#$(call _math_check_valid,)
+#$(call _math_check_valid,1 2)
+
+# Returns the greater of $1 or $2.
+# If $1 or $2 is not a positive integer <= 100, then an error is generated.
+define math_max
+$(strip $(call _math_check_valid,$(1)) $(call _math_check_valid,$(2)) \
+  $(lastword $(filter $(1) $(2),$(__MATH_NUMBERS))))
+endef
+
+#$(call math_max)
+#$(call math_max,1)
+#$(call math_max,1 2,3)
+#$(warning 1 == $(call math_max,1,1))
+#$(warning 42 == $(call math_max,5,42))
+#$(warning 42 == $(call math_max,42,5))
+
+###########################################################
 ## Other includes
 ###########################################################
 
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
index 5a2f07f..7a0fb95 100644
--- a/core/dex_preopt_libart.mk
+++ b/core/dex_preopt_libart.mk
@@ -25,10 +25,6 @@
 COMPILED_CLASSES := $(call word-colon,1,$(firstword \
     $(filter %system/etc/compiled-classes,$(PRODUCT_COPY_FILES))))
 
-# start of image reserved address space
-LIBART_IMG_HOST_BASE_ADDRESS   := 0x60000000
-LIBART_IMG_TARGET_BASE_ADDRESS := 0x70000000
-
 define get-product-default-property
 $(strip $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))))
 endef
@@ -45,7 +41,6 @@
 # building the image. We therefore limit the Xmx value. This isn't done
 # via a property as we want the larger Xmx value if we're running on a
 # MIPS device.
-LIBART_IMG_TARGET_BASE_ADDRESS := 0x30000000
 DEX2OAT_XMX := 128m
 endif
 
@@ -109,7 +104,8 @@
 	--instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
 	--instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
 	--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
-	--include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \
+	--include-patch-information --runtime-arg -Xnorelocate \
+	--no-generate-debug-info --generate-build-id \
 	--abort-on-hard-verifier-error \
 	--no-inline-from=core-oj.jar \
 	$(PRIVATE_DEX_PREOPT_FLAGS) \
diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk
index 1a0dc5b..5d383a9 100644
--- a/core/dex_preopt_libart_boot.mk
+++ b/core/dex_preopt_libart_boot.mk
@@ -52,7 +52,7 @@
 
 $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME): PRIVATE_2ND_ARCH_VAR_PREFIX := $(my_2nd_arch_prefix)
 # Use dex2oat debug version for better error reporting
-$($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) : $(LIBART_TARGET_BOOT_DEX_FILES) $(DEX2OAT_DEPENDENCY)
+$($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) : $(LIBART_TARGET_BOOT_DEX_FILES) $(PRELOADED_CLASSES) $(COMPILED_CLASSES) $(DEX2OAT_DEPENDENCY)
 	@echo "target dex2oat: $@"
 	@mkdir -p $(dir $@)
 	@mkdir -p $(dir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_TARGET_BOOT_OAT_UNSTRIPPED))
@@ -71,6 +71,7 @@
 		--instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
 		--instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
 		--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
-		--android-root=$(PRODUCT_OUT)/system --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \
+		--android-root=$(PRODUCT_OUT)/system --include-patch-information --runtime-arg -Xnorelocate \
+		--no-generate-debug-info --generate-build-id \
 		--multi-image --no-inline-from=core-oj.jar \
 		$(PRODUCT_DEX_PREOPT_BOOT_FLAGS) $(GLOBAL_DEXPREOPT_FLAGS) $(COMPILED_CLASSES_FLAGS) $(ART_BOOT_IMAGE_EXTRA_ARGS)
diff --git a/core/main.mk b/core/main.mk
index b20044a..dabe093 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -82,6 +82,7 @@
     ramdisk-nodeps \
     bootimage-nodeps \
     recoveryimage-nodeps \
+    vbmetaimage-nodeps \
     product-graph dump-products
 
 ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),)
@@ -503,12 +504,9 @@
 
 FULL_BUILD := true
 
-# Before we go and include all of the module makefiles, stash away
-# the PRODUCT_* values so that later we can verify they are not modified.
-stash_product_vars:=true
-ifeq ($(stash_product_vars),true)
-  $(call stash-product-vars, __STASHED)
-endif
+# Before we go and include all of the module makefiles, mark the PRODUCT_*
+# values readonly so that they won't be modified.
+$(call readonly-product-vars)
 
 ifneq ($(ONE_SHOT_MAKEFILE),)
 # We've probably been invoked by the "mm" shell function
@@ -573,10 +571,6 @@
 # Now with all Android.mks loaded we can do post cleaning steps.
 include $(BUILD_SYSTEM)/post_clean.mk
 
-ifeq ($(stash_product_vars),true)
-  $(call assert-product-vars, __STASHED)
-endif
-
 # -------------------------------------------------------------------
 # All module makefiles have been included at this point.
 # -------------------------------------------------------------------
@@ -659,6 +653,14 @@
 $(1): | $(2)
 endef
 
+# Use a normal dependency instead of an order-only dependency when installing
+# host dynamic binaries so that the timestamp of the final binary always
+# changes, even if the toc optimization has skipped relinking the binary
+# and its dependant shared libraries.
+define add-required-host-so-deps
+$(1): $(2)
+endef
+
 $(foreach m,$(ALL_MODULES), \
   $(eval r := $(ALL_MODULES.$(m).REQUIRED)) \
   $(if $(r), \
@@ -701,7 +703,9 @@
   $(if $(3),$(eval deps := $(addprefix host_cross_,$(deps))))\
   $(eval r := $(filter $($(root))/%,$(call module-installed-files,\
     $(deps))))\
-  $(eval $(call add-required-deps,$(word 2,$(p)),$(r)))\
+  $(if $(filter $(1),HOST_),\
+    $(eval $(call add-required-host-so-deps,$(word 2,$(p)),$(r))),\
+    $(eval $(call add-required-deps,$(word 2,$(p)),$(r))))\
   $(eval ALL_MODULES.$(mod).REQUIRED += $(deps)))
 endef
 
@@ -936,6 +940,9 @@
 .PHONY: bootimage
 bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
 
+.PHONY: vbmetaimage
+vbmetaimage: $(INSTALLED_VBMETAIMAGE_TARGET)
+
 .PHONY: auxiliary
 auxiliary: $(INSTALLED_AUX_TARGETS)
 
@@ -945,6 +952,7 @@
 	systemimage \
 	$(INSTALLED_BOOTIMAGE_TARGET) \
 	$(INSTALLED_RECOVERYIMAGE_TARGET) \
+	$(INSTALLED_VBMETAIMAGE_TARGET) \
 	$(INSTALLED_USERDATAIMAGE_TARGET) \
 	$(INSTALLED_CACHEIMAGE_TARGET) \
 	$(INSTALLED_BPTIMAGE_TARGET) \
diff --git a/core/ninja.mk b/core/ninja.mk
index f3aa70e..30146d2 100644
--- a/core/ninja.mk
+++ b/core/ninja.mk
@@ -1,4 +1,8 @@
+ifeq ($(filter address,$(SANITIZE_HOST)),)
 NINJA ?= prebuilts/build-tools/$(HOST_PREBUILT_TAG)/bin/ninja
+else
+NINJA ?= prebuilts/build-tools/$(HOST_PREBUILT_TAG)/asan/bin/ninja
+endif
 
 include $(BUILD_SYSTEM)/soong.mk
 
@@ -36,7 +40,6 @@
 	eng \
 	fusion \
 	oem_image \
-	old-cts \
 	online-system-api-sdk-docs \
 	pdk \
 	platform \
@@ -148,7 +151,7 @@
 .PHONY: ninja_wrapper
 ninja_wrapper: $(COMBINED_BUILD_NINJA) $(MAKEPARALLEL)
 	@echo Starting build with ninja
-	+$(hide) export NINJA_STATUS="$(NINJA_STATUS)" && source $(KATI_ENV_SH) && $(NINJA_MAKEPARALLEL) $(NINJA) $(NINJA_GOALS) -C $(TOP) -f $(COMBINED_BUILD_NINJA) $(NINJA_ARGS)
+	+$(hide) export NINJA_STATUS="$(NINJA_STATUS)" && source $(KATI_ENV_SH) && exec $(NINJA_MAKEPARALLEL) $(NINJA) -d keepdepfile $(NINJA_GOALS) -C $(TOP) -f $(COMBINED_BUILD_NINJA) $(NINJA_ARGS)
 
 # Dummy Android.mk and CleanSpec.mk files so that kati won't recurse into the
 # out directory
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index c31a07e..af59756 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -126,7 +126,7 @@
 ifdef prebuilt_module_is_a_library
 export_includes := $(intermediates)/export_includes
 $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
-$(export_includes) :
+$(export_includes): $(LOCAL_EXPORT_C_INCLUDE_DEPS)
 	@echo Export includes file: $< -- $@
 	$(hide) mkdir -p $(dir $@) && rm -f $@
 ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
diff --git a/core/product.mk b/core/product.mk
index ad9b022..d4790d5 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -296,33 +296,15 @@
 	GLOBAL_CLANG_CFLAGS_NO_OVERRIDE \
 
 #
-# Stash values of the variables in _product_stash_var_list.
-# $(1): Renamed prefix
+# Mark the variables in _product_stash_var_list as readonly
 #
-define stash-product-vars
+define readonly-product-vars
 $(foreach v,$(_product_stash_var_list), \
-        $(eval $(strip $(1))_$(call rot13,$(v)):=$$($$(v))) \
+	$(eval $(v) ?=) \
+	$(eval .KATI_READONLY := $(v)) \
  )
 endef
 
-#
-# Assert that the the variable stashed by stash-product-vars remains untouched.
-# $(1): The prefix as supplied to stash-product-vars
-#
-define assert-product-vars
-$(strip \
-  $(eval changed_variables:=)
-  $(foreach v,$(_product_stash_var_list), \
-    $(if $(call streq,$($(v)),$($(strip $(1))_$(call rot13,$(v)))),, \
-        $(eval $(warning $(v) has been modified: $($(v)))) \
-        $(eval $(warning previous value: $($(strip $(1))_$(call rot13,$(v))))) \
-        $(eval changed_variables := $(changed_variables) $(v))) \
-   ) \
-  $(if $(changed_variables),\
-    $(eval $(error The following variables have been changed: $(changed_variables))),)
-)
-endef
-
 define add-to-product-copy-files-if-exists
 $(if $(wildcard $(word 1,$(subst :, ,$(1)))),$(1))
 endef
diff --git a/core/product_config.mk b/core/product_config.mk
index 0d4ced3..3b8c0eb 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -189,6 +189,8 @@
 all_product_configs := $(get-all-product-makefiles)
 endif
 
+all_named_products :=
+
 # Find the product config makefile for the current product.
 # all_product_configs consists items like:
 # <product_name>:<path_to_the_product_makefile>
@@ -202,9 +204,11 @@
     $(eval _cpm_word2 := $(word 2,$(_cpm_words)))\
     $(if $(_cpm_word2),\
         $(eval all_product_makefiles += $(_cpm_word2))\
+        $(eval all_named_products += $(_cpm_word2))\
         $(if $(filter $(TARGET_PRODUCT),$(_cpm_word1)),\
             $(eval current_product_makefile += $(_cpm_word2)),),\
         $(eval all_product_makefiles += $(f))\
+        $(eval all_named_products += $(basename $(notdir $(f))))\
         $(if $(filter $(TARGET_PRODUCT),$(basename $(notdir $(f)))),\
             $(eval current_product_makefile += $(f)),)))
 _cpm_words :=
diff --git a/core/shared_library_internal.mk b/core/shared_library_internal.mk
index 05886fa..1a8975a 100644
--- a/core/shared_library_internal.mk
+++ b/core/shared_library_internal.mk
@@ -96,17 +96,23 @@
         STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX), \
         $(my_host_cross))/$(lib)$(gcno_suffix))
 
-GCNO_ARCHIVE := $(LOCAL_MODULE)$(gcno_suffix)
+ifdef LOCAL_IS_HOST_MODULE
+my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path))
+else
+my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
+endif
+
+GCNO_ARCHIVE := $(basename $(my_installed_module_stem))$(gcno_suffix)
 
 $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS := $(strip $(LOCAL_GCNO_FILES))
 $(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(strip $(built_whole_gcno_libraries)) $(strip $(built_static_gcno_libraries))
 $(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries) $(built_static_gcno_libraries)
 	$(transform-o-to-static-lib)
 
-$($(my_prefix)OUT_COVERAGE)/$(GCNO_ARCHIVE) : $(intermediates)/$(GCNO_ARCHIVE)
+$(my_coverage_path)/$(GCNO_ARCHIVE) : $(intermediates)/$(GCNO_ARCHIVE)
 	$(copy-file-to-target)
 
-$(LOCAL_BUILT_MODULE): $($(my_prefix)OUT_COVERAGE)/$(GCNO_ARCHIVE)
+$(LOCAL_BUILT_MODULE): $(my_coverage_path)/$(GCNO_ARCHIVE)
 endif
 
 endif  # skip_build_from_source
diff --git a/core/tasks/old-cts.mk b/core/tasks/old-cts.mk
deleted file mode 100644
index 7024638..0000000
--- a/core/tasks/old-cts.mk
+++ /dev/null
@@ -1,399 +0,0 @@
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-cts_dir := $(HOST_OUT)/old-cts
-cts_tools_src_dir := cts/tools
-
-cts_name := old-android-cts
-
-JUNIT_HOST_JAR := $(HOST_OUT_JAVA_LIBRARIES)/junit.jar
-HOSTTESTLIB_JAR := $(HOST_OUT_JAVA_LIBRARIES)/hosttestlib.jar
-TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
-CTS_TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/old-cts-tradefed.jar
-CTS_TF_EXEC_PATH ?= $(HOST_OUT_EXECUTABLES)/old-cts-tradefed
-CTS_TF_README_PATH := $(cts_tools_src_dir)/tradefed-host/README
-
-VMTESTSTF_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,vm-tests-tf,HOST)
-VMTESTSTF_JAR := $(VMTESTSTF_INTERMEDIATES)/android.core.vm-tests-tf.jar
-
-# The list of test packages that core-tests (libcore/Android.mk)
-# is split into.
-CTS_CORE_CASE_LIST := \
-	android.core.tests.libcore.package.dalvik \
-	android.core.tests.libcore.package.com \
-	android.core.tests.libcore.package.conscrypt \
-	android.core.tests.libcore.package.sun \
-	android.core.tests.libcore.package.tests \
-	android.core.tests.libcore.package.org \
-	android.core.tests.libcore.package.libcore \
-	android.core.tests.libcore.package.jsr166 \
-	android.core.tests.libcore.package.harmony_annotation \
-	android.core.tests.libcore.package.harmony_java_io \
-	android.core.tests.libcore.package.harmony_java_lang \
-	android.core.tests.libcore.package.harmony_java_math \
-	android.core.tests.libcore.package.harmony_java_net \
-	android.core.tests.libcore.package.harmony_java_nio \
-	android.core.tests.libcore.package.harmony_java_text \
-	android.core.tests.libcore.package.harmony_java_util \
-	android.core.tests.libcore.package.harmony_javax_security \
-	android.core.tests.libcore.package.okhttp \
-	android.core.tests.runner
-
-# Additional CTS packages for code under libcore
-CTS_CORE_CASE_LIST += \
-	android.core.tests.libcore.package.tzdata
-
-# The list of test packages that apache-harmony-tests (external/apache-harmony/Android.mk)
-# is split into.
-CTS_CORE_CASE_LIST += \
-	android.core.tests.libcore.package.harmony_beans \
-	android.core.tests.libcore.package.harmony_logging \
-	android.core.tests.libcore.package.harmony_prefs \
-	android.core.tests.libcore.package.harmony_sql
-
-
-CTS_TEST_JAR_LIST := \
-	cts-junit \
-	CtsJdwp \
-	cts-testng \
-	CtsLibcoreOj
-
-# Depend on the full package paths rather than the phony targets to avoid
-# rebuilding the packages every time.
-CTS_CORE_CASES := $(foreach pkg,$(CTS_CORE_CASE_LIST),$(call intermediates-dir-for,APPS,$(pkg))/package.apk)
-CTS_TEST_JAR_FILES := $(foreach c,$(CTS_TEST_JAR_LIST),$(call intermediates-dir-for,JAVA_LIBRARIES,$(c))/javalib.jar)
-
--include cts/OldCtsTestCaseList.mk
-
-# A module may have mutliple installed files (e.g. split apks)
-CTS_CASE_LIST_APKS :=
-$(foreach m, $(CTS_TEST_CASE_LIST),\
-  $(foreach fp, $(ALL_MODULES.$(m).BUILT_INSTALLED),\
-    $(eval pair := $(subst :,$(space),$(fp)))\
-    $(eval CTS_CASE_LIST_APKS += $(CTS_TESTCASES_OUT)/$(notdir $(word 2,$(pair))))))\
-$(foreach m, $(CTS_CORE_CASE_LIST),\
-  $(foreach fp, $(ALL_MODULES.$(m).BUILT_INSTALLED),\
-    $(eval pair := $(subst :,$(space),$(fp)))\
-    $(eval built := $(word 1,$(pair)))\
-    $(eval installed := $(CTS_TESTCASES_OUT)/$(notdir $(word 2,$(pair))))\
-    $(eval $(call copy-one-file, $(built), $(installed)))\
-    $(eval CTS_CASE_LIST_APKS += $(installed))))
-
-CTS_CASE_LIST_JARS :=
-$(foreach m, $(CTS_TEST_JAR_LIST),\
-  $(eval CTS_CASE_LIST_JARS += $(CTS_TESTCASES_OUT)/$(m).jar))
-
-CTS_SHARED_LIBS :=
-
-DEFAULT_TEST_PLAN := $(cts_dir)/$(cts_name)/resource/plans
-$(cts_dir)/all_cts_files_stamp: $(CTS_CORE_CASES) $(CTS_TEST_JAR_FILES) $(CTS_TEST_CASES) $(CTS_CASE_LIST_APKS) $(CTS_CASE_LIST_JARS) $(JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(TF_JAR) $(VMTESTSTF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(CTS_TF_README_PATH) $(ADDITIONAL_TF_JARS) $(ACP) $(CTS_SHARED_LIBS)
-
-# Make necessary directory for CTS
-	$(hide) mkdir -p $(TMP_DIR)
-	$(hide) mkdir -p $(PRIVATE_DIR)/docs
-	$(hide) mkdir -p $(PRIVATE_DIR)/tools
-	$(hide) mkdir -p $(PRIVATE_DIR)/repository/testcases
-	$(hide) mkdir -p $(PRIVATE_DIR)/repository/plans
-# Copy executable and JARs to CTS directory
-	$(hide) $(ACP) -fp $(VMTESTSTF_JAR) $(CTS_TESTCASES_OUT)
-	$(hide) $(ACP) -fp $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(TF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(ADDITIONAL_TF_JARS) $(CTS_TF_README_PATH) $(PRIVATE_DIR)/tools
-	$(hide) $(call copy-files-with-structure, $(CTS_SHARED_LIBS),$(HOST_OUT)/,$(PRIVATE_DIR))
-	$(hide) touch $@
-
-# Generate the test descriptions for the core-tests
-# Parameters:
-# $1 : The output file where the description should be written (without the '.xml' extension)
-# $2 : The AndroidManifest.xml corresponding to the test package
-# $3 : The jar file name on PRIVATE_CLASSPATH containing junit tests to search for
-# $4 : The package prefix of classes to include, possible empty
-# $5 : The architecture of the current build
-# $6 : The directory containing vogar expectations files
-# $7 : The Android.mk corresponding to the test package (required for host-side tests only)
-define generate-core-test-description
-@echo "Generate core-test description ("$(notdir $(1))")"
-$(hide) java -Xmx256M \
-	-Xbootclasspath/a:$(PRIVATE_CLASSPATH):$(JUNIT_HOST_JAR) \
-	-classpath $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOST_JDK_TOOLS_JAR) \
-	$(PRIVATE_PARAMS) CollectAllTests $(1) $(2) $(3) "$(4)" $(5) $(6) $(7)
-endef
-
-OJ_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-oj,,COMMON)
-CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-libart,,COMMON)
-CONSCRYPT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,conscrypt,,COMMON)
-BOUNCYCASTLE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,bouncycastle,,COMMON)
-APACHEXML_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,apache-xml,,COMMON)
-OKHTTP_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,okhttp-nojarjar,,COMMON)
-OKHTTPTESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,okhttp-tests-nojarjar,,COMMON)
-OKHTTP_REPACKAGED_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,okhttp,,COMMON)
-APACHEHARMONYTESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,apache-harmony-tests,,COMMON)
-SQLITEJDBC_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,sqlite-jdbc,,COMMON)
-JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
-CORETESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
-JSR166TESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,jsr166-tests,,COMMON)
-CONSCRYPTTESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,conscrypt-tests,,COMMON)
-TZDATAUPDATETESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,tzdata_update-tests,,COMMON)
-
-GEN_CLASSPATH := \
-    $(OJ_INTERMEDIATES)/classes.jar:$(CORE_INTERMEDIATES)/classes.jar:$(CONSCRYPT_INTERMEDIATES)/classes.jar:$(BOUNCYCASTLE_INTERMEDIATES)/classes.jar:$(APACHEXML_INTERMEDIATES)/classes.jar:$(APACHEHARMONYTESTS_INTERMEDIATES)/classes.jar:$(OKHTTP_INTERMEDIATES)/classes.jar:$(OKHTTPTESTS_INTERMEDIATES)/classes.jar:$(OKHTTP_REPACKAGED_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(SQLITEJDBC_INTERMEDIATES)/javalib.jar:$(CORETESTS_INTERMEDIATES)/javalib.jar:$(JSR166TESTS_INTERMEDIATES)/javalib.jar:$(CONSCRYPTTESTS_INTERMEDIATES)/javalib.jar:$(TZDATAUPDATETESTS_INTERMEDIATES)/javalib.jar
-
-CTS_CORE_XMLS := \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.com.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.conscrypt.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.sun.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tests.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.org.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.libcore.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.jsr166.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_annotation.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_io.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_lang.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_math.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_net.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_nio.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_text.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_util.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_javax_security.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_beans.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_logging.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_prefs.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_sql.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.okhttp.xml \
-	$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tzdata.xml \
-
-$(CTS_CORE_XMLS): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
-# Why does this depend on javalib.jar instead of classes.jar?  Because
-# even though the tool will operate on the classes.jar files, the
-# build system requires that dependencies use javalib.jar.  If
-# javalib.jar is up-to-date, then classes.jar is as well.  Depending
-# on classes.jar will build the files incorrectly.
-CTS_CORE_XMLS_DEPS := $(CTS_CORE_CASES) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(JUNIT_HOST_JAR) $(CORE_INTERMEDIATES)/javalib.jar $(BOUNCYCASTLE_INTERMEDIATES)/javalib.jar $(APACHEXML_INTERMEDIATES)/javalib.jar $(APACHEHARMONYTESTS_INTERMEDIATES)/javalib.jar $(OKHTTP_INTERMEDIATES)/javalib.jar $(OKHTTPTESTS_INTERMEDIATES)/javalib.jar $(OKHTTP_REPACKAGED_INTERMEDIATES)/javalib.jar $(SQLITEJDBC_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(CORETESTS_INTERMEDIATES)/javalib.jar $(JSR166TESTS_INTERMEDIATES)/javalib.jar $(CONSCRYPTTESTS_INTERMEDIATES)/javalib.jar $(TZDATAUPDATETESTS_INTERMEDIATES)/javalib.jar build/core/tasks/cts.mk | $(ACP)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik,\
-		cts/tests/core/libcore/dalvik/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,dalvik,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.com.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.com,\
-		cts/tests/core/libcore/com/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,com,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.conscrypt.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.conscrypt,\
-		cts/tests/core/libcore/conscrypt/AndroidManifest.xml,\
-		$(CONSCRYPTTESTS_INTERMEDIATES)/javalib.jar,,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.sun.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.sun,\
-		cts/tests/core/libcore/sun/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,sun,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tests.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tests,\
-		cts/tests/core/libcore/tests/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,tests,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.org.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.org,\
-		cts/tests/core/libcore/org/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,\
-		org.w3c.domts:\
-		org.apache.harmony.security.tests:\
-		org.apache.harmony.nio.tests:\
-		org.apache.harmony.crypto.tests:\
-		org.apache.harmony.regex.tests:\
-		org.apache.harmony.luni.tests:\
-		org.apache.harmony.tests.internal.net.www.protocol:\
-		org.apache.harmony.tests.javax.net:\
-		org.apache.harmony.tests.javax.xml:\
-		org.json,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.libcore.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.libcore,\
-		cts/tests/core/libcore/libcore/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,libcore,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.jsr166.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.jsr166,\
-		cts/tests/core/libcore/jsr166/AndroidManifest.xml,\
-		$(JSR166TESTS_INTERMEDIATES)/javalib.jar,jsr166,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_annotation.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_annotation,\
-		cts/tests/core/libcore/harmony_annotation/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.annotation.tests,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_io.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_io,\
-		cts/tests/core/libcore/harmony_java_io/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.io,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_lang.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_lang,\
-		cts/tests/core/libcore/harmony_java_lang/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.lang,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_math.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_math,\
-		cts/tests/core/libcore/harmony_java_math/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.math,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_net.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_net,\
-		cts/tests/core/libcore/harmony_java_net/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.net,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_nio.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_nio,\
-		cts/tests/core/libcore/harmony_java_nio/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.nio,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_text.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_text,\
-		cts/tests/core/libcore/harmony_java_text/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.text,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_util.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_util,\
-		cts/tests/core/libcore/harmony_java_util/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.util,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_javax_security.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_javax_security,\
-		cts/tests/core/libcore/harmony_javax_security/AndroidManifest.xml,\
-		$(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.javax.security,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_beans.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_beans,\
-		cts/tests/core/libcore/harmony_beans/AndroidManifest.xml,\
-		$(APACHEHARMONYTESTS_INTERMEDIATES)/javalib.jar,com.android.org.apache.harmony.beans,\
-		$(TARGET_ARCH),libcore/expectations external/apache-harmony/Android.mk)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_logging.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_logging,\
-		cts/tests/core/libcore/harmony_logging/AndroidManifest.xml,\
-		$(APACHEHARMONYTESTS_INTERMEDIATES)/javalib.jar,com.android.org.apache.harmony.logging,\
-		$(TARGET_ARCH),libcore/expectations external/apache-harmony/Android.mk)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_prefs.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_prefs,\
-		cts/tests/core/libcore/harmony_prefs/AndroidManifest.xml,\
-		$(APACHEHARMONYTESTS_INTERMEDIATES)/javalib.jar,com.android.org.apache.harmony.prefs,\
-		$(TARGET_ARCH),libcore/expectations external/apache-harmony/Android.mk)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_sql.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_sql,\
-		cts/tests/core/libcore/harmony_sql/AndroidManifest.xml,\
-		$(APACHEHARMONYTESTS_INTERMEDIATES)/javalib.jar,com.android.org.apache.harmony.sql,\
-		$(TARGET_ARCH),libcore/expectations external/apache-harmony/Android.mk)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.okhttp.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.okhttp,\
-		cts/tests/core/libcore/okhttp/AndroidManifest.xml,\
-		$(OKHTTPTESTS_INTERMEDIATES)/javalib.jar,,\
-		$(TARGET_ARCH),libcore/expectations)
-
-$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tzdata.xml: $(CTS_CORE_XMLS_DEPS)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tzdata,\
-		cts/tests/core/libcore/tzdata/AndroidManifest.xml,\
-		$(TZDATAUPDATETESTS_INTERMEDIATES)/javalib.jar,,\
-		$(TARGET_ARCH),libcore/expectations)
-
-# ----- Generate the test descriptions for the vm-tests-tf -----
-#
-CORE_VM_TEST_TF_DESC := $(CTS_TESTCASES_OUT)/android.core.vm-tests-tf.xml
-
-# core tests only needed to get hold of junit-framework-classes
-OJ_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-oj,,COMMON)
-CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-libart,,COMMON)
-JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
-
-GEN_CLASSPATH := $(OJ_INTERMEDIATES)/classes.jar:$(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(VMTESTSTF_JAR):$(TF_JAR)
-
-$(CORE_VM_TEST_TF_DESC): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
-# Please see big comment above on why this line depends on javalib.jar instead of classes.jar
-$(CORE_VM_TEST_TF_DESC): $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(JUNIT_HOST_JAR) $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(VMTESTSTF_JAR) | $(ACP)
-	$(hide) mkdir -p $(CTS_TESTCASES_OUT)
-	$(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.vm-tests-tf,\
-		cts/tests/vm-tests-tf/AndroidManifest.xml,\
-		$(VMTESTSTF_JAR),"",\
-		$(TARGET_ARCH),\
-		libcore/expectations,\
-		cts/tools/vm-tests-tf/Android.mk)
-
-# Generate the default test plan for User.
-# Usage: buildCts.py <testRoot> <ctsOutputDir> <tempDir> <androidRootDir> <docletPath>
-
-$(DEFAULT_TEST_PLAN): $(cts_dir)/all_cts_files_stamp $(cts_tools_src_dir)/utils/buildCts.py $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CTS_CORE_XMLS) $(CTS_TEST_XMLS) $(CORE_VM_TEST_TF_DESC)
-	$(hide) $(cts_tools_src_dir)/utils/buildCts.py cts/tests/tests/ $(PRIVATE_DIR) $(TMP_DIR) \
-		$(TOP) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar
-	$(hide) mkdir -p $(dir $@) && touch $@
-
-# Package CTS and clean up.
-#
-# TODO:
-#   Pack cts.bat into the same zip file as well. See http://buganizer/issue?id=1656821 for more details
-INTERNAL_CTS_TARGET := $(cts_dir)/$(cts_name).zip
-$(INTERNAL_CTS_TARGET): PRIVATE_NAME := $(cts_name)
-$(INTERNAL_CTS_TARGET): PRIVATE_CTS_DIR := $(cts_dir)
-$(INTERNAL_CTS_TARGET): PRIVATE_DIR := $(cts_dir)/$(cts_name)
-$(INTERNAL_CTS_TARGET): TMP_DIR := $(cts_dir)/temp
-$(INTERNAL_CTS_TARGET): $(cts_dir)/all_cts_files_stamp $(DEFAULT_TEST_PLAN)
-	$(hide) echo "Package CTS: $@"
-	$(hide) cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME)
-
-.PHONY: old-cts
-old-cts: $(INTERNAL_CTS_TARGET) adb
-$(call dist-for-goals,old-cts,$(INTERNAL_CTS_TARGET))
diff --git a/target/product/core_minimal.mk b/target/product/core_minimal.mk
index d19dcb2..e008640 100644
--- a/target/product/core_minimal.mk
+++ b/target/product/core_minimal.mk
@@ -75,6 +75,7 @@
     make_ext4fs \
     e2fsck \
     resize2fs \
+    tune2fs \
     screencap \
     sensorservice \
     telephony-common \
diff --git a/target/product/core_tiny.mk b/target/product/core_tiny.mk
index ec2fa41..ea70454 100644
--- a/target/product/core_tiny.mk
+++ b/target/product/core_tiny.mk
@@ -72,6 +72,7 @@
     make_ext4fs \
     e2fsck \
     resize2fs \
+    tune2fs \
     nullwebview \
     screencap \
     sensorservice \
diff --git a/target/product/embedded.mk b/target/product/embedded.mk
index 55de3b9..5faf24f 100644
--- a/target/product/embedded.mk
+++ b/target/product/embedded.mk
@@ -32,6 +32,7 @@
     grep \
     gzip \
     healthd \
+    hwservicemanager \
     init \
     init.environ.rc \
     init.rc \
diff --git a/tools/droiddoc/templates-ds/customizations.cs b/tools/droiddoc/templates-ds/customizations.cs
index 75559e6..c1138f5 100644
--- a/tools/droiddoc/templates-ds/customizations.cs
+++ b/tools/droiddoc/templates-ds/customizations.cs
@@ -10,7 +10,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs 
-        include:"../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
 
 
       </div>
@@ -25,7 +25,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs 
-        include:"../../../../frameworks/base/docs/html/resources/resources_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/resources/resources_toc.cs" ?>
 
 
       </div>
@@ -43,7 +43,7 @@
       <div id="devdoc-nav" class="scroll-pane">
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 <?cs 
-        include:"../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
         
         
       </div>
@@ -63,7 +63,7 @@
 
 
 <?cs 
-        include:"../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
         
 
       </div>
@@ -83,7 +83,7 @@
 
 
 <?cs 
-        include:"../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
         
 
       </div>
@@ -103,7 +103,7 @@
 
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
        
 
       </div>
@@ -122,7 +122,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/distribute/distribute_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/distribute/distribute_toc.cs" ?>
         
 
       </div>
@@ -142,7 +142,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
         
 
       </div>
@@ -166,7 +166,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
         
 
       </div>
@@ -186,7 +186,7 @@
 
 
 <?cs 
-        include:"../../../../frameworks/base/docs/html/distribute/more/more_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/distribute/more/more_toc.cs" ?>
         
 
       </div>
diff --git a/tools/droiddoc/templates-ndk/assets/css/default.css b/tools/droiddoc/templates-ndk/assets/css/default.css
index f411d93..036c0eb 100644
--- a/tools/droiddoc/templates-ndk/assets/css/default.css
+++ b/tools/droiddoc/templates-ndk/assets/css/default.css
@@ -4217,7 +4217,7 @@
 }
 
 /* offset the <a name=""> tags to account for sticky nav */
-body.reference a[name] {
+body.reference a[name]:empty {
   visibility: hidden;
   display: block;
   position: relative;
diff --git a/tools/droiddoc/templates-ndk/customizations.cs b/tools/droiddoc/templates-ndk/customizations.cs
index 0c640de..808bc81 100644
--- a/tools/droiddoc/templates-ndk/customizations.cs
+++ b/tools/droiddoc/templates-ndk/customizations.cs
@@ -9,7 +9,7 @@
       <div id="devdoc-nav" class="scroll-pane">
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
 
 
       </div>
@@ -25,7 +25,7 @@
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
 <?cs
-        include:"../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
 
 
       </div>
@@ -43,7 +43,7 @@
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
 <?cs
-        include:"../../../../frameworks/base/docs/html-ndk/ndk/guides/guides_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html-ndk/ndk/guides/guides_toc.cs" ?>
 
 
       </div>
@@ -62,7 +62,7 @@
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
 <?cs
-        include:"../../../../frameworks/base/docs/html-ndk/ndk/reference/reference_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html-ndk/ndk/reference/reference_toc.cs" ?>
 
 
       </div>
@@ -81,7 +81,7 @@
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
 <?cs
-        include:"../../../../frameworks/base/docs/html-ndk/ndk/samples/samples_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html-ndk/ndk/samples/samples_toc.cs" ?>
 
 
       </div>
@@ -100,7 +100,7 @@
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
 <?cs
-        include:"../../../../frameworks/base/docs/html-ndk/ndk/downloads/downloads_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html-ndk/ndk/downloads/downloads_toc.cs" ?>
 
 
       </div>
@@ -120,7 +120,7 @@
 
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
 
 
       </div>
@@ -136,7 +136,7 @@
   <div class="wrap clearfix" id="body-content">
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/googleplay/googleplay_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/googleplay/googleplay_toc.cs" ?>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -150,7 +150,7 @@
   <div class="wrap clearfix" id="body-content">
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/essentials/essentials_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/essentials/essentials_toc.cs" ?>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -164,7 +164,7 @@
   <div class="wrap clearfix" id="body-content">
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/users/users_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/users/users_toc.cs" ?>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -178,7 +178,7 @@
   <div class="wrap clearfix" id="body-content">
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/engage/engage_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/engage/engage_toc.cs" ?>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -192,7 +192,7 @@
   <div class="wrap clearfix" id="body-content">
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/analyze/analyze_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/analyze/analyze_toc.cs" ?>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -206,7 +206,7 @@
   <div class="wrap clearfix" id="body-content">
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/monetize/monetize_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/monetize/monetize_toc.cs" ?>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -220,7 +220,7 @@
   <div class="wrap clearfix" id="body-content">
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/tools/disttools_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/tools/disttools_toc.cs" ?>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -234,7 +234,7 @@
   <div class="wrap clearfix" id="body-content">
     <div class="col-3" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/stories/stories_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/stories/stories_toc.cs" ?>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -250,7 +250,7 @@
       <div id="devdoc-nav" class="scroll-pane">
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
 
 
       </div>
@@ -269,7 +269,7 @@
 
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
 
 
       </div>
@@ -287,7 +287,7 @@
       <div id="devdoc-nav" class="scroll-pane">
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/distribute/distribute_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/distribute/distribute_toc.cs" ?>
 
 
       </div>
@@ -306,7 +306,7 @@
       <div id="devdoc-nav" class="scroll-pane">
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/samples/samples_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/samples/samples_toc.cs" ?>
 
       </div>
 
@@ -325,7 +325,7 @@
       <div id="devdoc-nav" class="scroll-pane">
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
 
 
       </div>
@@ -348,7 +348,7 @@
       <div id="devdoc-nav" class="scroll-pane">
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
 
 
       </div>
@@ -368,7 +368,7 @@
       <div id="devdoc-nav" class="scroll-pane">
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/wear/wear_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/wear/wear_toc.cs" ?>
 
 
       </div>
@@ -386,7 +386,7 @@
     <div class="col-4" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav" class="scroll-pane">
         <?cs
-          include:"../../../../frameworks/base/docs/html/preview/preview_toc.cs" ?>
+          include:"../../../../../frameworks/base/docs/html/preview/preview_toc.cs" ?>
       </div>
     </div> <!-- end side-nav -->
     <script>
diff --git a/tools/droiddoc/templates-pdk/customizations.cs b/tools/droiddoc/templates-pdk/customizations.cs
index e4fbbb9..15f67ea 100644
--- a/tools/droiddoc/templates-pdk/customizations.cs
+++ b/tools/droiddoc/templates-pdk/customizations.cs
@@ -3,7 +3,7 @@
   <div class="g-section g-tpl-240" id="body-content">
     <div class="g-unit g-first" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav"><?cs 
-        include:"../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
       </div>
     </div> <!-- end side-nav -->
 <?cs /def ?>
@@ -12,7 +12,7 @@
   <div class="g-section g-tpl-240" id="body-content">
     <div class="g-unit g-first" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav"><?cs 
-        include:"../../../../frameworks/base/docs/html/resources/resources_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/resources/resources_toc.cs" ?>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -26,7 +26,7 @@
   <div class="g-section g-tpl-240" id="body-content">
     <div class="g-unit g-first" id="side-nav" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <div id="devdoc-nav"><?cs 
-        include:"../../../../vendor/pdk/data/google/docs/guide/guide_toc.cs" ?>
+        include:"../../../../../vendor/pdk/data/google/docs/guide/guide_toc.cs" ?>
       </div>
     </div> <!-- end side-nav -->
     <script>
@@ -37,7 +37,7 @@
 <?cs /def ?>
 <?cs
 def:design_nav() ?>
-  <?cs include:"../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
+  <?cs include:"../../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
 <?cs /def ?>
 
 <?cs # The default side navigation for the reference docs ?><?cs 
diff --git a/tools/droiddoc/templates-sac/customizations.cs b/tools/droiddoc/templates-sac/customizations.cs
index 1120e70..01d3d72 100644
--- a/tools/droiddoc/templates-sac/customizations.cs
+++ b/tools/droiddoc/templates-sac/customizations.cs
@@ -10,7 +10,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs 
-        include:"../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
 
 
       </div>
@@ -25,7 +25,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs 
-        include:"../../../../frameworks/base/docs/html/resources/resources_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/resources/resources_toc.cs" ?>
 
 
       </div>
@@ -43,7 +43,7 @@
       <div id="devdoc-nav" class="scroll-pane">
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 <?cs 
-        include:"../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
         
         
       </div>
@@ -63,7 +63,7 @@
 
 
 <?cs 
-        include:"../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
         
 
       </div>
@@ -83,7 +83,7 @@
 
 
 <?cs 
-        include:"../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
         
 
       </div>
@@ -103,7 +103,7 @@
 
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
        
 
       </div>
@@ -122,7 +122,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/distribute/distribute_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/distribute/distribute_toc.cs" ?>
         
 
       </div>
@@ -142,7 +142,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
         
 
       </div>
@@ -166,7 +166,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs
-        include:"../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
         
 
       </div>
@@ -186,7 +186,7 @@
 
 
 <?cs 
-        include:"../../../../frameworks/base/docs/html/distribute/more/more_toc.cs" ?>
+        include:"../../../../../frameworks/base/docs/html/distribute/more/more_toc.cs" ?>
         
 
       </div>
@@ -397,7 +397,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs 
-        include:"../../../../docs/source.android.com/src/devices/devices_toc.cs" ?>
+        include:"../../../../../docs/source.android.com/src/devices/devices_toc.cs" ?>
 
       </div>
       <script type="text/javascript">
@@ -419,7 +419,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs 
-        include:"../../../../docs/source.android.com/src/compatibility/compatibility_toc.cs" ?>
+        include:"../../../../../docs/source.android.com/src/compatibility/compatibility_toc.cs" ?>
 
       </div>
     </div> <!-- end side-nav -->
@@ -438,7 +438,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs 
-        include:"../../../../docs/source.android.com/src/source/source_toc.cs" ?>
+        include:"../../../../../docs/source.android.com/src/source/source_toc.cs" ?>
 
       </div>
     </div> <!-- end side-nav -->
@@ -457,7 +457,7 @@
 <a class="totop" href="#top" data-g-event="left-nav-top">to top</a>
 
 <?cs 
-        include:"../../../../docs/source.android.com/src/security/security_toc.cs" ?>
+        include:"../../../../../docs/source.android.com/src/security/security_toc.cs" ?>
 
       </div>
     </div> <!-- end side-nav -->
diff --git a/tools/droiddoc/templates-sdk-dev/assets/css/default.css b/tools/droiddoc/templates-sdk-dev/assets/css/default.css
index 43449d4..11bbacf 100644
--- a/tools/droiddoc/templates-sdk-dev/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk-dev/assets/css/default.css
@@ -3209,7 +3209,7 @@
 }
 
 /* offset the <a name=""> tags to account for sticky nav */
-body.reference a[name] {
+body.reference a[name]:empty {
   visibility: hidden;
   display: block;
   position: relative;
diff --git a/tools/droiddoc/templates-sdk-dev/customizations.cs b/tools/droiddoc/templates-sdk-dev/customizations.cs
index 44ae239..38584d2 100644
--- a/tools/droiddoc/templates-sdk-dev/customizations.cs
+++ b/tools/droiddoc/templates-sdk-dev/customizations.cs
@@ -18,7 +18,7 @@
   <!-- End: Fullscreen toggler -->
 
   <?cs if:reference.gcm || reference.gms ?>
-    <?cs include:"../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
+    <?cs include:"../../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
     <script type="text/javascript">
       showGoogleRefTree();
     </script>
@@ -83,10 +83,10 @@
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
 <?cs
-if:guide ?><?cs include:"../../../../frameworks/base/docs/html/ndk/guides/guides_toc.cs" ?><?cs
-elif:reference ?><?cs include:"../../../../frameworks/base/docs/html/ndk/reference/reference_toc.cs" ?><?cs
-elif:downloads ?><?cs include:"../../../../frameworks/base/docs/html/ndk/downloads/downloads_toc.cs" ?><?cs
-elif:samples ?><?cs include:"../../../../frameworks/base/docs/html/ndk/samples/samples_toc.cs" ?><?cs
+if:guide ?><?cs include:"../../../../../frameworks/base/docs/html/ndk/guides/guides_toc.cs" ?><?cs
+elif:reference ?><?cs include:"../../../../../frameworks/base/docs/html/ndk/reference/reference_toc.cs" ?><?cs
+elif:downloads ?><?cs include:"../../../../../frameworks/base/docs/html/ndk/downloads/downloads_toc.cs" ?><?cs
+elif:samples ?><?cs include:"../../../../../frameworks/base/docs/html/ndk/samples/samples_toc.cs" ?><?cs
 /if ?>
         </div>
       </div>
@@ -158,52 +158,52 @@
     <div class="dac-nav-sub dac-swap-section dac-right dac-active" itemscope itemtype="http://schema.org/SiteNavigationElement">
       <?cs if:ndk ?>
         <?cs if:guide ?>
-          <?cs include:"../../../../frameworks/base/docs/html/ndk/guides/guides_toc.cs" ?>
+          <?cs include:"../../../../../frameworks/base/docs/html/ndk/guides/guides_toc.cs" ?>
         <?cs elif:reference ?>
-          <?cs include:"../../../../frameworks/base/docs/html/ndk/reference/reference_toc.cs" ?>
+          <?cs include:"../../../../../frameworks/base/docs/html/ndk/reference/reference_toc.cs" ?>
         <?cs elif:downloads ?>
-          <?cs include:"../../../../frameworks/base/docs/html/ndk/downloads/downloads_toc.cs" ?>
+          <?cs include:"../../../../../frameworks/base/docs/html/ndk/downloads/downloads_toc.cs" ?>
         <?cs elif:samples ?>
-          <?cs include:"../../../../frameworks/base/docs/html/ndk/samples/samples_toc.cs" ?>
+          <?cs include:"../../../../../frameworks/base/docs/html/ndk/samples/samples_toc.cs" ?>
         <?cs else ?>
           <?cs call:reference_default_nav() ?>
         <?cs /if ?>
       <?cs elif:guide ?>
-        <?cs include:"../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
+        <?cs include:"../../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
       <?cs elif:design ?>
-        <?cs include:"../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
+        <?cs include:"../../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
       <?cs elif:training ?>
-        <?cs include:"../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
+        <?cs include:"../../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
       <?cs elif:tools ?>
-        <?cs include:"../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
+        <?cs include:"../../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
       <?cs elif:google ?>
-        <?cs include:"../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
+        <?cs include:"../../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
       <?cs elif:samples ?>
-        <?cs include:"../../../../frameworks/base/docs/html/samples/samples_toc.cs" ?>
+        <?cs include:"../../../../../frameworks/base/docs/html/samples/samples_toc.cs" ?>
       <?cs elif:preview ?>
-        <?cs include:"../../../../frameworks/base/docs/html/preview/preview_toc.cs" ?>
+        <?cs include:"../../../../../frameworks/base/docs/html/preview/preview_toc.cs" ?>
       <?cs elif:preview ?>
-        <?cs include:"../../../../frameworks/base/docs/html/wear/preview/preview_toc.cs" ?>
+        <?cs include:"../../../../../frameworks/base/docs/html/wear/preview/preview_toc.cs" ?>
       <?cs elif:distribute ?>
         <?cs if:googleplay ?>
-          <?cs include:"../../../../frameworks/base/docs/html/distribute/googleplay/googleplay_toc.cs" ?>
+          <?cs include:"../../../../../frameworks/base/docs/html/distribute/googleplay/googleplay_toc.cs" ?>
         <?cs elif:essentials ?>
-          <?cs include:"../../../../frameworks/base/docs/html/distribute/essentials/essentials_toc.cs" ?>
+          <?cs include:"../../../../../frameworks/base/docs/html/distribute/essentials/essentials_toc.cs" ?>
         <?cs elif:users ?>
-          <?cs include:"../../../../frameworks/base/docs/html/distribute/users/users_toc.cs" ?>
+          <?cs include:"../../../../../frameworks/base/docs/html/distribute/users/users_toc.cs" ?>
         <?cs elif:engage ?>
-          <?cs include:"../../../../frameworks/base/docs/html/distribute/engage/engage_toc.cs" ?>
+          <?cs include:"../../../../../frameworks/base/docs/html/distribute/engage/engage_toc.cs" ?>
         <?cs elif:monetize ?>
-          <?cs include:"../../../../frameworks/base/docs/html/distribute/monetize/monetize_toc.cs" ?>
+          <?cs include:"../../../../../frameworks/base/docs/html/distribute/monetize/monetize_toc.cs" ?>
         <?cs elif:analyze ?>
-          <?cs include:"../../../../frameworks/base/docs/html/distribute/analyze/analyze_toc.cs" ?>
+          <?cs include:"../../../../../frameworks/base/docs/html/distribute/analyze/analyze_toc.cs" ?>
         <?cs elif:disttools ?>
-          <?cs include:"../../../../frameworks/base/docs/html/distribute/tools/disttools_toc.cs" ?>
+          <?cs include:"../../../../../frameworks/base/docs/html/distribute/tools/disttools_toc.cs" ?>
         <?cs elif:stories ?>
-          <?cs include:"../../../../frameworks/base/docs/html/distribute/stories/stories_toc.cs" ?>
+          <?cs include:"../../../../../frameworks/base/docs/html/distribute/stories/stories_toc.cs" ?>
         <?cs /if ?>
       <?cs elif:about ?>
-        <?cs include:"../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
+        <?cs include:"../../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
       <?cs else ?>
         <?cs call:reference_default_nav() ?>
       <?cs /if ?>
diff --git a/tools/droiddoc/templates-sdk-dev/sdkpage.cs b/tools/droiddoc/templates-sdk-dev/sdkpage.cs
index 1785fa0..1f3bf90 100644
--- a/tools/droiddoc/templates-sdk-dev/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk-dev/sdkpage.cs
@@ -1,6 +1,6 @@
 <?cs include:"doctype.cs" ?>
 <?cs include:"macros.cs" ?>
-<?cs include:"../../../../frameworks/base/docs/html/sdk/sdk_vars.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/sdk/sdk_vars.cs" ?>
 <html<?cs if:devsite ?> devsite<?cs /if ?>>
 <?cs if:sdk.redirect ?>
   <head>
diff --git a/tools/droiddoc/templates-sdk-refonly/assets/css/default.css b/tools/droiddoc/templates-sdk-refonly/assets/css/default.css
index 106ab2f..d12852a 100644
--- a/tools/droiddoc/templates-sdk-refonly/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk-refonly/assets/css/default.css
@@ -732,7 +732,7 @@
     text-align:center;
     width: 50%;
   }
-  
+
   .training-nav-top a.prev-page-link {
     padding-left: 15px;
     text-align: left;
@@ -840,7 +840,7 @@
     margin: 0 0 6px;
     line-height: 16px;
   }
-  
+
   /* Class colors */
   ol.class-list li:nth-child(10n+1) .title {
     background: #00bcd4;
@@ -872,7 +872,7 @@
   ol.class-list li:nth-child(10n+10) .title {
     background: #7e57c2;
   }
-  
+
   @media (max-width: 719px) {
     ol.class-list ol,
     ol.class-list .description {
@@ -3822,8 +3822,8 @@
   display: none;
 }
 
-/* offset the <a name=""> tags to account for sticky nav */
-body.reference a[name] {
+/* offset the empty <a name=""> tags to account for sticky nav */
+body.reference a[name]:empty {
   visibility: hidden;
   display: block;
   position: relative;
@@ -6376,7 +6376,7 @@
 .dac-button.dac-raised.dac-primary, .landing-secondary, .button {
   background-color: #039bef; }
   .dac-button.dac-raised.dac-primary:hover, .landing-secondary:hover, .button:hover {
-    background-color: #0288d1; 
+    background-color: #0288d1;
     color:#fff; }
   .dac-button.dac-raised.dac-primary:active, .landing-secondary:active, .button:active {
     background-color: #0277bd;
diff --git a/tools/droiddoc/templates-sdk-refonly/customizations.cs b/tools/droiddoc/templates-sdk-refonly/customizations.cs
index 16469ac..1f48c16 100644
--- a/tools/droiddoc/templates-sdk-refonly/customizations.cs
+++ b/tools/droiddoc/templates-sdk-refonly/customizations.cs
@@ -17,7 +17,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -34,7 +34,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -51,7 +51,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -68,7 +68,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/googleplay/googleplay_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/googleplay/googleplay_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -85,7 +85,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/preview/preview_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/preview/preview_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -102,7 +102,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/essentials/essentials_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/essentials/essentials_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -119,7 +119,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/users/users_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/users/users_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -136,7 +136,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/engage/engage_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/engage/engage_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -153,7 +153,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/analyze/analyze_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/analyze/analyze_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -170,7 +170,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/monetize/monetize_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/monetize/monetize_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -187,7 +187,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/tools/disttools_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/tools/disttools_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -204,7 +204,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/stories/stories_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/stories/stories_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -221,7 +221,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -238,7 +238,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -255,7 +255,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/distribute_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/distribute_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -273,7 +273,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/samples/samples_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/samples/samples_toc.cs" ?>
         </div>
       </div>
 
@@ -292,7 +292,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
         </div>
       </div>
       <script type="text/javascript">
@@ -314,7 +314,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -333,7 +333,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/wear/wear_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/wear/wear_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -463,10 +463,10 @@
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
 <?cs
-if:guide ?><?cs include:"../../../../frameworks/base/docs/html/ndk/guides/guides_toc.cs" ?><?cs
-elif:reference ?><?cs include:"../../../../frameworks/base/docs/html/ndk/reference/reference_toc.cs" ?><?cs
-elif:downloads ?><?cs include:"../../../../frameworks/base/docs/html/ndk/downloads/downloads_toc.cs" ?><?cs
-elif:samples ?><?cs include:"../../../../frameworks/base/docs/html/ndk/samples/samples_toc.cs" ?><?cs
+if:guide ?><?cs include:"../../../../../frameworks/base/docs/html/ndk/guides/guides_toc.cs" ?><?cs
+elif:reference ?><?cs include:"../../../../../frameworks/base/docs/html/ndk/reference/reference_toc.cs" ?><?cs
+elif:downloads ?><?cs include:"../../../../../frameworks/base/docs/html/ndk/downloads/downloads_toc.cs" ?><?cs
+elif:samples ?><?cs include:"../../../../../frameworks/base/docs/html/ndk/samples/samples_toc.cs" ?><?cs
 /if ?>
         </div>
       </div>
diff --git a/tools/droiddoc/templates-sdk-refonly/sdkpage.cs b/tools/droiddoc/templates-sdk-refonly/sdkpage.cs
index 9076387..5274a04 100644
--- a/tools/droiddoc/templates-sdk-refonly/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk-refonly/sdkpage.cs
@@ -1,6 +1,6 @@
 <?cs include:"doctype.cs" ?>
 <?cs include:"macros.cs" ?>
-<?cs include:"../../../../frameworks/base/docs/html/sdk/sdk_vars.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/sdk/sdk_vars.cs" ?>
 <html<?cs if:devsite ?> devsite<?cs /if ?>>
 <?cs if:sdk.redirect ?>
   <head>
diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css
index accf7bf..c71f4f4 100644
--- a/tools/droiddoc/templates-sdk/assets/css/default.css
+++ b/tools/droiddoc/templates-sdk/assets/css/default.css
@@ -3822,15 +3822,14 @@
   display: none;
 }
 
-/* offset the <a name=""> tags to account for sticky nav */
-body.reference a[name] {
+/* offset the empty <a name=""> tags to account for sticky nav */
+body.reference a[name]:empty {
   visibility: hidden;
   display: block;
   position: relative;
   top: -56px;
 }
 
-
 /* Quicknav */
 .btn-quicknav {
   width:20px;
diff --git a/tools/droiddoc/templates-sdk/customizations.cs b/tools/droiddoc/templates-sdk/customizations.cs
index 4cf5abb..00d0bc7 100644
--- a/tools/droiddoc/templates-sdk/customizations.cs
+++ b/tools/droiddoc/templates-sdk/customizations.cs
@@ -17,7 +17,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/sdk/sdk_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -34,7 +34,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/tools/tools_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -51,7 +51,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/training/training_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -68,7 +68,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/googleplay/googleplay_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/googleplay/googleplay_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -85,7 +85,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/preview/preview_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/preview/preview_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -102,7 +102,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/essentials/essentials_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/essentials/essentials_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -119,7 +119,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/users/users_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/users/users_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -136,7 +136,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/engage/engage_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/engage/engage_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -153,7 +153,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/analyze/analyze_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/analyze/analyze_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -170,7 +170,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/monetize/monetize_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/monetize/monetize_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -187,7 +187,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/tools/disttools_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/tools/disttools_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -204,7 +204,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/stories/stories_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/stories/stories_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -221,7 +221,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/guide/guide_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -238,7 +238,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/design/design_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -255,7 +255,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/distribute/distribute_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/distribute/distribute_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -273,7 +273,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/samples/samples_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/samples/samples_toc.cs" ?>
         </div>
       </div>
 
@@ -292,7 +292,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/google/google_toc.cs" ?>
         </div>
       </div>
       <script type="text/javascript">
@@ -314,7 +314,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/about/about_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -333,7 +333,7 @@
       <?cs call:mobile_nav_toggle() ?>
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
-<?cs include:"../../../../frameworks/base/docs/html/wear/wear_toc.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/wear/wear_toc.cs" ?>
         </div>
       </div>
     </div> <!-- end side-nav -->
@@ -463,10 +463,10 @@
       <div class="dac-toggle-content" id="devdoc-nav">
         <div class="scroll-pane">
 <?cs
-if:guide ?><?cs include:"../../../../frameworks/base/docs/html/ndk/guides/guides_toc.cs" ?><?cs
-elif:reference ?><?cs include:"../../../../frameworks/base/docs/html/ndk/reference/reference_toc.cs" ?><?cs
-elif:downloads ?><?cs include:"../../../../frameworks/base/docs/html/ndk/downloads/downloads_toc.cs" ?><?cs
-elif:samples ?><?cs include:"../../../../frameworks/base/docs/html/ndk/samples/samples_toc.cs" ?><?cs
+if:guide ?><?cs include:"../../../../../frameworks/base/docs/html/ndk/guides/guides_toc.cs" ?><?cs
+elif:reference ?><?cs include:"../../../../../frameworks/base/docs/html/ndk/reference/reference_toc.cs" ?><?cs
+elif:downloads ?><?cs include:"../../../../../frameworks/base/docs/html/ndk/downloads/downloads_toc.cs" ?><?cs
+elif:samples ?><?cs include:"../../../../../frameworks/base/docs/html/ndk/samples/samples_toc.cs" ?><?cs
 /if ?>
         </div>
       </div>
diff --git a/tools/droiddoc/templates-sdk/sdkpage.cs b/tools/droiddoc/templates-sdk/sdkpage.cs
index c6679a6..62ce174 100644
--- a/tools/droiddoc/templates-sdk/sdkpage.cs
+++ b/tools/droiddoc/templates-sdk/sdkpage.cs
@@ -1,6 +1,6 @@
 <?cs include:"doctype.cs" ?>
 <?cs include:"macros.cs" ?>
-<?cs include:"../../../../frameworks/base/docs/html/sdk/sdk_vars.cs" ?>
+<?cs include:"../../../../../frameworks/base/docs/html/sdk/sdk_vars.cs" ?>
 <html<?cs if:devsite ?> devsite<?cs /if ?>>
 <?cs if:sdk.redirect ?>
   <head>
diff --git a/tools/kati_all_products.sh b/tools/kati_all_products.sh
new file mode 100755
index 0000000..4567dbd
--- /dev/null
+++ b/tools/kati_all_products.sh
@@ -0,0 +1,7 @@
+#!/bin/bash -e
+
+cd $ANDROID_BUILD_TOP
+mkdir -p out.kati
+source build/envsetup.sh
+
+get_build_var all_named_products | sed "s/ /\n/g" | parallel "$@" --progress "(source build/envsetup.sh; lunch {}-eng && m -j OUT_DIR=out.kati/{} out.kati/{}/build-{}.ninja) >out.kati/log.{} 2>&1"
diff --git a/tools/makeparallel/makeparallel.cpp b/tools/makeparallel/makeparallel.cpp
index c70fa9a..4ae8f61 100644
--- a/tools/makeparallel/makeparallel.cpp
+++ b/tools/makeparallel/makeparallel.cpp
@@ -337,7 +337,29 @@
 
   args.push_back(nullptr);
 
-  pid_t pid = fork();
+  static pid_t pid;
+
+  // Set up signal handlers to forward SIGHUP, SIGINT, SIGQUIT, SIGTERM, and
+  // SIGALRM to child
+  struct sigaction action = {};
+  action.sa_flags = SA_SIGINFO | SA_RESTART,
+  action.sa_sigaction = [](int signal, siginfo_t*, void*) {
+    if (pid > 0) {
+      kill(pid, signal);
+    }
+  };
+
+  int ret = 0;
+  if (!ret) ret = sigaction(SIGHUP, &action, NULL);
+  if (!ret) ret = sigaction(SIGINT, &action, NULL);
+  if (!ret) ret = sigaction(SIGQUIT, &action, NULL);
+  if (!ret) ret = sigaction(SIGTERM, &action, NULL);
+  if (!ret) ret = sigaction(SIGALRM, &action, NULL);
+  if (ret < 0) {
+    error(errno, errno, "sigaction failed");
+  }
+
+  pid = fork();
   if (pid < 0) {
     error(errno, errno, "fork failed");
   } else if (pid == 0) {
@@ -361,9 +383,10 @@
   }
 
   // parent
+
   siginfo_t status = {};
   int exit_status = 0;
-  int ret = waitid(P_PID, pid, &status, WEXITED);
+  ret = waitid(P_PID, pid, &status, WEXITED);
   if (ret < 0) {
     error(errno, errno, "waitpid failed");
   } else if (status.si_code == CLD_EXITED) {
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index 5369c5b..2e26514 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -96,19 +96,6 @@
   imgname = BuildSystem(OPTIONS.input_tmp, OPTIONS.info_dict,
                         block_list=block_list)
 
-  # If requested, calculate and add dm-verity integrity hashes and
-  # metadata to system.img.
-  if OPTIONS.info_dict.get("board_bvb_enable", None) == "true":
-    bvbtool = os.getenv('BVBTOOL') or "bvbtool"
-    cmd = [bvbtool, "add_image_hashes", "--image", imgname]
-    args = OPTIONS.info_dict.get("board_bvb_add_image_hashes_args", None)
-    if args and args.strip():
-      cmd.extend(shlex.split(args))
-    p = common.Run(cmd, stdout=subprocess.PIPE)
-    p.communicate()
-    assert p.returncode == 0, "bvbtool add_image_hashes of %s image failed" % (
-      os.path.basename(OPTIONS.input_tmp),)
-
   common.ZipWrite(output_zip, imgname, prefix + "system.img")
   common.ZipWrite(output_zip, block_list, prefix + "system.map")
   return imgname
@@ -251,6 +238,25 @@
   shutil.rmtree(temp_dir)
 
 
+def AddVBMeta(output_zip, boot_img_path, system_img_path, prefix="IMAGES/"):
+  """Create a VBMeta image and store it in output_zip."""
+  _, img_file_name = tempfile.mkstemp()
+  avbtool = os.getenv('AVBTOOL') or "avbtool"
+  cmd = [avbtool, "make_vbmeta_image",
+         "--output", img_file_name,
+         "--include_descriptors_from_image", boot_img_path,
+         "--include_descriptors_from_image", system_img_path,
+         "--generate_dm_verity_cmdline_from_hashtree", system_img_path]
+  common.AppendAVBSigningArgs(cmd)
+  args = OPTIONS.info_dict.get("board_avb_make_vbmeta_image_args", None)
+  if args and args.strip():
+    cmd.extend(shlex.split(args))
+  p = common.Run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+  p.communicate()
+  assert p.returncode == 0, "avbtool make_vbmeta_image failed"
+  common.ZipWrite(output_zip, img_file_name, prefix + "vbmeta.img")
+
+
 def AddPartitionTable(output_zip, prefix="IMAGES/"):
   """Create a partition table image and store it in output_zip."""
 
@@ -346,15 +352,6 @@
 
   has_recovery = (OPTIONS.info_dict.get("no_recovery") != "true")
   system_root_image = (OPTIONS.info_dict.get("system_root_image", None) == "true")
-  board_bvb_enable = (OPTIONS.info_dict.get("board_bvb_enable", None) == "true")
-
-  # Brillo Verified Boot is incompatible with certain
-  # configurations. Explicitly check for these.
-  if board_bvb_enable:
-    assert not has_recovery, "has_recovery incompatible with bvb"
-    assert not system_root_image, "system_root_image incompatible with bvb"
-    assert not OPTIONS.rebuild_recovery, "rebuild_recovery incompatible with bvb"
-    assert not has_vendor, "VENDOR images currently incompatible with bvb"
 
   def banner(s):
     print "\n\n++++ " + s + " ++++\n\n"
@@ -368,17 +365,11 @@
       boot_image = common.GetBootableImage(
           "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
   else:
-    if board_bvb_enable:
-      # With Brillo Verified Boot, we need to build system.img before
-      # boot.img since the latter includes the dm-verity root hash and
-      # salt for the former.
-      pass
-    else:
-      banner("boot")
-      boot_image = common.GetBootableImage(
+    banner("boot")
+    boot_image = common.GetBootableImage(
         "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT")
-      if boot_image:
-        boot_image.AddToZip(output_zip)
+    if boot_image:
+      boot_image.AddToZip(output_zip)
 
   recovery_image = None
   if has_recovery:
@@ -399,15 +390,6 @@
   banner("system")
   system_img_path = AddSystem(
     output_zip, recovery_img=recovery_image, boot_img=boot_image)
-  if OPTIONS.info_dict.get("board_bvb_enable", None) == "true":
-    # If we're using Brillo Verified Boot, we can now build boot.img
-    # given that we have system.img.
-    banner("boot")
-    boot_image = common.GetBootableImage(
-      "IMAGES/boot.img", "boot.img", OPTIONS.input_tmp, "BOOT",
-      system_img_path=system_img_path)
-    if boot_image:
-      boot_image.AddToZip(output_zip)
   if has_vendor:
     banner("vendor")
     AddVendor(output_zip)
@@ -419,6 +401,10 @@
   if OPTIONS.info_dict.get("board_bpt_enable", None) == "true":
     banner("partition-table")
     AddPartitionTable(output_zip)
+  if OPTIONS.info_dict.get("board_avb_enable", None) == "true":
+    banner("vbmeta")
+    boot_contents = boot_image.WriteToTemp()
+    AddVBMeta(output_zip, boot_contents.name, system_img_path)
 
   # For devices using A/B update, copy over images from RADIO/ and/or
   # VENDOR_IMAGES/ to IMAGES/ and make sure we have all the needed
diff --git a/tools/releasetools/blockimgdiff.py b/tools/releasetools/blockimgdiff.py
index 66d5907..70bb4eb 100644
--- a/tools/releasetools/blockimgdiff.py
+++ b/tools/releasetools/blockimgdiff.py
@@ -695,10 +695,19 @@
     with open(prefix + ".new.dat", "wb") as new_f:
       for xf in self.transfers:
         if xf.style == "zero":
-          pass
+          tgt_size = xf.tgt_ranges.size() * self.tgt.blocksize
+          print("%10d %10d (%6.2f%%) %7s %s %s" % (
+              tgt_size, tgt_size, 100.0, xf.style, xf.tgt_name,
+              str(xf.tgt_ranges)))
+
         elif xf.style == "new":
           for piece in self.tgt.ReadRangeSet(xf.tgt_ranges):
             new_f.write(piece)
+          tgt_size = xf.tgt_ranges.size() * self.tgt.blocksize
+          print("%10d %10d (%6.2f%%) %7s %s %s" % (
+              tgt_size, tgt_size, 100.0, xf.style,
+              xf.tgt_name, str(xf.tgt_ranges)))
+
         elif xf.style == "diff":
           src = self.src.ReadRangeSet(xf.src_ranges)
           tgt = self.tgt.ReadRangeSet(xf.tgt_ranges)
@@ -725,6 +734,12 @@
             # These are identical; we don't need to generate a patch,
             # just issue copy commands on the device.
             xf.style = "move"
+            if xf.src_ranges != xf.tgt_ranges:
+              print("%10d %10d (%6.2f%%) %7s %s %s (from %s)" % (
+                  tgt_size, tgt_size, 100.0, xf.style,
+                  xf.tgt_name if xf.tgt_name == xf.src_name else (
+                      xf.tgt_name + " (from " + xf.src_name + ")"),
+                  str(xf.tgt_ranges), str(xf.src_ranges)))
           else:
             # For files in zip format (eg, APKs, JARs, etc.) we would
             # like to use imgdiff -z if possible (because it usually
@@ -772,10 +787,11 @@
           size = len(patch)
           with lock:
             patches[patchnum] = (patch, xf)
-            print("%10d %10d (%6.2f%%) %7s %s" % (
+            print("%10d %10d (%6.2f%%) %7s %s %s %s" % (
                 size, tgt_size, size * 100.0 / tgt_size, xf.style,
                 xf.tgt_name if xf.tgt_name == xf.src_name else (
-                    xf.tgt_name + " (from " + xf.src_name + ")")))
+                    xf.tgt_name + " (from " + xf.src_name + ")"),
+                str(xf.tgt_ranges), str(xf.src_ranges)))
 
       threads = [threading.Thread(target=diff_worker)
                  for _ in range(self.threads)]
@@ -1101,27 +1117,23 @@
   def FindTransfers(self):
     """Parse the file_map to generate all the transfers."""
 
-    def AddTransfer(tgt_name, src_name, tgt_ranges, src_ranges, style, by_id,
-                    split=False):
-      """Wrapper function for adding a Transfer().
+    def AddSplitTransfers(tgt_name, src_name, tgt_ranges, src_ranges,
+                          style, by_id):
+      """Add one or multiple Transfer()s by splitting large files.
 
       For BBOTA v3, we need to stash source blocks for resumable feature.
       However, with the growth of file size and the shrink of the cache
       partition source blocks are too large to be stashed. If a file occupies
-      too many blocks (greater than MAX_BLOCKS_PER_DIFF_TRANSFER), we split it
-      into smaller pieces by getting multiple Transfer()s.
+      too many blocks, we split it into smaller pieces by getting multiple
+      Transfer()s.
 
       The downside is that after splitting, we may increase the package size
       since the split pieces don't align well. According to our experiments,
       1/8 of the cache size as the per-piece limit appears to be optimal.
       Compared to the fixed 1024-block limit, it reduces the overall package
-      size by 30% volantis, and 20% for angler and bullhead."""
+      size by 30% for volantis, and 20% for angler and bullhead."""
 
-      # We care about diff transfers only.
-      if style != "diff" or not split:
-        Transfer(tgt_name, src_name, tgt_ranges, src_ranges, style, by_id)
-        return
-
+      # Possibly split large files into smaller chunks.
       pieces = 0
       cache_size = common.OPTIONS.cache_size
       split_threshold = 0.125
@@ -1157,6 +1169,74 @@
         Transfer(tgt_split_name, src_split_name, tgt_ranges, src_ranges, style,
                  by_id)
 
+    def AddTransfer(tgt_name, src_name, tgt_ranges, src_ranges, style, by_id,
+                    split=False):
+      """Wrapper function for adding a Transfer()."""
+
+      # We specialize diff transfers only (which covers bsdiff/imgdiff/move);
+      # otherwise add the Transfer() as is.
+      if style != "diff" or not split:
+        Transfer(tgt_name, src_name, tgt_ranges, src_ranges, style, by_id)
+        return
+
+      # Handle .odex files specially to analyze the block-wise difference. If
+      # most of the blocks are identical with only few changes (e.g. header),
+      # we will patch the changed blocks only. This avoids stashing unchanged
+      # blocks while patching. We limit the analysis to files without size
+      # changes only. This is to avoid sacrificing the OTA generation cost too
+      # much.
+      if (tgt_name.split(".")[-1].lower() == 'odex' and
+          tgt_ranges.size() == src_ranges.size()):
+
+        # 0.5 threshold can be further tuned. The tradeoff is: if only very
+        # few blocks remain identical, we lose the opportunity to use imgdiff
+        # that may have better compression ratio than bsdiff.
+        crop_threshold = 0.5
+
+        tgt_skipped = RangeSet()
+        src_skipped = RangeSet()
+        tgt_size = tgt_ranges.size()
+        tgt_changed = 0
+        for src_block, tgt_block in zip(src_ranges.next_item(),
+                                        tgt_ranges.next_item()):
+          src_rs = RangeSet(str(src_block))
+          tgt_rs = RangeSet(str(tgt_block))
+          if self.src.ReadRangeSet(src_rs) == self.tgt.ReadRangeSet(tgt_rs):
+            tgt_skipped = tgt_skipped.union(tgt_rs)
+            src_skipped = src_skipped.union(src_rs)
+          else:
+            tgt_changed += tgt_rs.size()
+
+          # Terminate early if no clear sign of benefits.
+          if tgt_changed > tgt_size * crop_threshold:
+            break
+
+        if tgt_changed < tgt_size * crop_threshold:
+          assert tgt_changed + tgt_skipped.size() == tgt_size
+          print('%10d %10d (%6.2f%%) %s' % (tgt_skipped.size(), tgt_size,
+                tgt_skipped.size() * 100.0 / tgt_size, tgt_name))
+          AddSplitTransfers(
+              "%s-skipped" % (tgt_name,),
+              "%s-skipped" % (src_name,),
+              tgt_skipped, src_skipped, style, by_id)
+
+          # Intentionally change the file extension to avoid being imgdiff'd as
+          # the files are no longer in their original format.
+          tgt_name = "%s-cropped" % (tgt_name,)
+          src_name = "%s-cropped" % (src_name,)
+          tgt_ranges = tgt_ranges.subtract(tgt_skipped)
+          src_ranges = src_ranges.subtract(src_skipped)
+
+          # Possibly having no changed blocks.
+          if not tgt_ranges:
+            return
+
+      # Add the transfer(s).
+      AddSplitTransfers(
+          tgt_name, src_name, tgt_ranges, src_ranges, style, by_id)
+
+    print("Finding transfers...")
+
     empty = RangeSet()
     for tgt_fn, tgt_ranges in self.tgt.file_map.items():
       if tgt_fn == "__ZERO":
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index a7b3fdd..50e81bf 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -27,6 +27,7 @@
 import sys
 import commands
 import common
+import shlex
 import shutil
 import sparse_img
 import tempfile
@@ -102,6 +103,51 @@
   simg = sparse_img.SparseImage(image_file, mode="r+b", build_map=False)
   simg.AppendFillChunk(0, blocks)
 
+def AVBCalcMaxImageSize(avbtool, partition_size, additional_args):
+  """Calculates max image size for a given partition size.
+
+  Args:
+    avbtool: String with path to avbtool.
+    partition_size: The size of the partition in question.
+    additional_args: Additional arguments to pass to 'avbtool
+      add_hashtree_image'.
+  Returns:
+    The maximum image size or 0 if an error occurred.
+  """
+  cmdline = "%s add_hashtree_footer " % avbtool
+  cmdline += "--partition_size %d " % partition_size
+  cmdline += "--calc_max_image_size "
+  cmdline += additional_args
+  (output, exit_code) = RunCommand(shlex.split(cmdline))
+  if exit_code != 0:
+    return 0
+  else:
+    return int(output)
+
+def AVBAddHashtree(image_path, avbtool, partition_size, partition_name,
+                   signing_args, additional_args):
+  """Adds dm-verity hashtree and AVB metadata to an image.
+
+  Args:
+    image_path: Path to image to modify.
+    avbtool: String with path to avbtool.
+    partition_size: The size of the partition in question.
+    partition_name: The name of the partition - will be embedded in metadata.
+    signing_args: Arguments for signing the image.
+    additional_args: Additional arguments to pass to 'avbtool
+      add_hashtree_image'.
+  Returns:
+    True if the operation succeeded.
+  """
+  cmdline = "%s add_hashtree_footer " % avbtool
+  cmdline += "--partition_size %d " % partition_size
+  cmdline += "--partition_name %s " % partition_name
+  cmdline += "--image %s " % image_path
+  cmdline += signing_args + " "
+  cmdline += additional_args
+  (_, exit_code) = RunCommand(shlex.split(cmdline))
+  return exit_code == 0
+
 def AdjustPartitionSizeForVerity(partition_size, fec_supported):
   """Modifies the provided partition size to account for the verity metadata.
 
@@ -375,6 +421,18 @@
     prop_dict["original_partition_size"] = str(partition_size)
     prop_dict["verity_size"] = str(verity_size)
 
+  # Adjust partition size for AVB.
+  if prop_dict.get("avb_enable") == "true":
+    avbtool = prop_dict.get("avb_avbtool")
+    partition_size = int(prop_dict.get("partition_size"))
+    additional_args = prop_dict["avb_add_hashtree_footer_args"]
+    max_image_size = AVBCalcMaxImageSize(avbtool, partition_size,
+                                         additional_args)
+    if max_image_size == 0:
+      return False
+    prop_dict["partition_size"] = str(max_image_size)
+    prop_dict["original_partition_size"] = str(partition_size)
+
   if fs_type.startswith("ext"):
     build_command = ["mkuserimg.sh"]
     if "extfs_sparse_flag" in prop_dict:
@@ -497,6 +555,17 @@
     if not MakeVerityEnabledImage(out_file, verity_fec_supported, prop_dict):
       return False
 
+  # Add AVB hashtree and metadata.
+  if "avb_enable" in prop_dict:
+    avbtool = prop_dict.get("avb_avbtool")
+    original_partition_size = int(prop_dict.get("original_partition_size"))
+    partition_name = prop_dict["partition_name"]
+    signing_args = prop_dict["avb_signing_args"]
+    additional_args = prop_dict["avb_add_hashtree_footer_args"]
+    if not AVBAddHashtree(out_file, avbtool, original_partition_size,
+                          partition_name, signing_args, additional_args):
+      return False
+
   if run_fsck and prop_dict.get("skip_fsck") != "true":
     success, unsparse_image = UnsparseImage(out_file, replace=False)
     if not success:
@@ -537,7 +606,9 @@
       "verity",
       "verity_key",
       "verity_signer_cmd",
-      "verity_fec"
+      "verity_fec",
+      "avb_signing_args",
+      "avb_avbtool"
       )
   for p in common_props:
     copy_prop(p, p)
@@ -559,6 +630,9 @@
     copy_prop("system_squashfs_compressor_opt", "squashfs_compressor_opt")
     copy_prop("system_squashfs_disable_4k_align", "squashfs_disable_4k_align")
     copy_prop("system_base_fs_file", "base_fs_file")
+    copy_prop("system_avb_enable", "avb_enable")
+    copy_prop("system_avb_add_hashtree_footer_args",
+              "avb_add_hashtree_footer_args")
   elif mount_point == "data":
     # Copy the generic fs type first, override with specific one if available.
     copy_prop("fs_type", "fs_type")
@@ -577,12 +651,15 @@
     copy_prop("vendor_squashfs_compressor_opt", "squashfs_compressor_opt")
     copy_prop("vendor_squashfs_disable_4k_align", "squashfs_disable_4k_align")
     copy_prop("vendor_base_fs_file", "base_fs_file")
+    copy_prop("vendor_avb_enable", "avb_enable")
+    copy_prop("vendor_avb_add_hashtree_footer_args",
+              "avb_add_hashtree_footer_args")
   elif mount_point == "oem":
     copy_prop("fs_type", "fs_type")
     copy_prop("oem_size", "partition_size")
     copy_prop("oem_journal_size", "journal_size")
     copy_prop("has_ext4_reserved_blocks", "has_ext4_reserved_blocks")
-
+  d["partition_name"] = mount_point
   return d
 
 
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 3f3b011..fad6a5e 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -384,6 +384,16 @@
     print "%-25s = (%s) %s" % (k, type(v).__name__, v)
 
 
+def AppendAVBSigningArgs(cmd):
+  """Append signing arguments for avbtool."""
+  keypath = OPTIONS.info_dict.get("board_avb_key_path", None)
+  algorithm = OPTIONS.info_dict.get("board_avb_algorithm", None)
+  if not keypath or not algorithm:
+    algorithm = "SHA256_RSA4096"
+    keypath = "external/avb/test/data/testkey_rsa4096.pem"
+  cmd.extend(["--key", keypath, "--algorithm", algorithm])
+
+
 def _BuildBootableImage(sourcedir, fs_config_file, info_dict=None,
                         has_ramdisk=False):
   """Build a bootable image from the specified sourcedir.
@@ -503,111 +513,20 @@
     img_unsigned.close()
     img_keyblock.close()
 
-  img.seek(os.SEEK_SET, 0)
-  data = img.read()
-
-  if has_ramdisk:
-    ramdisk_img.close()
-  img.close()
-
-  return data
-
-
-def _BuildBvbBootableImage(sourcedir, fs_config_file, system_img_path,
-                           info_dict=None, has_ramdisk=False):
-  """Build a bootable image compatible with Brillo Verified Boot from the
-  specified sourcedir.
-
-  Take a kernel, cmdline, system image path, and optionally a ramdisk
-  directory from the input (in 'sourcedir'), and turn them into a boot
-  image.  Return the image data, or None if sourcedir does not appear
-  to contains files for building the requested image.
-  """
-
-  def make_ramdisk():
-    ramdisk_img = tempfile.NamedTemporaryFile()
-
-    if os.access(fs_config_file, os.F_OK):
-      cmd = ["mkbootfs", "-f", fs_config_file,
-             os.path.join(sourcedir, "RAMDISK")]
-    else:
-      cmd = ["mkbootfs", os.path.join(sourcedir, "RAMDISK")]
-    p1 = Run(cmd, stdout=subprocess.PIPE)
-    p2 = Run(["minigzip"], stdin=p1.stdout, stdout=ramdisk_img.file.fileno())
-
-    p2.wait()
-    p1.wait()
-    assert p1.returncode == 0, "mkbootfs of %s ramdisk failed" % (sourcedir,)
-    assert p2.returncode == 0, "minigzip of %s ramdisk failed" % (sourcedir,)
-
-    return ramdisk_img
-
-  if not os.access(os.path.join(sourcedir, "kernel"), os.F_OK):
-    return None
-
-  if has_ramdisk and not os.access(os.path.join(sourcedir, "RAMDISK"), os.F_OK):
-    return None
-
-  if info_dict is None:
-    info_dict = OPTIONS.info_dict
-
-  img = tempfile.NamedTemporaryFile()
-
-  if has_ramdisk:
-    ramdisk_img = make_ramdisk()
-
-  # use BVBTOOL from environ, or "bvbtool" if empty or not set
-  bvbtool = os.getenv('BVBTOOL') or "bvbtool"
-
-  # First, create boot.img.
-  cmd = [bvbtool, "make_boot_image"]
-
-  fn = os.path.join(sourcedir, "cmdline")
-  if os.access(fn, os.F_OK):
-    cmd.append("--kernel_cmdline")
-    cmd.append(open(fn).read().rstrip("\n"))
-
-  cmd.extend(["--kernel", os.path.join(sourcedir, "kernel")])
-
-  if has_ramdisk:
-    cmd.extend(["--initrd", ramdisk_img.name])
-
-  cmd.extend(["--rootfs_with_hashes", system_img_path])
-
-  args = info_dict.get("board_bvb_make_boot_image_args", None)
-  if args and args.strip():
-    cmd.extend(shlex.split(args))
-
-  rollback_index = info_dict.get("board_bvb_rollback_index", None)
-  if rollback_index and rollback_index.strip():
-    cmd.extend(["--rollback_index", rollback_index.strip()])
-
-  cmd.extend(["--output", img.name])
-
-  p = Run(cmd, stdout=subprocess.PIPE)
-  p.communicate()
-  assert p.returncode == 0, "bvbtool make_boot_image of %s image failed" % (
-      os.path.basename(sourcedir),)
-
-  # Then, sign boot.img.
-  cmd = [bvbtool, "sign_boot_image", "--image", img.name]
-
-  algorithm = info_dict.get("board_bvb_algorithm", None)
-  key_path = info_dict.get("board_bvb_key_path", None)
-  if algorithm and algorithm.strip() and key_path and key_path.strip():
-    cmd.extend(["--algorithm", algorithm, "--key", key_path])
-  else:
-    cmd.extend(["--algorithm", "SHA256_RSA4096"])
-    cmd.extend(["--key", "external/bvb/test/testkey_rsa4096.pem"])
-
-  args = info_dict.get("board_bvb_sign_boot_image_args", None)
-  if args and args.strip():
-    cmd.extend(shlex.split(args))
-
-  p = Run(cmd, stdout=subprocess.PIPE)
-  p.communicate()
-  assert p.returncode == 0, "bvbtool sign_boot_image of %s image failed" % (
-      os.path.basename(sourcedir),)
+  # AVB: if enabled, calculate and add hash to boot.img.
+  if info_dict.get("board_avb_enable", None) == "true":
+    avbtool = os.getenv('AVBTOOL') or "avbtool"
+    part_size = info_dict.get("boot_size", None)
+    cmd = [avbtool, "add_hash_footer", "--image", img.name,
+           "--partition_size", str(part_size), "--partition_name", "boot"]
+    AppendAVBSigningArgs(cmd)
+    args = info_dict.get("board_avb_boot_add_hash_footer_args", None)
+    if args and args.strip():
+      cmd.extend(shlex.split(args))
+    p = Run(cmd, stdout=subprocess.PIPE)
+    p.communicate()
+    assert p.returncode == 0, "avbtool add_hash_footer of %s failed" % (
+        os.path.basename(OPTIONS.input_tmp))
 
   img.seek(os.SEEK_SET, 0)
   data = img.read()
@@ -650,14 +569,9 @@
                  info_dict.get("recovery_as_boot") == "true")
 
   fs_config = "META/" + tree_subdir.lower() + "_filesystem_config.txt"
-  if info_dict.get("board_bvb_enable", None) == "true":
-    data = _BuildBvbBootableImage(os.path.join(unpack_dir, tree_subdir),
-                                  os.path.join(unpack_dir, fs_config),
-                                  system_img_path, info_dict, has_ramdisk)
-  else:
-    data = _BuildBootableImage(os.path.join(unpack_dir, tree_subdir),
-                               os.path.join(unpack_dir, fs_config),
-                               info_dict, has_ramdisk)
+  data = _BuildBootableImage(os.path.join(unpack_dir, tree_subdir),
+                             os.path.join(unpack_dir, fs_config),
+                             info_dict, has_ramdisk)
   if data:
     return File(name, data)
   return None
diff --git a/tools/releasetools/rangelib.py b/tools/releasetools/rangelib.py
index 1638f8c..fa6eec1 100644
--- a/tools/releasetools/rangelib.py
+++ b/tools/releasetools/rangelib.py
@@ -313,6 +313,20 @@
         n -= e - s
     return RangeSet(data=out)
 
+  def next_item(self):
+    """Return the next integer represented by the RangeSet.
+
+    >>> list(RangeSet("0-9").next_item())
+    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+    >>> list(RangeSet("10-19 3-5").next_item())
+    [3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
+    >>> list(rangelib.RangeSet("10-19 3 5 7").next_item())
+    [3, 5, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
+    """
+    for s, e in self:
+      for element in range(s, e):
+        yield element
+
 
 if __name__ == "__main__":
   import doctest
diff --git a/tools/releasetools/sign_target_files_apks.py b/tools/releasetools/sign_target_files_apks.py
index 6d68be1..7f69a57 100755
--- a/tools/releasetools/sign_target_files_apks.py
+++ b/tools/releasetools/sign_target_files_apks.py
@@ -280,7 +280,7 @@
       pass
 
     # Skip the care_map as we will regenerate the system/vendor images.
-    elif (info.filename == "META/care_map.txt"):
+    elif info.filename == "META/care_map.txt":
       pass
 
     # Copy BOOT/, RECOVERY/, META/, ROOT/ to rebuild recovery patch. This case
@@ -553,9 +553,12 @@
   for param in in_cmdline.split():
     if "veritykeyid" in param:
       # extract keyid using openssl command
-      p = common.Run(["openssl", "x509", "-in", keypath, "-text"], stdout=subprocess.PIPE)
+      p = common.Run(
+          ["openssl", "x509", "-in", keypath, "-text"],
+          stdout=subprocess.PIPE)
       keyid, stderr = p.communicate()
-      keyid = re.search(r'keyid:([0-9a-fA-F:]*)', keyid).group(1).replace(':', '').lower()
+      keyid = re.search(
+          r'keyid:([0-9a-fA-F:]*)', keyid).group(1).replace(':', '').lower()
       print "Replacing verity keyid with %s error=%s" % (keyid, stderr)
       out_cmdline.append("veritykeyid=id:%s" % (keyid,))
     else:
@@ -592,7 +595,6 @@
   codename = None
   for line in data.split("\n"):
     line = line.strip()
-    original_line = line
     if line and line[0] != '#' and "=" in line:
       key, value = line.split("=", 1)
       key = key.strip()
@@ -615,7 +617,6 @@
   codenames = None
   for line in data.split("\n"):
     line = line.strip()
-    original_line = line
     if line and line[0] != '#' and "=" in line:
       key, value = line.split("=", 1)
       key = key.strip()
@@ -698,12 +699,8 @@
   CheckAllApksSigned(input_zip, apk_key_map)
 
   key_passwords = common.GetKeyPasswords(set(apk_key_map.values()))
-  platform_api_level, platform_codename = GetApiLevelAndCodename(input_zip)
+  platform_api_level, _ = GetApiLevelAndCodename(input_zip)
   codename_to_api_level_map = GetCodenameToApiLevelMap(input_zip)
-  # Android N will be API Level 24, but isn't yet.
-  # TODO: Remove this workaround once Android N is officially API Level 24.
-  if platform_api_level == 23 and platform_codename == "N":
-    platform_api_level = 24
 
   ProcessTargetFiles(input_zip, output_zip, misc_info,
                      apk_key_map, key_passwords,
diff --git a/tools/releasetools/test_rangelib.py b/tools/releasetools/test_rangelib.py
index 1c57cbc..e181187 100644
--- a/tools/releasetools/test_rangelib.py
+++ b/tools/releasetools/test_rangelib.py
@@ -138,3 +138,14 @@
 
     with self.assertRaises(AssertionError):
       RangeSet.parse_raw("4,0,10")
+
+  def test_next_item(self):
+    self.assertEqual(
+        list(RangeSet("0-9").next_item()),
+        [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
+    self.assertEqual(
+        list(RangeSet("10-19 3-5").next_item()),
+        [3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])
+    self.assertEqual(
+        list(RangeSet("10-19 3 5 7").next_item()),
+        [3, 5, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])
diff --git a/tools/warn.py b/tools/warn.py
index d8dbd1c..3c75825 100755
--- a/tools/warn.py
+++ b/tools/warn.py
@@ -1,17 +1,97 @@
-#!/usr/bin/env python
+#!/usr/bin/python
 # This file uses the following encoding: utf-8
 
+"""Grep warnings messages and output HTML tables or warning counts in CSV.
+
+Default is to output warnings in HTML tables grouped by warning severity.
+Use option --byproject to output tables grouped by source file projects.
+Use option --gencsv to output warning counts in CSV format.
+"""
+
+# List of important data structures and functions in this script.
+#
+# To parse and keep warning message in the input file:
+#   severity:                classification of message severity
+#   severity.range           [0, 1, ... last_severity_level]
+#   severity.colors          for header background
+#   severity.column_headers  for the warning count table
+#   severity.headers         for warning message tables
+#   warn_patterns:
+#   warn_patterns[w]['category']     tool that issued the warning, not used now
+#   warn_patterns[w]['description']  table heading
+#   warn_patterns[w]['members']      matched warnings from input
+#   warn_patterns[w]['option']       compiler flag to control the warning
+#   warn_patterns[w]['patterns']     regular expressions to match warnings
+#   warn_patterns[w]['projects'][p]  number of warnings of pattern w in p
+#   warn_patterns[w]['severity']     severity level
+#   project_list[p][0]               project name
+#   project_list[p][1]               regular expression to match a project path
+#   project_patterns[p]              re.compile(project_list[p][1])
+#   project_names[p]                 project_list[p][0]
+#   warning_messages     array of each warning message, without source url
+#   warning_records      array of [idx to warn_patterns,
+#                                  idx to project_names,
+#                                  idx to warning_messages]
+#   android_root
+#   platform_version
+#   target_product
+#   target_variant
+#   compile_patterns, parse_input_file
+#
+# To emit html page of warning messages:
+#   flags: --byproject, --url, --separator
+# Old stuff for static html components:
+#   html_script_style:  static html scripts and styles
+#   htmlbig:
+#   dump_stats, dump_html_prologue, dump_html_epilogue:
+#   emit_buttons:
+#   dump_fixed
+#   sort_warnings:
+#   emit_stats_by_project:
+#   all_patterns,
+#   findproject, classify_warning
+#   dump_html
+#
+# New dynamic HTML page's static JavaScript data:
+#   Some data are copied from Python to JavaScript, to generate HTML elements.
+#   FlagURL                args.url
+#   FlagSeparator          args.separator
+#   SeverityColors:        severity.colors
+#   SeverityHeaders:       severity.headers
+#   SeverityColumnHeaders: severity.column_headers
+#   ProjectNames:          project_names, or project_list[*][0]
+#   WarnPatternsSeverity:     warn_patterns[*]['severity']
+#   WarnPatternsDescription:  warn_patterns[*]['description']
+#   WarnPatternsOption:       warn_patterns[*]['option']
+#   WarningMessages:          warning_messages
+#   Warnings:                 warning_records
+#   StatsHeader:           warning count table header row
+#   StatsRows:             array of warning count table rows
+#
+# New dynamic HTML page's dynamic JavaScript data:
+#
+# New dynamic HTML related function to emit data:
+#   escape_string, strip_escape_string, emit_warning_arrays
+#   emit_js_data():
+#
+# To emit csv files of warning message counts:
+#   flag --gencsv
+#   description_for_csv, string_for_csv:
+#   count_severity(sev, kind):
+#   dump_csv():
+
 import argparse
+import os
 import re
 
 parser = argparse.ArgumentParser(description='Convert a build log into HTML')
 parser.add_argument('--gencsv',
                     help='Generate a CSV file with number of various warnings',
-                    action="store_true",
+                    action='store_true',
                     default=False)
 parser.add_argument('--byproject',
                     help='Separate warnings in HTML output by project names',
-                    action="store_true",
+                    action='store_true',
                     default=False)
 parser.add_argument('--url',
                     help='Root URL of an Android source code tree prefixed '
@@ -23,2020 +103,2307 @@
                     help='Path to build.log file')
 args = parser.parse_args()
 
-# if you add another level, don't forget to give it a color below
-class severity:
-    UNKNOWN = 0
-    FIXMENOW = 1
-    HIGH = 2
-    MEDIUM = 3
-    LOW = 4
-    TIDY = 5
-    HARMLESS = 6
-    SKIP = 7
-    attributes = [
-        ['lightblue', 'Unknown',   'Unknown warnings'],
-        ['fuchsia',   'FixNow',    'Critical warnings, fix me now'],
-        ['red',       'High',      'High severity warnings'],
-        ['orange',    'Medium',    'Medium severity warnings'],
-        ['yellow',    'Low',       'Low severity warnings'],
-        ['peachpuff', 'Tidy',      'Clang-Tidy warnings'],
-        ['limegreen', 'Harmless',  'Harmless warnings'],
-        ['grey',      'Unhandled', 'Unhandled warnings']
-    ]
-    color = [a[0] for a in attributes]
-    columnheader = [a[1] for a in attributes]
-    header = [a[2] for a in attributes]
-    # order to dump by severity
-    kinds = [FIXMENOW, HIGH, MEDIUM, LOW, TIDY, HARMLESS, UNKNOWN, SKIP]
 
-warnpatterns = [
-    { 'category':'make',    'severity':severity.MEDIUM,
-        'description':'make: overriding commands/ignoring old commands',
-        'patterns':[r".*: warning: overriding commands for target .+",
-                    r".*: warning: ignoring old commands for target .+"] },
-    { 'category':'make',    'severity':severity.HIGH,
-        'description':'make: LOCAL_CLANG is false',
-        'patterns':[r".*: warning: LOCAL_CLANG is set to false"] },
-    { 'category':'make',    'severity':severity.HIGH,
-        'description':'SDK App using platform shared library',
-        'patterns':[r".*: warning: .+ \(.*app:sdk.*\) should not link to .+ \(native:platform\)"] },
-    { 'category':'make',    'severity':severity.HIGH,
-        'description':'System module linking to a vendor module',
-        'patterns':[r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"] },
-    { 'category':'make',    'severity':severity.MEDIUM,
-        'description':'Invalid SDK/NDK linking',
-        'patterns':[r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"] },
-    { 'category':'C/C++',   'severity':severity.HIGH, 'option':'-Wimplicit-function-declaration',
-        'description':'Implicit function declaration',
-        'patterns':[r".*: warning: implicit declaration of function .+",
-                    r".*: warning: implicitly declaring library function" ] },
-    { 'category':'C/C++',   'severity':severity.SKIP,
-        'description':'',
-        'patterns':[r".*: warning: conflicting types for '.+'"] },
-    { 'category':'C/C++',   'severity':severity.HIGH, 'option':'-Wtype-limits',
-        'description':'Expression always evaluates to true or false',
-        'patterns':[r".*: warning: comparison is always .+ due to limited range of data type",
-                    r".*: warning: comparison of unsigned .*expression .+ is always true",
-                    r".*: warning: comparison of unsigned .*expression .+ is always false"] },
-    { 'category':'C/C++',   'severity':severity.HIGH,
-        'description':'Potential leak of memory, bad free, use after free',
-        'patterns':[r".*: warning: Potential leak of memory",
-                    r".*: warning: Potential memory leak",
-                    r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
-                    r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
-                    r".*: warning: 'delete' applied to a pointer that was allocated",
-                    r".*: warning: Use of memory after it is freed",
-                    r".*: warning: Argument to .+ is the address of .+ variable",
-                    r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
-                    r".*: warning: Attempt to .+ released memory"] },
-    { 'category':'C/C++',   'severity':severity.HIGH,
-        'description':'Use transient memory for control value',
-        'patterns':[r".*: warning: .+Using such transient memory for the control value is .*dangerous."] },
-    { 'category':'C/C++',   'severity':severity.HIGH,
-        'description':'Return address of stack memory',
-        'patterns':[r".*: warning: Address of stack memory .+ returned to caller",
-                    r".*: warning: Address of stack memory .+ will be a dangling reference"] },
-    { 'category':'C/C++',   'severity':severity.HIGH,
-        'description':'Problem with vfork',
-        'patterns':[r".*: warning: This .+ is prohibited after a successful vfork",
-                    r".*: warning: Call to function '.+' is insecure "] },
-    { 'category':'C/C++',   'severity':severity.HIGH, 'option':'infinite-recursion',
-        'description':'Infinite recursion',
-        'patterns':[r".*: warning: all paths through this function will call itself"] },
-    { 'category':'C/C++',   'severity':severity.HIGH,
-        'description':'Potential buffer overflow',
-        'patterns':[r".*: warning: Size argument is greater than .+ the destination buffer",
-                    r".*: warning: Potential buffer overflow.",
-                    r".*: warning: String copy function overflows destination buffer"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Incompatible pointer types',
-        'patterns':[r".*: warning: assignment from incompatible pointer type",
-                    r".*: warning: return from incompatible pointer type",
-                    r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
-                    r".*: warning: initialization from incompatible pointer type"] },
-    { 'category':'C/C++',   'severity':severity.HIGH, 'option':'-fno-builtin',
-        'description':'Incompatible declaration of built in function',
-        'patterns':[r".*: warning: incompatible implicit declaration of built-in function .+"] },
-    { 'category':'C/C++',   'severity':severity.HIGH, 'option':'-Wincompatible-library-redeclaration',
-        'description':'Incompatible redeclaration of library function',
-        'patterns':[r".*: warning: incompatible redeclaration of library function .+"] },
-    { 'category':'C/C++',   'severity':severity.HIGH,
-        'description':'Null passed as non-null argument',
-        'patterns':[r".*: warning: Null passed to a callee that requires a non-null"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wunused-parameter',
-        'description':'Unused parameter',
-        'patterns':[r".*: warning: unused parameter '.*'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wunused',
-        'description':'Unused function, variable or label',
-        'patterns':[r".*: warning: '.+' defined but not used",
-                    r".*: warning: unused function '.+'",
-                    r".*: warning: private field '.+' is not used",
-                    r".*: warning: unused variable '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wunused-value',
-        'description':'Statement with no effect or result unused',
-        'patterns':[r".*: warning: statement with no effect",
-                    r".*: warning: expression result unused"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wunused-result',
-        'description':'Ignoreing return value of function',
-        'patterns':[r".*: warning: ignoring return value of function .+Wunused-result"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wmissing-field-initializers',
-        'description':'Missing initializer',
-        'patterns':[r".*: warning: missing initializer"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wdelete-non-virtual-dtor',
-        'description':'Need virtual destructor',
-        'patterns':[r".*: warning: delete called .* has virtual functions but non-virtual destructor"] },
-    { 'category':'cont.',   'severity':severity.SKIP,
-        'description':'',
-        'patterns':[r".*: warning: \(near initialization for '.+'\)"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wdate-time',
-        'description':'Expansion of data or time macro',
-        'patterns':[r".*: warning: expansion of date or time macro is not reproducible"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wformat',
-        'description':'Format string does not match arguments',
-        'patterns':[r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
-                    r".*: warning: more '%' conversions than data arguments",
-                    r".*: warning: data argument not used by format string",
-                    r".*: warning: incomplete format specifier",
-                    r".*: warning: unknown conversion type .* in format",
-                    r".*: warning: format .+ expects .+ but argument .+Wformat=",
-                    r".*: warning: field precision should have .+ but argument has .+Wformat",
-                    r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wformat-extra-args',
-        'description':'Too many arguments for format string',
-        'patterns':[r".*: warning: too many arguments for format"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wformat-invalid-specifier',
-        'description':'Invalid format specifier',
-        'patterns':[r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wsign-compare',
-        'description':'Comparison between signed and unsigned',
-        'patterns':[r".*: warning: comparison between signed and unsigned",
-                    r".*: warning: comparison of promoted \~unsigned with unsigned",
-                    r".*: warning: signed and unsigned type in conditional expression"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Comparison between enum and non-enum',
-        'patterns':[r".*: warning: enumeral and non-enumeral type in conditional expression"] },
-    { 'category':'libpng',  'severity':severity.MEDIUM,
-        'description':'libpng: zero area',
-        'patterns':[r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"] },
-    { 'category':'aapt',    'severity':severity.MEDIUM,
-        'description':'aapt: no comment for public symbol',
-        'patterns':[r".*: warning: No comment for public symbol .+"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wmissing-braces',
-        'description':'Missing braces around initializer',
-        'patterns':[r".*: warning: missing braces around initializer.*"] },
-    { 'category':'C/C++',   'severity':severity.HARMLESS,
-        'description':'No newline at end of file',
-        'patterns':[r".*: warning: no newline at end of file"] },
-    { 'category':'C/C++',   'severity':severity.HARMLESS,
-        'description':'Missing space after macro name',
-        'patterns':[r".*: warning: missing whitespace after the macro name"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'-Wcast-align',
-        'description':'Cast increases required alignment',
-        'patterns':[r".*: warning: cast from .* to .* increases required alignment .*"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wcast-qual',
-        'description':'Qualifier discarded',
-        'patterns':[r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
-                    r".*: warning: assignment discards qualifiers from pointer target type",
-                    r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
-                    r".*: warning: assigning to .+ from .+ discards qualifiers",
-                    r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
-                    r".*: warning: return discards qualifiers from pointer target type"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wunknown-attributes',
-        'description':'Unknown attribute',
-        'patterns':[r".*: warning: unknown attribute '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wignored-attributes',
-        'description':'Attribute ignored',
-        'patterns':[r".*: warning: '_*packed_*' attribute ignored",
-                    r".*: warning: attribute declaration must precede definition .+ignored-attributes"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wvisibility',
-        'description':'Visibility problem',
-        'patterns':[r".*: warning: declaration of '.+' will not be visible outside of this function"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wattributes',
-        'description':'Visibility mismatch',
-        'patterns':[r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Shift count greater than width of type',
-        'patterns':[r".*: warning: (left|right) shift count >= width of type"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wextern-initializer',
-        'description':'extern &lt;foo&gt; is initialized',
-        'patterns':[r".*: warning: '.+' initialized and declared 'extern'",
-                    r".*: warning: 'extern' variable has an initializer"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wold-style-declaration',
-        'description':'Old style declaration',
-        'patterns':[r".*: warning: 'static' is not at beginning of declaration"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wreturn-type',
-        'description':'Missing return value',
-        'patterns':[r".*: warning: control reaches end of non-void function"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wimplicit-int',
-        'description':'Implicit int type',
-        'patterns':[r".*: warning: type specifier missing, defaults to 'int'",
-                    r".*: warning: type defaults to 'int' in declaration of '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wmain-return-type',
-        'description':'Main function should return int',
-        'patterns':[r".*: warning: return type of 'main' is not 'int'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wuninitialized',
-        'description':'Variable may be used uninitialized',
-        'patterns':[r".*: warning: '.+' may be used uninitialized in this function"] },
-    { 'category':'C/C++',   'severity':severity.HIGH, 'option':'-Wuninitialized',
-        'description':'Variable is used uninitialized',
-        'patterns':[r".*: warning: '.+' is used uninitialized in this function",
-                    r".*: warning: variable '.+' is uninitialized when used here"] },
-    { 'category':'ld',      'severity':severity.MEDIUM, 'option':'-fshort-enums',
-        'description':'ld: possible enum size mismatch',
-        'patterns':[r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wpointer-sign',
-        'description':'Pointer targets differ in signedness',
-        'patterns':[r".*: warning: pointer targets in initialization differ in signedness",
-                    r".*: warning: pointer targets in assignment differ in signedness",
-                    r".*: warning: pointer targets in return differ in signedness",
-                    r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wstrict-overflow',
-        'description':'Assuming overflow does not occur',
-        'patterns':[r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wempty-body',
-        'description':'Suggest adding braces around empty body',
-        'patterns':[r".*: warning: suggest braces around empty body in an 'if' statement",
-                    r".*: warning: empty body in an if-statement",
-                    r".*: warning: suggest braces around empty body in an 'else' statement",
-                    r".*: warning: empty body in an else-statement"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wparentheses',
-        'description':'Suggest adding parentheses',
-        'patterns':[r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
-                    r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
-                    r".*: warning: suggest parentheses around comparison in operand of '.+'",
-                    r".*: warning: logical not is only applied to the left hand side of this comparison",
-                    r".*: warning: using the result of an assignment as a condition without parentheses",
-                    r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
-                    r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
-                    r".*: warning: suggest parentheses around assignment used as truth value"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Static variable used in non-static inline function',
-        'patterns':[r".*: warning: '.+' is static but used in inline function '.+' which is not static"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wimplicit int',
-        'description':'No type or storage class (will default to int)',
-        'patterns':[r".*: warning: data definition has no type or storage class"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Null pointer',
-        'patterns':[r".*: warning: Dereference of null pointer",
-                    r".*: warning: Called .+ pointer is null",
-                    r".*: warning: Forming reference to null pointer",
-                    r".*: warning: Returning null reference",
-                    r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
-                    r".*: warning: .+ results in a null pointer dereference",
-                    r".*: warning: Access to .+ results in a dereference of a null pointer",
-                    r".*: warning: Null pointer argument in"] },
-    { 'category':'cont.',   'severity':severity.SKIP,
-        'description':'',
-        'patterns':[r".*: warning: parameter names \(without types\) in function declaration"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wstrict-aliasing',
-        'description':'Dereferencing &lt;foo&gt; breaks strict aliasing rules',
-        'patterns':[r".*: warning: dereferencing .* break strict-aliasing rules"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wpointer-to-int-cast',
-        'description':'Cast from pointer to integer of different size',
-        'patterns':[r".*: warning: cast from pointer to integer of different size",
-                    r".*: warning: initialization makes pointer from integer without a cast"] } ,
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wint-to-pointer-cast',
-        'description':'Cast to pointer from integer of different size',
-        'patterns':[r".*: warning: cast to pointer from integer of different size"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Symbol redefined',
-        'patterns':[r".*: warning: "".+"" redefined"] },
-    { 'category':'cont.',   'severity':severity.SKIP,
-        'description':'',
-        'patterns':[r".*: warning: this is the location of the previous definition"] },
-    { 'category':'ld',      'severity':severity.MEDIUM,
-        'description':'ld: type and size of dynamic symbol are not defined',
-        'patterns':[r".*: warning: type and size of dynamic symbol `.+' are not defined"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Pointer from integer without cast',
-        'patterns':[r".*: warning: assignment makes pointer from integer without a cast"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Pointer from integer without cast',
-        'patterns':[r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Integer from pointer without cast',
-        'patterns':[r".*: warning: assignment makes integer from pointer without a cast"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Integer from pointer without cast',
-        'patterns':[r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Integer from pointer without cast',
-        'patterns':[r".*: warning: return makes integer from pointer without a cast"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wunknown-pragmas',
-        'description':'Ignoring pragma',
-        'patterns':[r".*: warning: ignoring #pragma .+"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-W#pragma-messages',
-        'description':'Pragma warning messages',
-        'patterns':[r".*: warning: .+W#pragma-messages"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wclobbered',
-        'description':'Variable might be clobbered by longjmp or vfork',
-        'patterns':[r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wclobbered',
-        'description':'Argument might be clobbered by longjmp or vfork',
-        'patterns':[r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wredundant-decls',
-        'description':'Redundant declaration',
-        'patterns':[r".*: warning: redundant redeclaration of '.+'"] },
-    { 'category':'cont.',   'severity':severity.SKIP,
-        'description':'',
-        'patterns':[r".*: warning: previous declaration of '.+' was here"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wswitch-enum',
-        'description':'Enum value not handled in switch',
-        'patterns':[r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"] },
-    { 'category':'java',    'severity':severity.MEDIUM, 'option':'-encoding',
-        'description':'Java: Non-ascii characters used, but ascii encoding specified',
-        'patterns':[r".*: warning: unmappable character for encoding ascii"] },
-    { 'category':'java',    'severity':severity.MEDIUM,
-        'description':'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
-        'patterns':[r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"] },
-    { 'category':'java',    'severity':severity.MEDIUM,
-        'description':'Java: Unchecked method invocation',
-        'patterns':[r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"] },
-    { 'category':'java',    'severity':severity.MEDIUM,
-        'description':'Java: Unchecked conversion',
-        'patterns':[r".*: warning: \[unchecked\] unchecked conversion"] },
-    { 'category':'java',   'severity':severity.MEDIUM,
-        'description':'_ used as an identifier',
-        'patterns':[r".*: warning: '_' used as an identifier"] },
+class Severity(object):
+  """Severity levels and attributes."""
+  # numbered by dump order
+  FIXMENOW = 0
+  HIGH = 1
+  MEDIUM = 2
+  LOW = 3
+  ANALYZER = 4
+  TIDY = 5
+  HARMLESS = 6
+  UNKNOWN = 7
+  SKIP = 8
+  range = range(SKIP + 1)
+  attributes = [
+      # pylint:disable=bad-whitespace
+      ['fuchsia',   'FixNow',    'Critical warnings, fix me now'],
+      ['red',       'High',      'High severity warnings'],
+      ['orange',    'Medium',    'Medium severity warnings'],
+      ['yellow',    'Low',       'Low severity warnings'],
+      ['hotpink',   'Analyzer',  'Clang-Analyzer warnings'],
+      ['peachpuff', 'Tidy',      'Clang-Tidy warnings'],
+      ['limegreen', 'Harmless',  'Harmless warnings'],
+      ['lightblue', 'Unknown',   'Unknown warnings'],
+      ['grey',      'Unhandled', 'Unhandled warnings']
+  ]
+  colors = [a[0] for a in attributes]
+  column_headers = [a[1] for a in attributes]
+  headers = [a[2] for a in attributes]
+
+warn_patterns = [
+    # pylint:disable=line-too-long,g-inconsistent-quotes
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer Security warning',
+     'patterns': [r".*: warning: .+\[clang-analyzer-security.*\]"]},
+    {'category': 'make', 'severity': Severity.MEDIUM,
+     'description': 'make: overriding commands/ignoring old commands',
+     'patterns': [r".*: warning: overriding commands for target .+",
+                  r".*: warning: ignoring old commands for target .+"]},
+    {'category': 'make', 'severity': Severity.HIGH,
+     'description': 'make: LOCAL_CLANG is false',
+     'patterns': [r".*: warning: LOCAL_CLANG is set to false"]},
+    {'category': 'make', 'severity': Severity.HIGH,
+     'description': 'SDK App using platform shared library',
+     'patterns': [r".*: warning: .+ \(.*app:sdk.*\) should not link to .+ \(native:platform\)"]},
+    {'category': 'make', 'severity': Severity.HIGH,
+     'description': 'System module linking to a vendor module',
+     'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(partition:.+\)"]},
+    {'category': 'make', 'severity': Severity.MEDIUM,
+     'description': 'Invalid SDK/NDK linking',
+     'patterns': [r".*: warning: .+ \(.+\) should not link to .+ \(.+\)"]},
+    {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wimplicit-function-declaration',
+     'description': 'Implicit function declaration',
+     'patterns': [r".*: warning: implicit declaration of function .+",
+                  r".*: warning: implicitly declaring library function"]},
+    {'category': 'C/C++', 'severity': Severity.SKIP,
+     'description': 'skip, conflicting types for ...',
+     'patterns': [r".*: warning: conflicting types for '.+'"]},
+    {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wtype-limits',
+     'description': 'Expression always evaluates to true or false',
+     'patterns': [r".*: warning: comparison is always .+ due to limited range of data type",
+                  r".*: warning: comparison of unsigned .*expression .+ is always true",
+                  r".*: warning: comparison of unsigned .*expression .+ is always false"]},
+    {'category': 'C/C++', 'severity': Severity.HIGH,
+     'description': 'Potential leak of memory, bad free, use after free',
+     'patterns': [r".*: warning: Potential leak of memory",
+                  r".*: warning: Potential memory leak",
+                  r".*: warning: Memory allocated by alloca\(\) should not be deallocated",
+                  r".*: warning: Memory allocated by .+ should be deallocated by .+ not .+",
+                  r".*: warning: 'delete' applied to a pointer that was allocated",
+                  r".*: warning: Use of memory after it is freed",
+                  r".*: warning: Argument to .+ is the address of .+ variable",
+                  r".*: warning: Argument to free\(\) is offset by .+ of memory allocated by",
+                  r".*: warning: Attempt to .+ released memory"]},
+    {'category': 'C/C++', 'severity': Severity.HIGH,
+     'description': 'Use transient memory for control value',
+     'patterns': [r".*: warning: .+Using such transient memory for the control value is .*dangerous."]},
+    {'category': 'C/C++', 'severity': Severity.HIGH,
+     'description': 'Return address of stack memory',
+     'patterns': [r".*: warning: Address of stack memory .+ returned to caller",
+                  r".*: warning: Address of stack memory .+ will be a dangling reference"]},
+    {'category': 'C/C++', 'severity': Severity.HIGH,
+     'description': 'Problem with vfork',
+     'patterns': [r".*: warning: This .+ is prohibited after a successful vfork",
+                  r".*: warning: Call to function '.+' is insecure "]},
+    {'category': 'C/C++', 'severity': Severity.HIGH, 'option': 'infinite-recursion',
+     'description': 'Infinite recursion',
+     'patterns': [r".*: warning: all paths through this function will call itself"]},
+    {'category': 'C/C++', 'severity': Severity.HIGH,
+     'description': 'Potential buffer overflow',
+     'patterns': [r".*: warning: Size argument is greater than .+ the destination buffer",
+                  r".*: warning: Potential buffer overflow.",
+                  r".*: warning: String copy function overflows destination buffer"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Incompatible pointer types',
+     'patterns': [r".*: warning: assignment from incompatible pointer type",
+                  r".*: warning: return from incompatible pointer type",
+                  r".*: warning: passing argument [0-9]+ of '.*' from incompatible pointer type",
+                  r".*: warning: initialization from incompatible pointer type"]},
+    {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-fno-builtin',
+     'description': 'Incompatible declaration of built in function',
+     'patterns': [r".*: warning: incompatible implicit declaration of built-in function .+"]},
+    {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wincompatible-library-redeclaration',
+     'description': 'Incompatible redeclaration of library function',
+     'patterns': [r".*: warning: incompatible redeclaration of library function .+"]},
+    {'category': 'C/C++', 'severity': Severity.HIGH,
+     'description': 'Null passed as non-null argument',
+     'patterns': [r".*: warning: Null passed to a callee that requires a non-null"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-parameter',
+     'description': 'Unused parameter',
+     'patterns': [r".*: warning: unused parameter '.*'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused',
+     'description': 'Unused function, variable or label',
+     'patterns': [r".*: warning: '.+' defined but not used",
+                  r".*: warning: unused function '.+'",
+                  r".*: warning: private field '.+' is not used",
+                  r".*: warning: unused variable '.+'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-value',
+     'description': 'Statement with no effect or result unused',
+     'patterns': [r".*: warning: statement with no effect",
+                  r".*: warning: expression result unused"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunused-result',
+     'description': 'Ignoreing return value of function',
+     'patterns': [r".*: warning: ignoring return value of function .+Wunused-result"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-field-initializers',
+     'description': 'Missing initializer',
+     'patterns': [r".*: warning: missing initializer"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdelete-non-virtual-dtor',
+     'description': 'Need virtual destructor',
+     'patterns': [r".*: warning: delete called .* has virtual functions but non-virtual destructor"]},
+    {'category': 'cont.', 'severity': Severity.SKIP,
+     'description': 'skip, near initialization for ...',
+     'patterns': [r".*: warning: \(near initialization for '.+'\)"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wdate-time',
+     'description': 'Expansion of data or time macro',
+     'patterns': [r".*: warning: expansion of date or time macro is not reproducible"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat',
+     'description': 'Format string does not match arguments',
+     'patterns': [r".*: warning: format '.+' expects type '.+', but argument [0-9]+ has type '.+'",
+                  r".*: warning: more '%' conversions than data arguments",
+                  r".*: warning: data argument not used by format string",
+                  r".*: warning: incomplete format specifier",
+                  r".*: warning: unknown conversion type .* in format",
+                  r".*: warning: format .+ expects .+ but argument .+Wformat=",
+                  r".*: warning: field precision should have .+ but argument has .+Wformat",
+                  r".*: warning: format specifies type .+ but the argument has .*type .+Wformat"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-extra-args',
+     'description': 'Too many arguments for format string',
+     'patterns': [r".*: warning: too many arguments for format"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wformat-invalid-specifier',
+     'description': 'Invalid format specifier',
+     'patterns': [r".*: warning: invalid .+ specifier '.+'.+format-invalid-specifier"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-compare',
+     'description': 'Comparison between signed and unsigned',
+     'patterns': [r".*: warning: comparison between signed and unsigned",
+                  r".*: warning: comparison of promoted \~unsigned with unsigned",
+                  r".*: warning: signed and unsigned type in conditional expression"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Comparison between enum and non-enum',
+     'patterns': [r".*: warning: enumeral and non-enumeral type in conditional expression"]},
+    {'category': 'libpng', 'severity': Severity.MEDIUM,
+     'description': 'libpng: zero area',
+     'patterns': [r".*libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area"]},
+    {'category': 'aapt', 'severity': Severity.MEDIUM,
+     'description': 'aapt: no comment for public symbol',
+     'patterns': [r".*: warning: No comment for public symbol .+"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-braces',
+     'description': 'Missing braces around initializer',
+     'patterns': [r".*: warning: missing braces around initializer.*"]},
+    {'category': 'C/C++', 'severity': Severity.HARMLESS,
+     'description': 'No newline at end of file',
+     'patterns': [r".*: warning: no newline at end of file"]},
+    {'category': 'C/C++', 'severity': Severity.HARMLESS,
+     'description': 'Missing space after macro name',
+     'patterns': [r".*: warning: missing whitespace after the macro name"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcast-align',
+     'description': 'Cast increases required alignment',
+     'patterns': [r".*: warning: cast from .* to .* increases required alignment .*"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wcast-qual',
+     'description': 'Qualifier discarded',
+     'patterns': [r".*: warning: passing argument [0-9]+ of '.+' discards qualifiers from pointer target type",
+                  r".*: warning: assignment discards qualifiers from pointer target type",
+                  r".*: warning: passing .+ to parameter of type .+ discards qualifiers",
+                  r".*: warning: assigning to .+ from .+ discards qualifiers",
+                  r".*: warning: initializing .+ discards qualifiers .+types-discards-qualifiers",
+                  r".*: warning: return discards qualifiers from pointer target type"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-attributes',
+     'description': 'Unknown attribute',
+     'patterns': [r".*: warning: unknown attribute '.+'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-attributes',
+     'description': 'Attribute ignored',
+     'patterns': [r".*: warning: '_*packed_*' attribute ignored",
+                  r".*: warning: attribute declaration must precede definition .+ignored-attributes"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvisibility',
+     'description': 'Visibility problem',
+     'patterns': [r".*: warning: declaration of '.+' will not be visible outside of this function"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wattributes',
+     'description': 'Visibility mismatch',
+     'patterns': [r".*: warning: '.+' declared with greater visibility than the type of its field '.+'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Shift count greater than width of type',
+     'patterns': [r".*: warning: (left|right) shift count >= width of type"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextern-initializer',
+     'description': 'extern &lt;foo&gt; is initialized',
+     'patterns': [r".*: warning: '.+' initialized and declared 'extern'",
+                  r".*: warning: 'extern' variable has an initializer"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wold-style-declaration',
+     'description': 'Old style declaration',
+     'patterns': [r".*: warning: 'static' is not at beginning of declaration"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreturn-type',
+     'description': 'Missing return value',
+     'patterns': [r".*: warning: control reaches end of non-void function"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit-int',
+     'description': 'Implicit int type',
+     'patterns': [r".*: warning: type specifier missing, defaults to 'int'",
+                  r".*: warning: type defaults to 'int' in declaration of '.+'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain-return-type',
+     'description': 'Main function should return int',
+     'patterns': [r".*: warning: return type of 'main' is not 'int'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wuninitialized',
+     'description': 'Variable may be used uninitialized',
+     'patterns': [r".*: warning: '.+' may be used uninitialized in this function"]},
+    {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wuninitialized',
+     'description': 'Variable is used uninitialized',
+     'patterns': [r".*: warning: '.+' is used uninitialized in this function",
+                  r".*: warning: variable '.+' is uninitialized when used here"]},
+    {'category': 'ld', 'severity': Severity.MEDIUM, 'option': '-fshort-enums',
+     'description': 'ld: possible enum size mismatch',
+     'patterns': [r".*: warning: .* uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-sign',
+     'description': 'Pointer targets differ in signedness',
+     'patterns': [r".*: warning: pointer targets in initialization differ in signedness",
+                  r".*: warning: pointer targets in assignment differ in signedness",
+                  r".*: warning: pointer targets in return differ in signedness",
+                  r".*: warning: pointer targets in passing argument [0-9]+ of '.+' differ in signedness"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-overflow',
+     'description': 'Assuming overflow does not occur',
+     'patterns': [r".*: warning: assuming signed overflow does not occur when assuming that .* is always (true|false)"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wempty-body',
+     'description': 'Suggest adding braces around empty body',
+     'patterns': [r".*: warning: suggest braces around empty body in an 'if' statement",
+                  r".*: warning: empty body in an if-statement",
+                  r".*: warning: suggest braces around empty body in an 'else' statement",
+                  r".*: warning: empty body in an else-statement"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wparentheses',
+     'description': 'Suggest adding parentheses',
+     'patterns': [r".*: warning: suggest explicit braces to avoid ambiguous 'else'",
+                  r".*: warning: suggest parentheses around arithmetic in operand of '.+'",
+                  r".*: warning: suggest parentheses around comparison in operand of '.+'",
+                  r".*: warning: logical not is only applied to the left hand side of this comparison",
+                  r".*: warning: using the result of an assignment as a condition without parentheses",
+                  r".*: warning: .+ has lower precedence than .+ be evaluated first .+Wparentheses",
+                  r".*: warning: suggest parentheses around '.+?' .+ '.+?'",
+                  r".*: warning: suggest parentheses around assignment used as truth value"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Static variable used in non-static inline function',
+     'patterns': [r".*: warning: '.+' is static but used in inline function '.+' which is not static"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wimplicit int',
+     'description': 'No type or storage class (will default to int)',
+     'patterns': [r".*: warning: data definition has no type or storage class"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Null pointer',
+     'patterns': [r".*: warning: Dereference of null pointer",
+                  r".*: warning: Called .+ pointer is null",
+                  r".*: warning: Forming reference to null pointer",
+                  r".*: warning: Returning null reference",
+                  r".*: warning: Null pointer passed as an argument to a 'nonnull' parameter",
+                  r".*: warning: .+ results in a null pointer dereference",
+                  r".*: warning: Access to .+ results in a dereference of a null pointer",
+                  r".*: warning: Null pointer argument in"]},
+    {'category': 'cont.', 'severity': Severity.SKIP,
+     'description': 'skip, parameter name (without types) in function declaration',
+     'patterns': [r".*: warning: parameter names \(without types\) in function declaration"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-aliasing',
+     'description': 'Dereferencing &lt;foo&gt; breaks strict aliasing rules',
+     'patterns': [r".*: warning: dereferencing .* break strict-aliasing rules"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-to-int-cast',
+     'description': 'Cast from pointer to integer of different size',
+     'patterns': [r".*: warning: cast from pointer to integer of different size",
+                  r".*: warning: initialization makes pointer from integer without a cast"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wint-to-pointer-cast',
+     'description': 'Cast to pointer from integer of different size',
+     'patterns': [r".*: warning: cast to pointer from integer of different size"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Symbol redefined',
+     'patterns': [r".*: warning: "".+"" redefined"]},
+    {'category': 'cont.', 'severity': Severity.SKIP,
+     'description': 'skip, ... location of the previous definition',
+     'patterns': [r".*: warning: this is the location of the previous definition"]},
+    {'category': 'ld', 'severity': Severity.MEDIUM,
+     'description': 'ld: type and size of dynamic symbol are not defined',
+     'patterns': [r".*: warning: type and size of dynamic symbol `.+' are not defined"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Pointer from integer without cast',
+     'patterns': [r".*: warning: assignment makes pointer from integer without a cast"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Pointer from integer without cast',
+     'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes pointer from integer without a cast"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Integer from pointer without cast',
+     'patterns': [r".*: warning: assignment makes integer from pointer without a cast"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Integer from pointer without cast',
+     'patterns': [r".*: warning: passing argument [0-9]+ of '.+' makes integer from pointer without a cast"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Integer from pointer without cast',
+     'patterns': [r".*: warning: return makes integer from pointer without a cast"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunknown-pragmas',
+     'description': 'Ignoring pragma',
+     'patterns': [r".*: warning: ignoring #pragma .+"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-W#pragma-messages',
+     'description': 'Pragma warning messages',
+     'patterns': [r".*: warning: .+W#pragma-messages"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
+     'description': 'Variable might be clobbered by longjmp or vfork',
+     'patterns': [r".*: warning: variable '.+' might be clobbered by 'longjmp' or 'vfork'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wclobbered',
+     'description': 'Argument might be clobbered by longjmp or vfork',
+     'patterns': [r".*: warning: argument '.+' might be clobbered by 'longjmp' or 'vfork'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wredundant-decls',
+     'description': 'Redundant declaration',
+     'patterns': [r".*: warning: redundant redeclaration of '.+'"]},
+    {'category': 'cont.', 'severity': Severity.SKIP,
+     'description': 'skip, previous declaration ... was here',
+     'patterns': [r".*: warning: previous declaration of '.+' was here"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wswitch-enum',
+     'description': 'Enum value not handled in switch',
+     'patterns': [r".*: warning: .*enumeration value.* not handled in switch.+Wswitch"]},
+    {'category': 'java', 'severity': Severity.MEDIUM, 'option': '-encoding',
+     'description': 'Java: Non-ascii characters used, but ascii encoding specified',
+     'patterns': [r".*: warning: unmappable character for encoding ascii"]},
+    {'category': 'java', 'severity': Severity.MEDIUM,
+     'description': 'Java: Non-varargs call of varargs method with inexact argument type for last parameter',
+     'patterns': [r".*: warning: non-varargs call of varargs method with inexact argument type for last parameter"]},
+    {'category': 'java', 'severity': Severity.MEDIUM,
+     'description': 'Java: Unchecked method invocation',
+     'patterns': [r".*: warning: \[unchecked\] unchecked method invocation: .+ in class .+"]},
+    {'category': 'java', 'severity': Severity.MEDIUM,
+     'description': 'Java: Unchecked conversion',
+     'patterns': [r".*: warning: \[unchecked\] unchecked conversion"]},
+    {'category': 'java', 'severity': Severity.MEDIUM,
+     'description': '_ used as an identifier',
+     'patterns': [r".*: warning: '_' used as an identifier"]},
 
     # Warnings from Error Prone.
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description': 'Java: Use of deprecated member',
      'patterns': [r'.*: warning: \[deprecation\] .+']},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description': 'Java: Unchecked conversion',
      'patterns': [r'.*: warning: \[unchecked\] .+']},
 
     # Warnings from Error Prone (auto generated list).
     {'category': 'java',
-     'severity': severity.LOW,
+     'severity': Severity.LOW,
      'description':
          'Java: Deprecated item is not annotated with @Deprecated',
      'patterns': [r".*: warning: \[DepAnn\] .+"]},
     {'category': 'java',
-     'severity': severity.LOW,
+     'severity': Severity.LOW,
      'description':
          'Java: Fallthrough warning suppression has no effect if warning is suppressed',
      'patterns': [r".*: warning: \[FallthroughSuppression\] .+"]},
     {'category': 'java',
-     'severity': severity.LOW,
+     'severity': Severity.LOW,
      'description':
          'Java: Prefer \'L\' to \'l\' for the suffix to long literals',
      'patterns': [r".*: warning: \[LongLiteralLowerCaseSuffix\] .+"]},
     {'category': 'java',
-     'severity': severity.LOW,
+     'severity': Severity.LOW,
      'description':
          'Java: @Binds is a more efficient and declaritive mechanism for delegating a binding.',
      'patterns': [r".*: warning: \[UseBinds\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Assertions may be disabled at runtime and do not guarantee that execution will halt here; consider throwing an exception instead',
      'patterns': [r".*: warning: \[AssertFalse\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Classes that implement Annotation must override equals and hashCode. Consider using AutoAnnotation instead of implementing Annotation by hand.',
      'patterns': [r".*: warning: \[BadAnnotationImplementation\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: BigDecimal(double) and BigDecimal.valueOf(double) may lose precision, prefer BigDecimal(String) or BigDecimal(long)',
      'patterns': [r".*: warning: \[BigDecimalLiteralDouble\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Mockito cannot mock final classes',
      'patterns': [r".*: warning: \[CannotMockFinalClass\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: This code, which counts elements using a loop, can be replaced by a simpler library method',
      'patterns': [r".*: warning: \[ElementsCountedInLoop\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Empty top-level type declaration',
      'patterns': [r".*: warning: \[EmptyTopLevelDeclaration\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Classes that override equals should also override hashCode.',
      'patterns': [r".*: warning: \[EqualsHashCode\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: An equality test between objects with incompatible types always returns false',
      'patterns': [r".*: warning: \[EqualsIncompatibleType\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: If you return or throw from a finally, then values returned or thrown from the try-catch block will be ignored. Consider using try-with-resources instead.',
      'patterns': [r".*: warning: \[Finally\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: This annotation has incompatible modifiers as specified by its @IncompatibleModifiers annotation',
      'patterns': [r".*: warning: \[IncompatibleModifiers\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Class should not implement both `Iterable` and `Iterator`',
      'patterns': [r".*: warning: \[IterableAndIterator\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Floating-point comparison without error tolerance',
      'patterns': [r".*: warning: \[JUnit3FloatingPointComparisonWithoutDelta\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Test class inherits from JUnit 3\'s TestCase but has JUnit 4 @Test annotations.',
      'patterns': [r".*: warning: \[JUnitAmbiguousTestClass\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Enum switch statement is missing cases',
      'patterns': [r".*: warning: \[MissingCasesInEnumSwitch\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Not calling fail() when expecting an exception masks bugs',
      'patterns': [r".*: warning: \[MissingFail\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: method overrides method in supertype; expected @Override',
      'patterns': [r".*: warning: \[MissingOverride\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Source files should not contain multiple top-level class declarations',
      'patterns': [r".*: warning: \[MultipleTopLevelClasses\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: This update of a volatile variable is non-atomic',
      'patterns': [r".*: warning: \[NonAtomicVolatileUpdate\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Static import of member uses non-canonical name',
      'patterns': [r".*: warning: \[NonCanonicalStaticMemberImport\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: equals method doesn\'t override Object.equals',
      'patterns': [r".*: warning: \[NonOverridingEquals\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Constructors should not be annotated with @Nullable since they cannot return null',
      'patterns': [r".*: warning: \[NullableConstructor\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: @Nullable should not be used for primitive types since they cannot be null',
      'patterns': [r".*: warning: \[NullablePrimitive\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: void-returning methods should not be annotated with @Nullable, since they cannot return null',
      'patterns': [r".*: warning: \[NullableVoid\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Package names should match the directory they are declared in',
      'patterns': [r".*: warning: \[PackageLocation\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Second argument to Preconditions.* is a call to String.format(), which can be unwrapped',
      'patterns': [r".*: warning: \[PreconditionsErrorMessageEagerEvaluation\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Preconditions only accepts the %s placeholder in error message strings',
      'patterns': [r".*: warning: \[PreconditionsInvalidPlaceholder\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Passing a primitive array to a varargs method is usually wrong',
      'patterns': [r".*: warning: \[PrimitiveArrayPassedToVarargsMethod\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Protobuf fields cannot be null, so this check is redundant',
      'patterns': [r".*: warning: \[ProtoFieldPreconditionsCheckNotNull\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: This annotation is missing required modifiers as specified by its @RequiredModifiers annotation',
      'patterns': [r".*: warning: \[RequiredModifiers\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: A static variable or method should not be accessed from an object instance',
      'patterns': [r".*: warning: \[StaticAccessedFromInstance\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: String comparison using reference equality instead of value equality',
      'patterns': [r".*: warning: \[StringEquality\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Declaring a type parameter that is only used in the return type is a misuse of generics: operations on the type parameter are unchecked, it hides unsafe casts at invocations of the method, and it interacts badly with method overload resolution.',
      'patterns': [r".*: warning: \[TypeParameterUnusedInFormals\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Using static imports for types is unnecessary',
      'patterns': [r".*: warning: \[UnnecessaryStaticImport\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Unsynchronized method overrides a synchronized method.',
      'patterns': [r".*: warning: \[UnsynchronizedOverridesSynchronized\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Non-constant variable missing @Var annotation',
      'patterns': [r".*: warning: \[Var\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Because of spurious wakeups, Object.wait() and Condition.await() must always be called in a loop',
      'patterns': [r".*: warning: \[WaitNotInLoop\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Subclasses of Fragment must be instantiable via Class#newInstance(): the class must be public, static and have a public nullary constructor',
      'patterns': [r".*: warning: \[FragmentNotInstantiable\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Hardcoded reference to /sdcard',
      'patterns': [r".*: warning: \[HardCodedSdCardPath\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Incompatible type as argument to Object-accepting Java collections method',
      'patterns': [r".*: warning: \[CollectionIncompatibleType\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: @AssistedInject and @Inject should not be used on different constructors in the same class.',
      'patterns': [r".*: warning: \[AssistedInjectAndInjectOnConstructors\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Although Guice allows injecting final fields, doing so is not recommended because the injected value may not be visible to other threads.',
      'patterns': [r".*: warning: \[GuiceInjectOnFinalField\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: This method is not annotated with @Inject, but it overrides a method that is annotated with @com.google.inject.Inject. Guice will inject this method, and it is recommended to annotate it explicitly.',
      'patterns': [r".*: warning: \[OverridesGuiceInjectableMethod\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Double-checked locking on non-volatile fields is unsafe',
      'patterns': [r".*: warning: \[DoubleCheckedLocking\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Writes to static fields should not be guarded by instance locks',
      'patterns': [r".*: warning: \[StaticGuardedByInstance\] .+"]},
     {'category': 'java',
-     'severity': severity.MEDIUM,
+     'severity': Severity.MEDIUM,
      'description':
          'Java: Synchronizing on non-final fields is not safe: if the field is ever updated, different threads may end up locking on different objects.',
      'patterns': [r".*: warning: \[SynchronizeOnNonFinalField\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Reference equality used to compare arrays',
      'patterns': [r".*: warning: \[ArrayEquals\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: hashcode method on array does not hash array contents',
      'patterns': [r".*: warning: \[ArrayHashCode\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Calling toString on an array does not provide useful information',
      'patterns': [r".*: warning: \[ArrayToString.*\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Arrays.asList does not autobox primitive arrays, as one might expect.',
      'patterns': [r".*: warning: \[ArraysAsListPrimitiveArray\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: AsyncCallable should not return a null Future, only a Future whose result is null.',
      'patterns': [r".*: warning: \[AsyncCallableReturnsNull\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: AsyncFunction should not return a null Future, only a Future whose result is null.',
      'patterns': [r".*: warning: \[AsyncFunctionReturnsNull\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Possible sign flip from narrowing conversion',
      'patterns': [r".*: warning: \[BadComparable\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Shift by an amount that is out of range',
      'patterns': [r".*: warning: \[BadShiftAmount\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: valueOf provides better time and space performance',
      'patterns': [r".*: warning: \[BoxedPrimitiveConstructor\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: The called constructor accepts a parameter with the same name and type as one of its caller\'s parameters, but its caller doesn\'t pass that parameter to it.  It\'s likely that it was intended to.',
      'patterns': [r".*: warning: \[ChainingConstructorIgnoresParameter\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Ignored return value of method that is annotated with @CheckReturnValue',
      'patterns': [r".*: warning: \[CheckReturnValue\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Inner class is non-static but does not reference enclosing class',
      'patterns': [r".*: warning: \[ClassCanBeStatic\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: The source file name should match the name of the top-level class it contains',
      'patterns': [r".*: warning: \[ClassName\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: This comparison method violates the contract',
      'patterns': [r".*: warning: \[ComparisonContractViolated\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Comparison to value that is out of range for the compared type',
      'patterns': [r".*: warning: \[ComparisonOutOfRange\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Non-compile-time constant expression passed to parameter with @CompileTimeConstant type annotation.',
      'patterns': [r".*: warning: \[CompileTimeConstant\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Exception created but not thrown',
      'patterns': [r".*: warning: \[DeadException\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Division by integer literal zero',
      'patterns': [r".*: warning: \[DivZero\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Empty statement after if',
      'patterns': [r".*: warning: \[EmptyIf\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: == NaN always returns false; use the isNaN methods instead',
      'patterns': [r".*: warning: \[EqualsNaN\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Method annotated @ForOverride must be protected or package-private and only invoked from declaring class',
      'patterns': [r".*: warning: \[ForOverride\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Futures.getChecked requires a checked exception type with a standard constructor.',
      'patterns': [r".*: warning: \[FuturesGetCheckedIllegalExceptionType\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Calling getClass() on an object of type Class returns the Class object for java.lang.Class; you probably meant to operate on the object directly',
      'patterns': [r".*: warning: \[GetClassOnClass\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: An object is tested for equality to itself using Guava Libraries',
      'patterns': [r".*: warning: \[GuavaSelfEquals\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: contains() is a legacy method that is equivalent to containsValue()',
      'patterns': [r".*: warning: \[HashtableContains\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Cipher.getInstance() is invoked using either the default settings or ECB mode',
      'patterns': [r".*: warning: \[InsecureCipherMode\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Invalid syntax used for a regular expression',
      'patterns': [r".*: warning: \[InvalidPatternSyntax\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: The argument to Class#isInstance(Object) should not be a Class',
      'patterns': [r".*: warning: \[IsInstanceOfClass\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: jMock tests must have a @RunWith(JMock.class) annotation, or the Mockery field must have a @Rule JUnit annotation',
      'patterns': [r".*: warning: \[JMockTestWithoutRunWithOrRuleAnnotation\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Test method will not be run; please prefix name with "test"',
      'patterns': [r".*: warning: \[JUnit3TestNotRun\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: setUp() method will not be run; Please add a @Before annotation',
      'patterns': [r".*: warning: \[JUnit4SetUpNotRun\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: tearDown() method will not be run; Please add an @After annotation',
      'patterns': [r".*: warning: \[JUnit4TearDownNotRun\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Test method will not be run; please add @Test annotation',
      'patterns': [r".*: warning: \[JUnit4TestNotRun\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Printf-like format string does not match its arguments',
      'patterns': [r".*: warning: \[MalformedFormatString\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Use of "YYYY" (week year) in a date pattern without "ww" (week in year). You probably meant to use "yyyy" (year) instead.',
      'patterns': [r".*: warning: \[MisusedWeekYear\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: A bug in Mockito will cause this test to fail at runtime with a ClassCastException',
      'patterns': [r".*: warning: \[MockitoCast\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Missing method call for verify(mock) here',
      'patterns': [r".*: warning: \[MockitoUsage\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Modifying a collection with itself',
      'patterns': [r".*: warning: \[ModifyingCollectionWithItself\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Compound assignments to bytes, shorts, chars, and floats hide dangerous casts',
      'patterns': [r".*: warning: \[NarrowingCompoundAssignment\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: @NoAllocation was specified on this method, but something was found that would trigger an allocation',
      'patterns': [r".*: warning: \[NoAllocation\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Static import of type uses non-canonical name',
      'patterns': [r".*: warning: \[NonCanonicalStaticImport\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: @CompileTimeConstant parameters should be final',
      'patterns': [r".*: warning: \[NonFinalCompileTimeConstant\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Calling getAnnotation on an annotation that is not retained at runtime.',
      'patterns': [r".*: warning: \[NonRuntimeAnnotation\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Numeric comparison using reference equality instead of value equality',
      'patterns': [r".*: warning: \[NumericEquality\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Comparison using reference equality instead of value equality',
      'patterns': [r".*: warning: \[OptionalEquality\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Varargs doesn\'t agree for overridden method',
      'patterns': [r".*: warning: \[Overrides\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Literal passed as first argument to Preconditions.checkNotNull() can never be null',
      'patterns': [r".*: warning: \[PreconditionsCheckNotNull\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: First argument to `Preconditions.checkNotNull()` is a primitive rather than an object reference',
      'patterns': [r".*: warning: \[PreconditionsCheckNotNullPrimitive\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Protobuf fields cannot be null',
      'patterns': [r".*: warning: \[ProtoFieldNullComparison\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Comparing protobuf fields of type String using reference equality',
      'patterns': [r".*: warning: \[ProtoStringFieldReferenceEquality\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java:  Check for non-whitelisted callers to RestrictedApiChecker.',
      'patterns': [r".*: warning: \[RestrictedApiChecker\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Return value of this method must be used',
      'patterns': [r".*: warning: \[ReturnValueIgnored\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Variable assigned to itself',
      'patterns': [r".*: warning: \[SelfAssignment\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: An object is compared to itself',
      'patterns': [r".*: warning: \[SelfComparision\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Variable compared to itself',
      'patterns': [r".*: warning: \[SelfEquality\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: An object is tested for equality to itself',
      'patterns': [r".*: warning: \[SelfEquals\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Comparison of a size >= 0 is always true, did you intend to check for non-emptiness?',
      'patterns': [r".*: warning: \[SizeGreaterThanOrEqualsZero\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Calling toString on a Stream does not provide useful information',
      'patterns': [r".*: warning: \[StreamToString\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: StringBuilder does not have a char constructor; this invokes the int constructor.',
      'patterns': [r".*: warning: \[StringBuilderInitWithChar\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Suppressing "deprecated" is probably a typo for "deprecation"',
      'patterns': [r".*: warning: \[SuppressWarningsDeprecated\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: throwIfUnchecked(knownCheckedException) is a no-op.',
      'patterns': [r".*: warning: \[ThrowIfUncheckedKnownChecked\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Catching Throwable/Error masks failures from fail() or assert*() in the try block',
      'patterns': [r".*: warning: \[TryFailThrowable\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Type parameter used as type qualifier',
      'patterns': [r".*: warning: \[TypeParameterQualifier\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Non-generic methods should not be invoked with type arguments',
      'patterns': [r".*: warning: \[UnnecessaryTypeArgument\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Instance created but never used',
      'patterns': [r".*: warning: \[UnusedAnonymousClass\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Use of wildcard imports is forbidden',
      'patterns': [r".*: warning: \[WildcardImport\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Method parameter has wrong package',
      'patterns': [r".*: warning: \[ParameterPackage\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Certain resources in `android.R.string` have names that do not match their content',
      'patterns': [r".*: warning: \[MislabeledAndroidString\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Return value of android.graphics.Rect.intersect() must be checked',
      'patterns': [r".*: warning: \[RectIntersectReturnValueIgnored\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Invalid printf-style format string',
      'patterns': [r".*: warning: \[FormatString\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: @AssistedInject and @Inject cannot be used on the same constructor.',
      'patterns': [r".*: warning: \[AssistedInjectAndInjectOnSameConstructor\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Injected constructors cannot be optional nor have binding annotations',
      'patterns': [r".*: warning: \[InjectedConstructorAnnotations\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: The target of a scoping annotation must be set to METHOD and/or TYPE.',
      'patterns': [r".*: warning: \[InjectInvalidTargetingOnScopingAnnotation\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Abstract methods are not injectable with javax.inject.Inject.',
      'patterns': [r".*: warning: \[JavaxInjectOnAbstractMethod\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: @javax.inject.Inject cannot be put on a final field.',
      'patterns': [r".*: warning: \[JavaxInjectOnFinalField\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: A class may not have more than one injectable constructor.',
      'patterns': [r".*: warning: \[MoreThanOneInjectableConstructor\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Using more than one qualifier annotation on the same element is not allowed.',
      'patterns': [r".*: warning: \[InjectMoreThanOneQualifier\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: A class can be annotated with at most one scope annotation',
      'patterns': [r".*: warning: \[InjectMoreThanOneScopeAnnotationOnClass\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Annotations cannot be both Qualifiers/BindingAnnotations and Scopes',
      'patterns': [r".*: warning: \[OverlappingQualifierAndScopeAnnotation\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Scope annotation on an interface or abstact class is not allowed',
      'patterns': [r".*: warning: \[InjectScopeAnnotationOnInterfaceOrAbstractClass\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Scoping and qualifier annotations must have runtime retention.',
      'patterns': [r".*: warning: \[InjectScopeOrQualifierAnnotationRetention\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Dagger @Provides methods may not return null unless annotated with @Nullable',
      'patterns': [r".*: warning: \[DaggerProvidesNull\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Scope annotation on implementation class of AssistedInject factory is not allowed',
      'patterns': [r".*: warning: \[GuiceAssistedInjectScoping\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: A constructor cannot have two @Assisted parameters of the same type unless they are disambiguated with named @Assisted annotations. ',
      'patterns': [r".*: warning: \[GuiceAssistedParameters\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: This method is not annotated with @Inject, but it overrides a  method that is  annotated with @javax.inject.Inject.',
      'patterns': [r".*: warning: \[OverridesJavaxInjectableMethod\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Checks for unguarded accesses to fields and methods with @GuardedBy annotations',
      'patterns': [r".*: warning: \[GuardedByChecker\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Invalid @GuardedBy expression',
      'patterns': [r".*: warning: \[GuardedByValidator\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: Type declaration annotated with @Immutable is not immutable',
      'patterns': [r".*: warning: \[Immutable\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: This method does not acquire the locks specified by its @LockMethod annotation',
      'patterns': [r".*: warning: \[LockMethodChecker\] .+"]},
     {'category': 'java',
-     'severity': severity.HIGH,
+     'severity': Severity.HIGH,
      'description':
          'Java: This method does not acquire the locks specified by its @UnlockMethod annotation',
      'patterns': [r".*: warning: \[UnlockMethod\] .+"]},
 
     {'category': 'java',
-     'severity': severity.UNKNOWN,
+     'severity': Severity.UNKNOWN,
      'description': 'Java: Unclassified/unrecognized warnings',
      'patterns': [r".*: warning: \[.+\] .+"]},
 
-    { 'category':'aapt',    'severity':severity.MEDIUM,
-        'description':'aapt: No default translation',
-        'patterns':[r".*: warning: string '.+' has no default translation in .*"] },
-    { 'category':'aapt',    'severity':severity.MEDIUM,
-        'description':'aapt: Missing default or required localization',
-        'patterns':[r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"] },
-    { 'category':'aapt',    'severity':severity.MEDIUM,
-        'description':'aapt: String marked untranslatable, but translation exists',
-        'patterns':[r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"] },
-    { 'category':'aapt',    'severity':severity.MEDIUM,
-        'description':'aapt: empty span in string',
-        'patterns':[r".*: warning: empty '.+' span found in text '.+"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Taking address of temporary',
-        'patterns':[r".*: warning: taking address of temporary"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Possible broken line continuation',
-        'patterns':[r".*: warning: backslash and newline separated by space"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wundefined-var-template',
-        'description':'Undefined variable template',
-        'patterns':[r".*: warning: instantiation of variable .* no definition is available"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wundefined-inline',
-        'description':'Inline function is not defined',
-        'patterns':[r".*: warning: inline function '.*' is not defined"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Warray-bounds',
-        'description':'Array subscript out of bounds',
-        'patterns':[r".*: warning: array subscript is above array bounds",
-                    r".*: warning: Array subscript is undefined",
-                    r".*: warning: array subscript is below array bounds"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Excess elements in initializer',
-        'patterns':[r".*: warning: excess elements in .+ initializer"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Decimal constant is unsigned only in ISO C90',
-        'patterns':[r".*: warning: this decimal constant is unsigned only in ISO C90"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wmain',
-        'description':'main is usually a function',
-        'patterns':[r".*: warning: 'main' is usually a function"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Typedef ignored',
-        'patterns':[r".*: warning: 'typedef' was ignored in this declaration"] },
-    { 'category':'C/C++',   'severity':severity.HIGH, 'option':'-Waddress',
-        'description':'Address always evaluates to true',
-        'patterns':[r".*: warning: the address of '.+' will always evaluate as 'true'"] },
-    { 'category':'C/C++',   'severity':severity.FIXMENOW,
-        'description':'Freeing a non-heap object',
-        'patterns':[r".*: warning: attempt to free a non-heap object '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wchar-subscripts',
-        'description':'Array subscript has type char',
-        'patterns':[r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Constant too large for type',
-        'patterns':[r".*: warning: integer constant is too large for '.+' type"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Woverflow',
-        'description':'Constant too large for type, truncated',
-        'patterns':[r".*: warning: large integer implicitly truncated to unsigned type"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Winteger-overflow',
-        'description':'Overflow in expression',
-        'patterns':[r".*: warning: overflow in expression; .*Winteger-overflow"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Woverflow',
-        'description':'Overflow in implicit constant conversion',
-        'patterns':[r".*: warning: overflow in implicit constant conversion"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Declaration does not declare anything',
-        'patterns':[r".*: warning: declaration 'class .+' does not declare anything"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wreorder',
-        'description':'Initialization order will be different',
-        'patterns':[r".*: warning: '.+' will be initialized after",
-                    r".*: warning: field .+ will be initialized after .+Wreorder"] },
-    { 'category':'cont.',   'severity':severity.SKIP,
-        'description':'',
-        'patterns':[r".*: warning:   '.+'"] },
-    { 'category':'cont.',   'severity':severity.SKIP,
-        'description':'',
-        'patterns':[r".*: warning:   base '.+'"] },
-    { 'category':'cont.',   'severity':severity.SKIP,
-        'description':'',
-        'patterns':[r".*: warning:   when initialized here"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wmissing-parameter-type',
-        'description':'Parameter type not specified',
-        'patterns':[r".*: warning: type of '.+' defaults to 'int'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wmissing-declarations',
-        'description':'Missing declarations',
-        'patterns':[r".*: warning: declaration does not declare anything"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wmissing-noreturn',
-        'description':'Missing noreturn',
-        'patterns':[r".*: warning: function '.*' could be declared with attribute 'noreturn'"] },
-    { 'category':'gcc',     'severity':severity.MEDIUM,
-        'description':'Invalid option for C file',
-        'patterns':[r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'User warning',
-        'patterns':[r".*: warning: #warning "".+"""] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wvexing-parse',
-        'description':'Vexing parsing problem',
-        'patterns':[r".*: warning: empty parentheses interpreted as a function declaration"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wextra',
-        'description':'Dereferencing void*',
-        'patterns':[r".*: warning: dereferencing 'void \*' pointer"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Comparison of pointer and integer',
-        'patterns':[r".*: warning: ordered comparison of pointer with integer zero",
-                    r".*: warning: .*comparison between pointer and integer"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Use of error-prone unary operator',
-        'patterns':[r".*: warning: use of unary operator that may be intended as compound assignment"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wwrite-strings',
-        'description':'Conversion of string constant to non-const char*',
-        'patterns':[r".*: warning: deprecated conversion from string constant to '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wstrict-prototypes',
-        'description':'Function declaration isn''t a prototype',
-        'patterns':[r".*: warning: function declaration isn't a prototype"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wignored-qualifiers',
-        'description':'Type qualifiers ignored on function return value',
-        'patterns':[r".*: warning: type qualifiers ignored on function return type",
-                    r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'&lt;foo&gt; declared inside parameter list, scope limited to this definition',
-        'patterns':[r".*: warning: '.+' declared inside parameter list"] },
-    { 'category':'cont.',   'severity':severity.SKIP,
-        'description':'',
-        'patterns':[r".*: warning: its scope is only this definition or declaration, which is probably not what you want"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'-Wcomment',
-        'description':'Line continuation inside comment',
-        'patterns':[r".*: warning: multi-line comment"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'-Wcomment',
-        'description':'Comment inside comment',
-        'patterns':[r".*: warning: "".+"" within comment"] },
+    {'category': 'aapt', 'severity': Severity.MEDIUM,
+     'description': 'aapt: No default translation',
+     'patterns': [r".*: warning: string '.+' has no default translation in .*"]},
+    {'category': 'aapt', 'severity': Severity.MEDIUM,
+     'description': 'aapt: Missing default or required localization',
+     'patterns': [r".*: warning: \*\*\*\* string '.+' has no default or required localization for '.+' in .+"]},
+    {'category': 'aapt', 'severity': Severity.MEDIUM,
+     'description': 'aapt: String marked untranslatable, but translation exists',
+     'patterns': [r".*: warning: string '.+' in .* marked untranslatable but exists in locale '??_??'"]},
+    {'category': 'aapt', 'severity': Severity.MEDIUM,
+     'description': 'aapt: empty span in string',
+     'patterns': [r".*: warning: empty '.+' span found in text '.+"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Taking address of temporary',
+     'patterns': [r".*: warning: taking address of temporary"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Possible broken line continuation',
+     'patterns': [r".*: warning: backslash and newline separated by space"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-var-template',
+     'description': 'Undefined variable template',
+     'patterns': [r".*: warning: instantiation of variable .* no definition is available"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wundefined-inline',
+     'description': 'Inline function is not defined',
+     'patterns': [r".*: warning: inline function '.*' is not defined"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Warray-bounds',
+     'description': 'Array subscript out of bounds',
+     'patterns': [r".*: warning: array subscript is above array bounds",
+                  r".*: warning: Array subscript is undefined",
+                  r".*: warning: array subscript is below array bounds"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Excess elements in initializer',
+     'patterns': [r".*: warning: excess elements in .+ initializer"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Decimal constant is unsigned only in ISO C90',
+     'patterns': [r".*: warning: this decimal constant is unsigned only in ISO C90"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmain',
+     'description': 'main is usually a function',
+     'patterns': [r".*: warning: 'main' is usually a function"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Typedef ignored',
+     'patterns': [r".*: warning: 'typedef' was ignored in this declaration"]},
+    {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Waddress',
+     'description': 'Address always evaluates to true',
+     'patterns': [r".*: warning: the address of '.+' will always evaluate as 'true'"]},
+    {'category': 'C/C++', 'severity': Severity.FIXMENOW,
+     'description': 'Freeing a non-heap object',
+     'patterns': [r".*: warning: attempt to free a non-heap object '.+'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wchar-subscripts',
+     'description': 'Array subscript has type char',
+     'patterns': [r".*: warning: array subscript .+ type 'char'.+Wchar-subscripts"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Constant too large for type',
+     'patterns': [r".*: warning: integer constant is too large for '.+' type"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
+     'description': 'Constant too large for type, truncated',
+     'patterns': [r".*: warning: large integer implicitly truncated to unsigned type"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Winteger-overflow',
+     'description': 'Overflow in expression',
+     'patterns': [r".*: warning: overflow in expression; .*Winteger-overflow"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Woverflow',
+     'description': 'Overflow in implicit constant conversion',
+     'patterns': [r".*: warning: overflow in implicit constant conversion"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Declaration does not declare anything',
+     'patterns': [r".*: warning: declaration 'class .+' does not declare anything"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wreorder',
+     'description': 'Initialization order will be different',
+     'patterns': [r".*: warning: '.+' will be initialized after",
+                  r".*: warning: field .+ will be initialized after .+Wreorder"]},
+    {'category': 'cont.', 'severity': Severity.SKIP,
+     'description': 'skip,   ....',
+     'patterns': [r".*: warning:   '.+'"]},
+    {'category': 'cont.', 'severity': Severity.SKIP,
+     'description': 'skip,   base ...',
+     'patterns': [r".*: warning:   base '.+'"]},
+    {'category': 'cont.', 'severity': Severity.SKIP,
+     'description': 'skip,   when initialized here',
+     'patterns': [r".*: warning:   when initialized here"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-parameter-type',
+     'description': 'Parameter type not specified',
+     'patterns': [r".*: warning: type of '.+' defaults to 'int'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-declarations',
+     'description': 'Missing declarations',
+     'patterns': [r".*: warning: declaration does not declare anything"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wmissing-noreturn',
+     'description': 'Missing noreturn',
+     'patterns': [r".*: warning: function '.*' could be declared with attribute 'noreturn'"]},
+    # pylint:disable=anomalous-backslash-in-string
+    # TODO(chh): fix the backslash pylint warning.
+    {'category': 'gcc', 'severity': Severity.MEDIUM,
+     'description': 'Invalid option for C file',
+     'patterns': [r".*: warning: command line option "".+"" is valid for C\+\+\/ObjC\+\+ but not for C"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'User warning',
+     'patterns': [r".*: warning: #warning "".+"""]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wvexing-parse',
+     'description': 'Vexing parsing problem',
+     'patterns': [r".*: warning: empty parentheses interpreted as a function declaration"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wextra',
+     'description': 'Dereferencing void*',
+     'patterns': [r".*: warning: dereferencing 'void \*' pointer"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Comparison of pointer and integer',
+     'patterns': [r".*: warning: ordered comparison of pointer with integer zero",
+                  r".*: warning: .*comparison between pointer and integer"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Use of error-prone unary operator',
+     'patterns': [r".*: warning: use of unary operator that may be intended as compound assignment"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wwrite-strings',
+     'description': 'Conversion of string constant to non-const char*',
+     'patterns': [r".*: warning: deprecated conversion from string constant to '.+'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wstrict-prototypes',
+     'description': 'Function declaration isn''t a prototype',
+     'patterns': [r".*: warning: function declaration isn't a prototype"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wignored-qualifiers',
+     'description': 'Type qualifiers ignored on function return value',
+     'patterns': [r".*: warning: type qualifiers ignored on function return type",
+                  r".*: warning: .+ type qualifier .+ has no effect .+Wignored-qualifiers"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': '&lt;foo&gt; declared inside parameter list, scope limited to this definition',
+     'patterns': [r".*: warning: '.+' declared inside parameter list"]},
+    {'category': 'cont.', 'severity': Severity.SKIP,
+     'description': 'skip, its scope is only this ...',
+     'patterns': [r".*: warning: its scope is only this definition or declaration, which is probably not what you want"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
+     'description': 'Line continuation inside comment',
+     'patterns': [r".*: warning: multi-line comment"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wcomment',
+     'description': 'Comment inside comment',
+     'patterns': [r".*: warning: "".+"" within comment"]},
     # Warning "value stored is never read" could be from clang-tidy or clang static analyzer.
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy Value stored is never read',
-        'patterns':[r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"] },
-    { 'category':'C/C++',   'severity':severity.LOW,
-        'description':'Value stored is never read',
-        'patterns':[r".*: warning: Value stored to .+ is never read"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'-Wdeprecated-declarations',
-        'description':'Deprecated declarations',
-        'patterns':[r".*: warning: .+ is deprecated.+deprecated-declarations"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'-Wdeprecated-register',
-        'description':'Deprecated register',
-        'patterns':[r".*: warning: 'register' storage class specifier is deprecated"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'-Wpointer-sign',
-        'description':'Converts between pointers to integer types with different sign',
-        'patterns':[r".*: warning: .+ converts between pointers to integer types with different sign"] },
-    { 'category':'C/C++',   'severity':severity.HARMLESS,
-        'description':'Extra tokens after #endif',
-        'patterns':[r".*: warning: extra tokens at end of #endif directive"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wenum-compare',
-        'description':'Comparison between different enums',
-        'patterns':[r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wconversion',
-        'description':'Conversion may change value',
-        'patterns':[r".*: warning: converting negative value '.+' to '.+'",
-                    r".*: warning: conversion to '.+' .+ may (alter|change)"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wconversion-null',
-        'description':'Converting to non-pointer type from NULL',
-        'patterns':[r".*: warning: converting to non-pointer type '.+' from NULL"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wnull-conversion',
-        'description':'Converting NULL to non-pointer type',
-        'patterns':[r".*: warning: implicit conversion of NULL constant to '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wnon-literal-null-conversion',
-        'description':'Zero used as null pointer',
-        'patterns':[r".*: warning: expression .* zero treated as a null pointer constant"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Implicit conversion changes value',
-        'patterns':[r".*: warning: implicit conversion .* changes value from .* to .*-conversion"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Passing NULL as non-pointer argument',
-        'patterns':[r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wctor-dtor-privacy',
-        'description':'Class seems unusable because of private ctor/dtor' ,
-        'patterns':[r".*: warning: all member functions in class '.+' are private"] },
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer Value stored is never read',
+     'patterns': [r".*: warning: Value stored to .+ is never read.*clang-analyzer-deadcode.DeadStores"]},
+    {'category': 'C/C++', 'severity': Severity.LOW,
+     'description': 'Value stored is never read',
+     'patterns': [r".*: warning: Value stored to .+ is never read"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-declarations',
+     'description': 'Deprecated declarations',
+     'patterns': [r".*: warning: .+ is deprecated.+deprecated-declarations"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wdeprecated-register',
+     'description': 'Deprecated register',
+     'patterns': [r".*: warning: 'register' storage class specifier is deprecated"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wpointer-sign',
+     'description': 'Converts between pointers to integer types with different sign',
+     'patterns': [r".*: warning: .+ converts between pointers to integer types with different sign"]},
+    {'category': 'C/C++', 'severity': Severity.HARMLESS,
+     'description': 'Extra tokens after #endif',
+     'patterns': [r".*: warning: extra tokens at end of #endif directive"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wenum-compare',
+     'description': 'Comparison between different enums',
+     'patterns': [r".*: warning: comparison between '.+' and '.+'.+Wenum-compare"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion',
+     'description': 'Conversion may change value',
+     'patterns': [r".*: warning: converting negative value '.+' to '.+'",
+                  r".*: warning: conversion to '.+' .+ may (alter|change)"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wconversion-null',
+     'description': 'Converting to non-pointer type from NULL',
+     'patterns': [r".*: warning: converting to non-pointer type '.+' from NULL"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-conversion',
+     'description': 'Converting NULL to non-pointer type',
+     'patterns': [r".*: warning: implicit conversion of NULL constant to '.+'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnon-literal-null-conversion',
+     'description': 'Zero used as null pointer',
+     'patterns': [r".*: warning: expression .* zero treated as a null pointer constant"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Implicit conversion changes value',
+     'patterns': [r".*: warning: implicit conversion .* changes value from .* to .*-conversion"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Passing NULL as non-pointer argument',
+     'patterns': [r".*: warning: passing NULL to non-pointer argument [0-9]+ of '.+'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
+     'description': 'Class seems unusable because of private ctor/dtor',
+     'patterns': [r".*: warning: all member functions in class '.+' are private"]},
     # skip this next one, because it only points out some RefBase-based classes where having a private destructor is perfectly fine
-    { 'category':'C/C++',   'severity':severity.SKIP, 'option':'-Wctor-dtor-privacy',
-        'description':'Class seems unusable because of private ctor/dtor' ,
-        'patterns':[r".*: warning: 'class .+' only defines a private destructor and has no friends"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wctor-dtor-privacy',
-        'description':'Class seems unusable because of private ctor/dtor' ,
-        'patterns':[r".*: warning: 'class .+' only defines private constructors and has no friends"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wgnu-static-float-init',
-        'description':'In-class initializer for static const float/double' ,
-        'patterns':[r".*: warning: in-class initializer for static data member of .+const (float|double)"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wpointer-arith',
-        'description':'void* used in arithmetic' ,
-        'patterns':[r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
-                    r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
-                    r".*: warning: wrong type argument to increment"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wsign-promo',
-        'description':'Overload resolution chose to promote from unsigned or enum to signed type' ,
-        'patterns':[r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"] },
-    { 'category':'cont.',   'severity':severity.SKIP,
-        'description':'',
-        'patterns':[r".*: warning:   in call to '.+'"] },
-    { 'category':'C/C++',   'severity':severity.HIGH, 'option':'-Wextra',
-        'description':'Base should be explicitly initialized in copy constructor',
-        'patterns':[r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'VLA has zero or negative size',
-        'patterns':[r".*: warning: Declared variable-length array \(VLA\) has .+ size"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Return value from void function',
-        'patterns':[r".*: warning: 'return' with a value, in function returning void"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'multichar',
-        'description':'Multi-character character constant',
-        'patterns':[r".*: warning: multi-character character constant"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'writable-strings',
-        'description':'Conversion from string literal to char*',
-        'patterns':[r".*: warning: .+ does not allow conversion from string literal to 'char \*'"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'-Wextra-semi',
-        'description':'Extra \';\'',
-        'patterns':[r".*: warning: extra ';' .+extra-semi"] },
-    { 'category':'C/C++',   'severity':severity.LOW,
-        'description':'Useless specifier',
-        'patterns':[r".*: warning: useless storage class specifier in empty declaration"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'-Wduplicate-decl-specifier',
-        'description':'Duplicate declaration specifier',
-        'patterns':[r".*: warning: duplicate '.+' declaration specifier"] },
-    { 'category':'logtags',   'severity':severity.LOW,
-        'description':'Duplicate logtag',
-        'patterns':[r".*: warning: tag \".+\" \(.+\) duplicated in .+"] },
-    { 'category':'logtags',   'severity':severity.LOW, 'option':'typedef-redefinition',
-        'description':'Typedef redefinition',
-        'patterns':[r".*: warning: redefinition of typedef '.+' is a C11 feature"] },
-    { 'category':'logtags',   'severity':severity.LOW, 'option':'gnu-designator',
-        'description':'GNU old-style field designator',
-        'patterns':[r".*: warning: use of GNU old-style field designator extension"] },
-    { 'category':'logtags',   'severity':severity.LOW, 'option':'missing-field-initializers',
-        'description':'Missing field initializers',
-        'patterns':[r".*: warning: missing field '.+' initializer"] },
-    { 'category':'logtags',   'severity':severity.LOW, 'option':'missing-braces',
-        'description':'Missing braces',
-        'patterns':[r".*: warning: suggest braces around initialization of",
-                    r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
-                    r".*: warning: braces around scalar initializer"] },
-    { 'category':'logtags',   'severity':severity.LOW, 'option':'sign-compare',
-        'description':'Comparison of integers of different signs',
-        'patterns':[r".*: warning: comparison of integers of different signs.+sign-compare"] },
-    { 'category':'logtags',   'severity':severity.LOW, 'option':'dangling-else',
-        'description':'Add braces to avoid dangling else',
-        'patterns':[r".*: warning: add explicit braces to avoid dangling else"] },
-    { 'category':'logtags',   'severity':severity.LOW, 'option':'initializer-overrides',
-        'description':'Initializer overrides prior initialization',
-        'patterns':[r".*: warning: initializer overrides prior initialization of this subobject"] },
-    { 'category':'logtags',   'severity':severity.LOW, 'option':'self-assign',
-        'description':'Assigning value to self',
-        'patterns':[r".*: warning: explicitly assigning value of .+ to itself"] },
-    { 'category':'logtags',   'severity':severity.LOW, 'option':'gnu-variable-sized-type-not-at-end',
-        'description':'GNU extension, variable sized type not at end',
-        'patterns':[r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"] },
-    { 'category':'logtags',   'severity':severity.LOW, 'option':'tautological-constant-out-of-range-compare',
-        'description':'Comparison of constant is always false/true',
-        'patterns':[r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"] },
-    { 'category':'logtags',   'severity':severity.LOW, 'option':'overloaded-virtual',
-        'description':'Hides overloaded virtual function',
-        'patterns':[r".*: '.+' hides overloaded virtual function"] },
-    { 'category':'logtags',   'severity':severity.LOW, 'option':'incompatible-pointer-types',
-        'description':'Incompatible pointer types',
-        'patterns':[r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"] },
-    { 'category':'logtags',   'severity':severity.LOW, 'option':'asm-operand-widths',
-        'description':'ASM value size does not match register size',
-        'patterns':[r".*: warning: value size does not match register size specified by the constraint and modifier"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'tautological-compare',
-        'description':'Comparison of self is always false',
-        'patterns':[r".*: self-comparison always evaluates to false"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'constant-logical-operand',
-        'description':'Logical op with constant operand',
-        'patterns':[r".*: use of logical '.+' with constant operand"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'literal-suffix',
-        'description':'Needs a space between literal and string macro',
-        'patterns':[r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'#warnings',
-        'description':'Warnings from #warning',
-        'patterns':[r".*: warning: .+-W#warnings"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'absolute-value',
-        'description':'Using float/int absolute value function with int/float argument',
-        'patterns':[r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
-                    r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'-Wc++11-extensions',
-        'description':'Using C++11 extensions',
-        'patterns':[r".*: warning: 'auto' type specifier is a C\+\+11 extension"] },
-    { 'category':'C/C++',   'severity':severity.LOW,
-        'description':'Refers to implicitly defined namespace',
-        'patterns':[r".*: warning: using directive refers to implicitly-defined namespace .+"] },
-    { 'category':'C/C++',   'severity':severity.LOW, 'option':'-Winvalid-pp-token',
-        'description':'Invalid pp token',
-        'patterns':[r".*: warning: missing .+Winvalid-pp-token"] },
+    {'category': 'C/C++', 'severity': Severity.SKIP, 'option': '-Wctor-dtor-privacy',
+     'description': 'Class seems unusable because of private ctor/dtor',
+     'patterns': [r".*: warning: 'class .+' only defines a private destructor and has no friends"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wctor-dtor-privacy',
+     'description': 'Class seems unusable because of private ctor/dtor',
+     'patterns': [r".*: warning: 'class .+' only defines private constructors and has no friends"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wgnu-static-float-init',
+     'description': 'In-class initializer for static const float/double',
+     'patterns': [r".*: warning: in-class initializer for static data member of .+const (float|double)"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wpointer-arith',
+     'description': 'void* used in arithmetic',
+     'patterns': [r".*: warning: pointer of type 'void \*' used in (arithmetic|subtraction)",
+                  r".*: warning: arithmetic on .+ to void is a GNU extension.*Wpointer-arith",
+                  r".*: warning: wrong type argument to increment"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsign-promo',
+     'description': 'Overload resolution chose to promote from unsigned or enum to signed type',
+     'patterns': [r".*: warning: passing '.+' chooses '.+' over '.+'.*Wsign-promo"]},
+    {'category': 'cont.', 'severity': Severity.SKIP,
+     'description': 'skip,   in call to ...',
+     'patterns': [r".*: warning:   in call to '.+'"]},
+    {'category': 'C/C++', 'severity': Severity.HIGH, 'option': '-Wextra',
+     'description': 'Base should be explicitly initialized in copy constructor',
+     'patterns': [r".*: warning: base class '.+' should be explicitly initialized in the copy constructor"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'VLA has zero or negative size',
+     'patterns': [r".*: warning: Declared variable-length array \(VLA\) has .+ size"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Return value from void function',
+     'patterns': [r".*: warning: 'return' with a value, in function returning void"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'multichar',
+     'description': 'Multi-character character constant',
+     'patterns': [r".*: warning: multi-character character constant"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'writable-strings',
+     'description': 'Conversion from string literal to char*',
+     'patterns': [r".*: warning: .+ does not allow conversion from string literal to 'char \*'"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wextra-semi',
+     'description': 'Extra \';\'',
+     'patterns': [r".*: warning: extra ';' .+extra-semi"]},
+    {'category': 'C/C++', 'severity': Severity.LOW,
+     'description': 'Useless specifier',
+     'patterns': [r".*: warning: useless storage class specifier in empty declaration"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wduplicate-decl-specifier',
+     'description': 'Duplicate declaration specifier',
+     'patterns': [r".*: warning: duplicate '.+' declaration specifier"]},
+    {'category': 'logtags', 'severity': Severity.LOW,
+     'description': 'Duplicate logtag',
+     'patterns': [r".*: warning: tag \".+\" \(.+\) duplicated in .+"]},
+    {'category': 'logtags', 'severity': Severity.LOW, 'option': 'typedef-redefinition',
+     'description': 'Typedef redefinition',
+     'patterns': [r".*: warning: redefinition of typedef '.+' is a C11 feature"]},
+    {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-designator',
+     'description': 'GNU old-style field designator',
+     'patterns': [r".*: warning: use of GNU old-style field designator extension"]},
+    {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-field-initializers',
+     'description': 'Missing field initializers',
+     'patterns': [r".*: warning: missing field '.+' initializer"]},
+    {'category': 'logtags', 'severity': Severity.LOW, 'option': 'missing-braces',
+     'description': 'Missing braces',
+     'patterns': [r".*: warning: suggest braces around initialization of",
+                  r".*: warning: too many braces around scalar initializer .+Wmany-braces-around-scalar-init",
+                  r".*: warning: braces around scalar initializer"]},
+    {'category': 'logtags', 'severity': Severity.LOW, 'option': 'sign-compare',
+     'description': 'Comparison of integers of different signs',
+     'patterns': [r".*: warning: comparison of integers of different signs.+sign-compare"]},
+    {'category': 'logtags', 'severity': Severity.LOW, 'option': 'dangling-else',
+     'description': 'Add braces to avoid dangling else',
+     'patterns': [r".*: warning: add explicit braces to avoid dangling else"]},
+    {'category': 'logtags', 'severity': Severity.LOW, 'option': 'initializer-overrides',
+     'description': 'Initializer overrides prior initialization',
+     'patterns': [r".*: warning: initializer overrides prior initialization of this subobject"]},
+    {'category': 'logtags', 'severity': Severity.LOW, 'option': 'self-assign',
+     'description': 'Assigning value to self',
+     'patterns': [r".*: warning: explicitly assigning value of .+ to itself"]},
+    {'category': 'logtags', 'severity': Severity.LOW, 'option': 'gnu-variable-sized-type-not-at-end',
+     'description': 'GNU extension, variable sized type not at end',
+     'patterns': [r".*: warning: field '.+' with variable sized type '.+' not at the end of a struct or class"]},
+    {'category': 'logtags', 'severity': Severity.LOW, 'option': 'tautological-constant-out-of-range-compare',
+     'description': 'Comparison of constant is always false/true',
+     'patterns': [r".*: comparison of .+ is always .+Wtautological-constant-out-of-range-compare"]},
+    {'category': 'logtags', 'severity': Severity.LOW, 'option': 'overloaded-virtual',
+     'description': 'Hides overloaded virtual function',
+     'patterns': [r".*: '.+' hides overloaded virtual function"]},
+    {'category': 'logtags', 'severity': Severity.LOW, 'option': 'incompatible-pointer-types',
+     'description': 'Incompatible pointer types',
+     'patterns': [r".*: warning: incompatible pointer types .+Wincompatible-pointer-types"]},
+    {'category': 'logtags', 'severity': Severity.LOW, 'option': 'asm-operand-widths',
+     'description': 'ASM value size does not match register size',
+     'patterns': [r".*: warning: value size does not match register size specified by the constraint and modifier"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'tautological-compare',
+     'description': 'Comparison of self is always false',
+     'patterns': [r".*: self-comparison always evaluates to false"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'constant-logical-operand',
+     'description': 'Logical op with constant operand',
+     'patterns': [r".*: use of logical '.+' with constant operand"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'literal-suffix',
+     'description': 'Needs a space between literal and string macro',
+     'patterns': [r".*: warning: invalid suffix on literal.+ requires a space .+Wliteral-suffix"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '#warnings',
+     'description': 'Warnings from #warning',
+     'patterns': [r".*: warning: .+-W#warnings"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': 'absolute-value',
+     'description': 'Using float/int absolute value function with int/float argument',
+     'patterns': [r".*: warning: using .+ absolute value function .+ when argument is .+ type .+Wabsolute-value",
+                  r".*: warning: absolute value function '.+' given .+ which may cause truncation .+Wabsolute-value"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Wc++11-extensions',
+     'description': 'Using C++11 extensions',
+     'patterns': [r".*: warning: 'auto' type specifier is a C\+\+11 extension"]},
+    {'category': 'C/C++', 'severity': Severity.LOW,
+     'description': 'Refers to implicitly defined namespace',
+     'patterns': [r".*: warning: using directive refers to implicitly-defined namespace .+"]},
+    {'category': 'C/C++', 'severity': Severity.LOW, 'option': '-Winvalid-pp-token',
+     'description': 'Invalid pp token',
+     'patterns': [r".*: warning: missing .+Winvalid-pp-token"]},
 
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Operator new returns NULL',
-        'patterns':[r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wnull-arithmetic',
-        'description':'NULL used in arithmetic',
-        'patterns':[r".*: warning: NULL used in arithmetic",
-                    r".*: warning: comparison between NULL and non-pointer"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'header-guard',
-        'description':'Misspelled header guard',
-        'patterns':[r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'empty-body',
-        'description':'Empty loop body',
-        'patterns':[r".*: warning: .+ loop has empty body"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'enum-conversion',
-        'description':'Implicit conversion from enumeration type',
-        'patterns':[r".*: warning: implicit conversion from enumeration type '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'switch',
-        'description':'case value not in enumerated type',
-        'patterns':[r".*: warning: case value not in enumerated type '.+'"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Undefined result',
-        'patterns':[r".*: warning: The result of .+ is undefined",
-                    r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
-                    r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
-                    r".*: warning: shifting a negative signed value is undefined"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Division by zero',
-        'patterns':[r".*: warning: Division by zero"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Use of deprecated method',
-        'patterns':[r".*: warning: '.+' is deprecated .+"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Use of garbage or uninitialized value',
-        'patterns':[r".*: warning: .+ is a garbage value",
-                    r".*: warning: Function call argument is an uninitialized value",
-                    r".*: warning: Undefined or garbage value returned to caller",
-                    r".*: warning: Called .+ pointer is.+uninitialized",
-                    r".*: warning: Called .+ pointer is.+uninitalized",  # match a typo in compiler message
-                    r".*: warning: Use of zero-allocated memory",
-                    r".*: warning: Dereference of undefined pointer value",
-                    r".*: warning: Passed-by-value .+ contains uninitialized data",
-                    r".*: warning: Branch condition evaluates to a garbage value",
-                    r".*: warning: The .+ of .+ is an uninitialized value.",
-                    r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
-                    r".*: warning: Assigned value is garbage or undefined"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Result of malloc type incompatible with sizeof operand type',
-        'patterns':[r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wsizeof-array-argument',
-        'description':'Sizeof on array argument',
-        'patterns':[r".*: warning: sizeof on array function parameter will return"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wsizeof-pointer-memacces',
-        'description':'Bad argument size of memory access functions',
-        'patterns':[r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Return value not checked',
-        'patterns':[r".*: warning: The return value from .+ is not checked"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Possible heap pollution',
-        'patterns':[r".*: warning: .*Possible heap pollution from .+ type .+"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Allocation size of 0 byte',
-        'patterns':[r".*: warning: Call to .+ has an allocation size of 0 byte"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Result of malloc type incompatible with sizeof operand type',
-        'patterns':[r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wfor-loop-analysis',
-        'description':'Variable used in loop condition not modified in loop body',
-        'patterns':[r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM,
-        'description':'Closing a previously closed file',
-        'patterns':[r".*: warning: Closing a previously closed file"] },
-    { 'category':'C/C++',   'severity':severity.MEDIUM, 'option':'-Wunnamed-type-template-args',
-        'description':'Unnamed template type argument',
-        'patterns':[r".*: warning: template argument.+Wunnamed-type-template-args"] },
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Operator new returns NULL',
+     'patterns': [r".*: warning: 'operator new' must not return NULL unless it is declared 'throw\(\)' .+"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wnull-arithmetic',
+     'description': 'NULL used in arithmetic',
+     'patterns': [r".*: warning: NULL used in arithmetic",
+                  r".*: warning: comparison between NULL and non-pointer"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'header-guard',
+     'description': 'Misspelled header guard',
+     'patterns': [r".*: warning: '.+' is used as a header guard .+ followed by .+ different macro"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'empty-body',
+     'description': 'Empty loop body',
+     'patterns': [r".*: warning: .+ loop has empty body"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'enum-conversion',
+     'description': 'Implicit conversion from enumeration type',
+     'patterns': [r".*: warning: implicit conversion from enumeration type '.+'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': 'switch',
+     'description': 'case value not in enumerated type',
+     'patterns': [r".*: warning: case value not in enumerated type '.+'"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Undefined result',
+     'patterns': [r".*: warning: The result of .+ is undefined",
+                  r".*: warning: passing an object that .+ has undefined behavior \[-Wvarargs\]",
+                  r".*: warning: 'this' pointer cannot be null in well-defined C\+\+ code;",
+                  r".*: warning: shifting a negative signed value is undefined"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Division by zero',
+     'patterns': [r".*: warning: Division by zero"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Use of deprecated method',
+     'patterns': [r".*: warning: '.+' is deprecated .+"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Use of garbage or uninitialized value',
+     'patterns': [r".*: warning: .+ is a garbage value",
+                  r".*: warning: Function call argument is an uninitialized value",
+                  r".*: warning: Undefined or garbage value returned to caller",
+                  r".*: warning: Called .+ pointer is.+uninitialized",
+                  r".*: warning: Called .+ pointer is.+uninitalized",  # match a typo in compiler message
+                  r".*: warning: Use of zero-allocated memory",
+                  r".*: warning: Dereference of undefined pointer value",
+                  r".*: warning: Passed-by-value .+ contains uninitialized data",
+                  r".*: warning: Branch condition evaluates to a garbage value",
+                  r".*: warning: The .+ of .+ is an uninitialized value.",
+                  r".*: warning: .+ is used uninitialized whenever .+sometimes-uninitialized",
+                  r".*: warning: Assigned value is garbage or undefined"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Result of malloc type incompatible with sizeof operand type',
+     'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-array-argument',
+     'description': 'Sizeof on array argument',
+     'patterns': [r".*: warning: sizeof on array function parameter will return"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wsizeof-pointer-memacces',
+     'description': 'Bad argument size of memory access functions',
+     'patterns': [r".*: warning: .+\[-Wsizeof-pointer-memaccess\]"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Return value not checked',
+     'patterns': [r".*: warning: The return value from .+ is not checked"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Possible heap pollution',
+     'patterns': [r".*: warning: .*Possible heap pollution from .+ type .+"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Allocation size of 0 byte',
+     'patterns': [r".*: warning: Call to .+ has an allocation size of 0 byte"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Result of malloc type incompatible with sizeof operand type',
+     'patterns': [r".*: warning: Result of '.+' is converted to .+ incompatible with sizeof operand type"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wfor-loop-analysis',
+     'description': 'Variable used in loop condition not modified in loop body',
+     'patterns': [r".*: warning: variable '.+' used in loop condition.*Wfor-loop-analysis"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM,
+     'description': 'Closing a previously closed file',
+     'patterns': [r".*: warning: Closing a previously closed file"]},
+    {'category': 'C/C++', 'severity': Severity.MEDIUM, 'option': '-Wunnamed-type-template-args',
+     'description': 'Unnamed template type argument',
+     'patterns': [r".*: warning: template argument.+Wunnamed-type-template-args"]},
 
-    { 'category':'C/C++',   'severity':severity.HARMLESS,
-        'description':'Discarded qualifier from pointer target type',
-        'patterns':[r".*: warning: .+ discards '.+' qualifier from pointer target type"] },
-    { 'category':'C/C++',   'severity':severity.HARMLESS,
-        'description':'Use snprintf instead of sprintf',
-        'patterns':[r".*: warning: .*sprintf is often misused; please use snprintf"] },
-    { 'category':'C/C++',   'severity':severity.HARMLESS,
-        'description':'Unsupported optimizaton flag',
-        'patterns':[r".*: warning: optimization flag '.+' is not supported"] },
-    { 'category':'C/C++',   'severity':severity.HARMLESS,
-        'description':'Extra or missing parentheses',
-        'patterns':[r".*: warning: equality comparison with extraneous parentheses",
-                    r".*: warning: .+ within .+Wlogical-op-parentheses"] },
-    { 'category':'C/C++',   'severity':severity.HARMLESS, 'option':'mismatched-tags',
-        'description':'Mismatched class vs struct tags',
-        'patterns':[r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
-                    r".*: warning: .+ was previously declared as a .+mismatched-tags"] },
+    {'category': 'C/C++', 'severity': Severity.HARMLESS,
+     'description': 'Discarded qualifier from pointer target type',
+     'patterns': [r".*: warning: .+ discards '.+' qualifier from pointer target type"]},
+    {'category': 'C/C++', 'severity': Severity.HARMLESS,
+     'description': 'Use snprintf instead of sprintf',
+     'patterns': [r".*: warning: .*sprintf is often misused; please use snprintf"]},
+    {'category': 'C/C++', 'severity': Severity.HARMLESS,
+     'description': 'Unsupported optimizaton flag',
+     'patterns': [r".*: warning: optimization flag '.+' is not supported"]},
+    {'category': 'C/C++', 'severity': Severity.HARMLESS,
+     'description': 'Extra or missing parentheses',
+     'patterns': [r".*: warning: equality comparison with extraneous parentheses",
+                  r".*: warning: .+ within .+Wlogical-op-parentheses"]},
+    {'category': 'C/C++', 'severity': Severity.HARMLESS, 'option': 'mismatched-tags',
+     'description': 'Mismatched class vs struct tags',
+     'patterns': [r".*: warning: '.+' defined as a .+ here but previously declared as a .+mismatched-tags",
+                  r".*: warning: .+ was previously declared as a .+mismatched-tags"]},
 
     # these next ones are to deal with formatting problems resulting from the log being mixed up by 'make -j'
-    { 'category':'C/C++',   'severity':severity.SKIP,
-        'description':'',
-        'patterns':[r".*: warning: ,$"] },
-    { 'category':'C/C++',   'severity':severity.SKIP,
-        'description':'',
-        'patterns':[r".*: warning: $"] },
-    { 'category':'C/C++',   'severity':severity.SKIP,
-        'description':'',
-        'patterns':[r".*: warning: In file included from .+,"] },
+    {'category': 'C/C++', 'severity': Severity.SKIP,
+     'description': 'skip, ,',
+     'patterns': [r".*: warning: ,$"]},
+    {'category': 'C/C++', 'severity': Severity.SKIP,
+     'description': 'skip,',
+     'patterns': [r".*: warning: $"]},
+    {'category': 'C/C++', 'severity': Severity.SKIP,
+     'description': 'skip, In file included from ...',
+     'patterns': [r".*: warning: In file included from .+,"]},
 
     # warnings from clang-tidy
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy readability',
-        'patterns':[r".*: .+\[readability-.+\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy c++ core guidelines',
-        'patterns':[r".*: .+\[cppcoreguidelines-.+\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy google-default-arguments',
-        'patterns':[r".*: .+\[google-default-arguments\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy google-runtime-int',
-        'patterns':[r".*: .+\[google-runtime-int\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy google-runtime-operator',
-        'patterns':[r".*: .+\[google-runtime-operator\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy google-runtime-references',
-        'patterns':[r".*: .+\[google-runtime-references\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy google-build',
-        'patterns':[r".*: .+\[google-build-.+\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy google-explicit',
-        'patterns':[r".*: .+\[google-explicit-.+\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy google-readability',
-        'patterns':[r".*: .+\[google-readability-.+\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy google-global',
-        'patterns':[r".*: .+\[google-global-.+\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy google- other',
-        'patterns':[r".*: .+\[google-.+\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy modernize',
-        'patterns':[r".*: .+\[modernize-.+\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy misc',
-        'patterns':[r".*: .+\[misc-.+\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy performance-faster-string-find',
-        'patterns':[r".*: .+\[performance-faster-string-find\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy performance-for-range-copy',
-        'patterns':[r".*: .+\[performance-for-range-copy\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy performance-implicit-cast-in-loop',
-        'patterns':[r".*: .+\[performance-implicit-cast-in-loop\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy performance-unnecessary-copy-initialization',
-        'patterns':[r".*: .+\[performance-unnecessary-copy-initialization\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy performance-unnecessary-value-param',
-        'patterns':[r".*: .+\[performance-unnecessary-value-param\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer Unreachable code',
-        'patterns':[r".*: warning: This statement is never executed.*UnreachableCode"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer Size of malloc may overflow',
-        'patterns':[r".*: warning: .* size of .* may overflow .*MallocOverflow"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer Stream pointer might be NULL',
-        'patterns':[r".*: warning: Stream pointer might be NULL .*unix.Stream"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer Opened file never closed',
-        'patterns':[r".*: warning: Opened File never closed.*unix.Stream"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer sozeof() on a pointer type',
-        'patterns':[r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer Pointer arithmetic on non-array variables',
-        'patterns':[r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer Subtraction of pointers of different memory chunks',
-        'patterns':[r".*: warning: Subtraction of two pointers .*PointerSub"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer Access out-of-bound array element',
-        'patterns':[r".*: warning: Access out-of-bound array element .*ArrayBound"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer Out of bound memory access',
-        'patterns':[r".*: warning: Out of bound memory access .*ArrayBoundV2"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer Possible lock order reversal',
-        'patterns':[r".*: warning: .* Possible lock order reversal.*PthreadLock"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer Argument is a pointer to uninitialized value',
-        'patterns':[r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer cast to struct',
-        'patterns':[r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer call path problems',
-        'patterns':[r".*: warning: Call Path : .+"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-analyzer other',
-        'patterns':[r".*: .+\[clang-analyzer-.+\]$",
-                    r".*: Call Path : .+$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy CERT',
-        'patterns':[r".*: .+\[cert-.+\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-tidy llvm',
-        'patterns':[r".*: .+\[llvm-.+\]$"] },
-    { 'category':'C/C++',   'severity':severity.TIDY,
-        'description':'clang-diagnostic',
-        'patterns':[r".*: .+\[clang-diagnostic-.+\]$"] },
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy readability',
+     'patterns': [r".*: .+\[readability-.+\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy c++ core guidelines',
+     'patterns': [r".*: .+\[cppcoreguidelines-.+\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy google-default-arguments',
+     'patterns': [r".*: .+\[google-default-arguments\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy google-runtime-int',
+     'patterns': [r".*: .+\[google-runtime-int\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy google-runtime-operator',
+     'patterns': [r".*: .+\[google-runtime-operator\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy google-runtime-references',
+     'patterns': [r".*: .+\[google-runtime-references\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy google-build',
+     'patterns': [r".*: .+\[google-build-.+\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy google-explicit',
+     'patterns': [r".*: .+\[google-explicit-.+\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy google-readability',
+     'patterns': [r".*: .+\[google-readability-.+\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy google-global',
+     'patterns': [r".*: .+\[google-global-.+\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy google- other',
+     'patterns': [r".*: .+\[google-.+\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy modernize',
+     'patterns': [r".*: .+\[modernize-.+\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy misc',
+     'patterns': [r".*: .+\[misc-.+\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy performance-faster-string-find',
+     'patterns': [r".*: .+\[performance-faster-string-find\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy performance-for-range-copy',
+     'patterns': [r".*: .+\[performance-for-range-copy\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy performance-implicit-cast-in-loop',
+     'patterns': [r".*: .+\[performance-implicit-cast-in-loop\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy performance-unnecessary-copy-initialization',
+     'patterns': [r".*: .+\[performance-unnecessary-copy-initialization\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy performance-unnecessary-value-param',
+     'patterns': [r".*: .+\[performance-unnecessary-value-param\]$"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer Unreachable code',
+     'patterns': [r".*: warning: This statement is never executed.*UnreachableCode"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer Size of malloc may overflow',
+     'patterns': [r".*: warning: .* size of .* may overflow .*MallocOverflow"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer Stream pointer might be NULL',
+     'patterns': [r".*: warning: Stream pointer might be NULL .*unix.Stream"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer Opened file never closed',
+     'patterns': [r".*: warning: Opened File never closed.*unix.Stream"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer sozeof() on a pointer type',
+     'patterns': [r".*: warning: .*calls sizeof.* on a pointer type.*SizeofPtr"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer Pointer arithmetic on non-array variables',
+     'patterns': [r".*: warning: Pointer arithmetic on non-array variables .*PointerArithm"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer Subtraction of pointers of different memory chunks',
+     'patterns': [r".*: warning: Subtraction of two pointers .*PointerSub"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer Access out-of-bound array element',
+     'patterns': [r".*: warning: Access out-of-bound array element .*ArrayBound"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer Out of bound memory access',
+     'patterns': [r".*: warning: Out of bound memory access .*ArrayBoundV2"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer Possible lock order reversal',
+     'patterns': [r".*: warning: .* Possible lock order reversal.*PthreadLock"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer Argument is a pointer to uninitialized value',
+     'patterns': [r".*: warning: .* argument is a pointer to uninitialized value .*CallAndMessage"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer cast to struct',
+     'patterns': [r".*: warning: Casting a non-structure type to a structure type .*CastToStruct"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer call path problems',
+     'patterns': [r".*: warning: Call Path : .+"]},
+    {'category': 'C/C++', 'severity': Severity.ANALYZER,
+     'description': 'clang-analyzer other',
+     'patterns': [r".*: .+\[clang-analyzer-.+\]$",
+                  r".*: Call Path : .+$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy CERT',
+     'patterns': [r".*: .+\[cert-.+\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-tidy llvm',
+     'patterns': [r".*: .+\[llvm-.+\]$"]},
+    {'category': 'C/C++', 'severity': Severity.TIDY,
+     'description': 'clang-diagnostic',
+     'patterns': [r".*: .+\[clang-diagnostic-.+\]$"]},
 
     # catch-all for warnings this script doesn't know about yet
-    { 'category':'C/C++',   'severity':severity.UNKNOWN,
-        'description':'Unclassified/unrecognized warnings',
-        'patterns':[r".*: warning: .+"] },
+    {'category': 'C/C++', 'severity': Severity.UNKNOWN,
+     'description': 'Unclassified/unrecognized warnings',
+     'patterns': [r".*: warning: .+"]},
 ]
 
-for w in warnpatterns:
-    w['members'] = []
-    if 'option' not in w:
-        w['option'] = ''
+
+def project_name_and_pattern(name, pattern):
+  return [name, '(^|.*/)' + pattern + '/.*: warning:']
+
+
+def simple_project_pattern(pattern):
+  return project_name_and_pattern(pattern, pattern)
+
 
 # A list of [project_name, file_path_pattern].
 # project_name should not contain comma, to be used in CSV output.
-projectlist = [
-    ['art',                 r"(^|.*/)art/.*: warning:"],
-    ['bionic',              r"(^|.*/)bionic/.*: warning:"],
-    ['bootable',            r"(^|.*/)bootable/.*: warning:"],
-    ['build',               r"(^|.*/)build/.*: warning:"],
-    ['cts',                 r"(^|.*/)cts/.*: warning:"],
-    ['dalvik',              r"(^|.*/)dalvik/.*: warning:"],
-    ['developers',          r"(^|.*/)developers/.*: warning:"],
-    ['development',         r"(^|.*/)development/.*: warning:"],
-    ['device',              r"(^|.*/)device/.*: warning:"],
-    ['doc',                 r"(^|.*/)doc/.*: warning:"],
+project_list = [
+    simple_project_pattern('art'),
+    simple_project_pattern('bionic'),
+    simple_project_pattern('bootable'),
+    simple_project_pattern('build'),
+    simple_project_pattern('cts'),
+    simple_project_pattern('dalvik'),
+    simple_project_pattern('developers'),
+    simple_project_pattern('development'),
+    simple_project_pattern('device'),
+    simple_project_pattern('doc'),
     # match external/google* before external/
-    ['external/google',     r"(^|.*/)external/google.*: warning:"],
-    ['external/non-google', r"(^|.*/)external/.*: warning:"],
-    ['frameworks',          r"(^|.*/)frameworks/.*: warning:"],
-    ['hardware',            r"(^|.*/)hardware/.*: warning:"],
-    ['kernel',              r"(^|.*/)kernel/.*: warning:"],
-    ['libcore',             r"(^|.*/)libcore/.*: warning:"],
-    ['libnativehelper',      r"(^|.*/)libnativehelper/.*: warning:"],
-    ['ndk',                 r"(^|.*/)ndk/.*: warning:"],
-    ['packages',            r"(^|.*/)packages/.*: warning:"],
-    ['pdk',                 r"(^|.*/)pdk/.*: warning:"],
-    ['prebuilts',           r"(^|.*/)prebuilts/.*: warning:"],
-    ['system',              r"(^|.*/)system/.*: warning:"],
-    ['toolchain',           r"(^|.*/)toolchain/.*: warning:"],
-    ['test',                r"(^|.*/)test/.*: warning:"],
-    ['tools',               r"(^|.*/)tools/.*: warning:"],
+    project_name_and_pattern('external/google', 'external/google.*'),
+    project_name_and_pattern('external/non-google', 'external'),
+    simple_project_pattern('frameworks/av/camera'),
+    simple_project_pattern('frameworks/av/cmds'),
+    simple_project_pattern('frameworks/av/drm'),
+    simple_project_pattern('frameworks/av/include'),
+    simple_project_pattern('frameworks/av/media'),
+    simple_project_pattern('frameworks/av/radio'),
+    simple_project_pattern('frameworks/av/services'),
+    project_name_and_pattern('frameworks/av/Other', 'frameworks/av'),
+    simple_project_pattern('frameworks/base'),
+    simple_project_pattern('frameworks/compile'),
+    simple_project_pattern('frameworks/minikin'),
+    simple_project_pattern('frameworks/native'),
+    simple_project_pattern('frameworks/opt'),
+    simple_project_pattern('frameworks/rs'),
+    simple_project_pattern('frameworks/webview'),
+    simple_project_pattern('frameworks/wilhelm'),
+    project_name_and_pattern('frameworks/Other', 'frameworks'),
+    simple_project_pattern('hardware/akm'),
+    simple_project_pattern('hardware/broadcom'),
+    simple_project_pattern('hardware/google'),
+    simple_project_pattern('hardware/intel'),
+    simple_project_pattern('hardware/interfaces'),
+    simple_project_pattern('hardware/libhardware'),
+    simple_project_pattern('hardware/libhardware_legacy'),
+    simple_project_pattern('hardware/qcom'),
+    simple_project_pattern('hardware/ril'),
+    project_name_and_pattern('hardware/Other', 'hardware'),
+    simple_project_pattern('kernel'),
+    simple_project_pattern('libcore'),
+    simple_project_pattern('libnativehelper'),
+    simple_project_pattern('ndk'),
+    # match vendor/unbungled_google/packages before other packages
+    simple_project_pattern('unbundled_google'),
+    simple_project_pattern('packages'),
+    simple_project_pattern('pdk'),
+    simple_project_pattern('prebuilts'),
+    simple_project_pattern('system/bt'),
+    simple_project_pattern('system/connectivity'),
+    simple_project_pattern('system/core'),
+    simple_project_pattern('system/extras'),
+    simple_project_pattern('system/gatekeeper'),
+    simple_project_pattern('system/keymaster'),
+    simple_project_pattern('system/libhwbinder'),
+    simple_project_pattern('system/media'),
+    simple_project_pattern('system/netd'),
+    simple_project_pattern('system/security'),
+    simple_project_pattern('system/sepolicy'),
+    simple_project_pattern('system/tools'),
+    simple_project_pattern('system/vold'),
+    project_name_and_pattern('system/Other', 'system'),
+    simple_project_pattern('toolchain'),
+    simple_project_pattern('test'),
+    simple_project_pattern('tools'),
     # match vendor/google* before vendor/
-    ['vendor/google',       r"(^|.*/)vendor/google.*: warning:"],
-    ['vendor/non-google',   r"(^|.*/)vendor/.*: warning:"],
+    project_name_and_pattern('vendor/google', 'vendor/google.*'),
+    project_name_and_pattern('vendor/non-google', 'vendor'),
     # keep out/obj and other patterns at the end.
-    ['out/obj', r".*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|STATIC_LIBRARIES)/.*: warning:"],
-    ['other',   r".*: warning:"],
+    ['out/obj',
+     '.*/(gen|obj[^/]*)/(include|EXECUTABLES|SHARED_LIBRARIES|'
+     'STATIC_LIBRARIES|NATIVE_TESTS)/.*: warning:'],
+    ['other', '.*']  # all other unrecognized patterns
 ]
 
-projectpatterns = []
-for p in projectlist:
-    projectpatterns.append({'description':p[0], 'members':[], 'pattern':re.compile(p[1])})
+project_patterns = []
+project_names = []
+warning_messages = []
+warning_records = []
 
-projectnames = [p[0] for p in projectlist]
 
-# Each warning pattern has 3 dictionaries:
-# (1) 'projects' maps a project name to number of warnings in that project.
-# (2) 'projectanchor' maps a project name to its anchor number for HTML.
-# (3) 'projectwarning' maps a project name to a list of warning of that project.
-for w in warnpatterns:
+def initialize_arrays():
+  """Complete global arrays before they are used."""
+  global project_names, project_patterns
+  project_names = [p[0] for p in project_list]
+  project_patterns = [re.compile(p[1]) for p in project_list]
+  for w in warn_patterns:
+    w['members'] = []
+    if 'option' not in w:
+      w['option'] = ''
+    # Each warning pattern has a 'projects' dictionary, that
+    # maps a project name to number of warnings in that project.
     w['projects'] = {}
-    w['projectanchor'] = {}
-    w['projectwarning'] = {}
 
-platformversion = 'unknown'
-targetproduct = 'unknown'
-targetvariant = 'unknown'
+
+initialize_arrays()
+
+
+android_root = ''
+platform_version = 'unknown'
+target_product = 'unknown'
+target_variant = 'unknown'
 
 
 ##### Data and functions to dump html file. ##################################
 
-anchor = 0
-cur_row_class = 0
-
-html_script_style = """\
-    <script type="text/javascript">
-    function expand(id) {
-      var e = document.getElementById(id);
+html_head_scripts = """\
+  <script type="text/javascript">
+  function expand(id) {
+    var e = document.getElementById(id);
+    var f = document.getElementById(id + "_mark");
+    if (e.style.display == 'block') {
+       e.style.display = 'none';
+       f.innerHTML = '&#x2295';
+    }
+    else {
+       e.style.display = 'block';
+       f.innerHTML = '&#x2296';
+    }
+  };
+  function expandCollapse(show) {
+    for (var id = 1; ; id++) {
+      var e = document.getElementById(id + "");
       var f = document.getElementById(id + "_mark");
-      if (e.style.display == 'block') {
-         e.style.display = 'none';
-         f.innerHTML = '&#x2295';
-      }
-      else {
-         e.style.display = 'block';
-         f.innerHTML = '&#x2296';
-      }
-    };
-    function expand_collapse(show) {
-      for (var id = 1; ; id++) {
-        var e = document.getElementById(id + "");
-        var f = document.getElementById(id + "_mark");
-        if (!e || !f) break;
-        e.style.display = (show ? 'block' : 'none');
-        f.innerHTML = (show ? '&#x2296' : '&#x2295');
-      }
-    };
-    </script>
-    <style type="text/css">
-    th,td{border-collapse:collapse; border:1px solid black;}
-    .button{color:blue;font-size:110%;font-weight:bolder;}
-    .bt{color:black;background-color:transparent;border:none;outline:none;
-        font-size:140%;font-weight:bolder;}
-    .c0{background-color:#e0e0e0;}
-    .c1{background-color:#d0d0d0;}
-    .t1{border-collapse:collapse; width:100%; border:1px solid black;}
-    </style>\n"""
+      if (!e || !f) break;
+      e.style.display = (show ? 'block' : 'none');
+      f.innerHTML = (show ? '&#x2296' : '&#x2295');
+    }
+  };
+  </script>
+  <style type="text/css">
+  th,td{border-collapse:collapse; border:1px solid black;}
+  .button{color:blue;font-size:110%;font-weight:bolder;}
+  .bt{color:black;background-color:transparent;border:none;outline:none;
+      font-size:140%;font-weight:bolder;}
+  .c0{background-color:#e0e0e0;}
+  .c1{background-color:#d0d0d0;}
+  .t1{border-collapse:collapse; width:100%; border:1px solid black;}
+  </style>
+  <script src="https://www.gstatic.com/charts/loader.js"></script>
+"""
 
 
-def output(text):
-    print text,
+def html_big(param):
+  return '<font size="+2">' + param + '</font>'
 
-def htmlbig(param):
-    return '<font size="+2">' + param + '</font>'
 
-def dumphtmlprologue(title):
-    output('<html>\n<head>\n')
-    output('<title>' + title + '</title>\n')
-    output(html_script_style)
-    output('</head>\n<body>\n')
-    output(htmlbig(title))
-    output('<p>\n')
+def dump_html_prologue(title):
+  print '<html>\n<head>'
+  print '<title>' + title + '</title>'
+  print html_head_scripts
+  emit_stats_by_project()
+  print '</head>\n<body>'
+  print html_big(title)
+  print '<p>'
 
-def dumphtmlepilogue():
-    output('</body>\n</head>\n</html>\n')
 
-def tablerow(text):
-    global cur_row_class
+def dump_html_epilogue():
+  print '</body>\n</head>\n</html>'
+
+
+def sort_warnings():
+  for i in warn_patterns:
+    i['members'] = sorted(set(i['members']))
+
+
+def emit_stats_by_project():
+  """Dump a google chart table of warnings per project and severity."""
+  # warnings[p][s] is number of warnings in project p of severity s.
+  warnings = {p: {s: 0 for s in Severity.range} for p in project_names}
+  for i in warn_patterns:
+    s = i['severity']
+    for p in i['projects']:
+      warnings[p][s] += i['projects'][p]
+
+  # total_by_project[p] is number of warnings in project p.
+  total_by_project = {p: sum(warnings[p][s] for s in Severity.range)
+                      for p in project_names}
+
+  # total_by_severity[s] is number of warnings of severity s.
+  total_by_severity = {s: sum(warnings[p][s] for p in project_names)
+                       for s in Severity.range}
+
+  # emit table header
+  stats_header = ['Project']
+  for s in Severity.range:
+    if total_by_severity[s]:
+      stats_header.append("<span style='background-color:{}'>{}</span>".
+                          format(Severity.colors[s],
+                                 Severity.column_headers[s]))
+  stats_header.append('TOTAL')
+
+  # emit a row of warning counts per project, skip no-warning projects
+  total_all_projects = 0
+  stats_rows = []
+  for p in project_names:
+    if total_by_project[p]:
+      one_row = [p]
+      for s in Severity.range:
+        if total_by_severity[s]:
+          one_row.append(warnings[p][s])
+      one_row.append(total_by_project[p])
+      stats_rows.append(one_row)
+      total_all_projects += total_by_project[p]
+
+  # emit a row of warning counts per severity
+  total_all_severities = 0
+  one_row = ['<b>TOTAL</b>']
+  for s in Severity.range:
+    if total_by_severity[s]:
+      one_row.append(total_by_severity[s])
+      total_all_severities += total_by_severity[s]
+  one_row.append(total_all_projects)
+  stats_rows.append(one_row)
+  print '<script>'
+  emit_const_string_array('StatsHeader', stats_header)
+  emit_const_object_array('StatsRows', stats_rows)
+  print draw_table_javascript
+  print '</script>'
+
+
+def dump_stats():
+  """Dump some stats about total number of warnings and such."""
+  known = 0
+  skipped = 0
+  unknown = 0
+  sort_warnings()
+  for i in warn_patterns:
+    if i['severity'] == Severity.UNKNOWN:
+      unknown += len(i['members'])
+    elif i['severity'] == Severity.SKIP:
+      skipped += len(i['members'])
+    else:
+      known += len(i['members'])
+  print 'Number of classified warnings: <b>' + str(known) + '</b><br>'
+  print 'Number of skipped warnings: <b>' + str(skipped) + '</b><br>'
+  print 'Number of unclassified warnings: <b>' + str(unknown) + '</b><br>'
+  total = unknown + known + skipped
+  extra_msg = ''
+  if total < 1000:
+    extra_msg = ' (low count may indicate incremental build)'
+  print 'Total number of warnings: <b>' + str(total) + '</b>' + extra_msg
+
+
+# New base table of warnings, [severity, warn_id, project, warning_message]
+# Need buttons to show warnings in different grouping options.
+# (1) Current, group by severity, id for each warning pattern
+#     sort by severity, warn_id, warning_message
+# (2) Current --byproject, group by severity,
+#     id for each warning pattern + project name
+#     sort by severity, warn_id, project, warning_message
+# (3) New, group by project + severity,
+#     id for each warning pattern
+#     sort by project, severity, warn_id, warning_message
+def emit_buttons():
+  print ('<button class="button" onclick="expandCollapse(1);">'
+         'Expand all warnings</button>\n'
+         '<button class="button" onclick="expandCollapse(0);">'
+         'Collapse all warnings</button>\n'
+         '<button class="button" onclick="groupBySeverity();">'
+         'Group warnings by severity</button>\n'
+         '<button class="button" onclick="groupByProject();">'
+         'Group warnings by project</button><br>')
+
+
+def all_patterns(category):
+  patterns = ''
+  for i in category['patterns']:
+    patterns += i
+    patterns += ' / '
+  return patterns
+
+
+def dump_fixed():
+  """Show which warnings no longer occur."""
+  anchor = 'fixed_warnings'
+  mark = anchor + '_mark'
+  print ('\n<br><p style="background-color:lightblue"><b>'
+         '<button id="' + mark + '" '
+         'class="bt" onclick="expand(\'' + anchor + '\');">'
+         '&#x2295</button> Fixed warnings. '
+         'No more occurrences. Please consider turning these into '
+         'errors if possible, before they are reintroduced in to the build'
+         ':</b></p>')
+  print '<blockquote>'
+  fixed_patterns = []
+  for i in warn_patterns:
+    if not i['members']:
+      fixed_patterns.append(i['description'] + ' (' +
+                            all_patterns(i) + ')')
+    if i['option']:
+      fixed_patterns.append(' ' + i['option'])
+  fixed_patterns.sort()
+  print '<div id="' + anchor + '" style="display:none;"><table>'
+  cur_row_class = 0
+  for text in fixed_patterns:
     cur_row_class = 1 - cur_row_class
     # remove last '\n'
     t = text[:-1] if text[-1] == '\n' else text
-    output('<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>\n')
+    print '<tr><td class="c' + str(cur_row_class) + '">' + t + '</td></tr>'
+  print '</table></div>'
+  print '</blockquote>'
 
-def sortwarnings():
-    for i in warnpatterns:
-        i['members'] = sorted(set(i['members']))
 
-# dump a table of warnings per project and severity
-def dumpstatsbyproject():
-    projects = set(projectnames)
-    severities = set(severity.kinds)
+def find_project_index(line):
+  for p in range(len(project_patterns)):
+    if project_patterns[p].match(line):
+      return p
+  return -1
 
-    # warnings[p][s] is number of warnings in project p of severity s.
-    warnings = {p:{s:0 for s in severity.kinds} for p in projectnames}
-    for i in warnpatterns:
-        s = i['severity']
-        for p in i['projects']:
-            warnings[p][s] += i['projects'][p]
 
-    # totalbyproject[p] is number of warnings in project p.
-    totalbyproject = {p:sum(warnings[p][s] for s in severity.kinds)
-                      for p in projectnames}
-
-    # totalbyseverity[s] is number of warnings of severity s.
-    totalbyseverity = {s:sum(warnings[p][s] for p in projectnames)
-                       for s in severity.kinds}
-
-    # emit table header
-    output('<blockquote><table border=1>\n<tr><th>Project</th>\n')
-    for s in severity.kinds:
-        if totalbyseverity[s]:
-            output('<th width="8%"><span style="background-color:{}">{}</span></th>'.
-                   format(severity.color[s], severity.columnheader[s]))
-    output('<th>TOTAL</th></tr>\n')
-
-    # emit a row of warning counts per project, skip no-warning projects
-    totalallprojects = 0
-    for p in projectnames:
-        if totalbyproject[p]:
-            output('<tr><td align="left">{}</td>'.format(p))
-            for s in severity.kinds:
-                if totalbyseverity[s]:
-                    output('<td align="right">{}</td>'.format(warnings[p][s]))
-            output('<td align="right">{}</td>'.format(totalbyproject[p]))
-            totalallprojects += totalbyproject[p]
-            output('</tr>\n')
-
-    # emit a row of warning counts per severity
-    totalallseverities = 0
-    output('<tr><td align="right">TOTAL</td>')
-    for s in severity.kinds:
-        if totalbyseverity[s]:
-            output('<td align="right">{}</td>'.format(totalbyseverity[s]))
-            totalallseverities += totalbyseverity[s]
-    output('<td align="right">{}</td></tr>\n'.format(totalallprojects))
-
-    # at the end of table, verify total counts
-    output('</table></blockquote><br>\n')
-    if totalallprojects != totalallseverities:
-        output('<h3>ERROR: Sum of warnings by project ' +
-               '!= Sum of warnings by severity.</h3>\n')
-
-# dump some stats about total number of warnings and such
-def dumpstats():
-    known = 0
-    skipped = 0
-    unknown = 0
-    sortwarnings()
-    for i in warnpatterns:
-        if i['severity'] == severity.UNKNOWN:
-            unknown += len(i['members'])
-        elif i['severity'] == severity.SKIP:
-            skipped += len(i['members'])
+def classify_warning(line):
+  for i in range(len(warn_patterns)):
+    w = warn_patterns[i]
+    for cpat in w['compiled_patterns']:
+      if cpat.match(line):
+        w['members'].append(line)
+        p = find_project_index(line)
+        index = len(warning_messages)
+        warning_messages.append(line)
+        warning_records.append([i, p, index])
+        pname = '???' if p < 0 else project_names[p]
+        # Count warnings by project.
+        if pname in w['projects']:
+          w['projects'][pname] += 1
         else:
-            known += len(i['members'])
-    output('\nNumber of classified warnings: <b>' + str(known) + '</b><br>' )
-    output('\nNumber of skipped warnings: <b>' + str(skipped) + '</b><br>')
-    output('\nNumber of unclassified warnings: <b>' + str(unknown) + '</b><br>')
-    total = unknown + known + skipped
-    output('\nTotal number of warnings: <b>' + str(total) + '</b>')
-    if total < 1000:
-        output('(low count may indicate incremental build)')
-    output('<br><br>\n')
-
-def emitbuttons():
-    output('<button class="button" onclick="expand_collapse(1);">' +
-           'Expand all warnings</button>\n' +
-           '<button class="button" onclick="expand_collapse(0);">' +
-           'Collapse all warnings</button><br>\n')
-
-# dump everything for a given severity
-def dumpseverity(sev):
-    global anchor
-    total = 0
-    for i in warnpatterns:
-        if i['severity'] == sev:
-            total = total + len(i['members'])
-    output('\n<br><span style="background-color:' + severity.color[sev] + '"><b>' +
-           severity.header[sev] + ': ' + str(total) + '</b></span>\n')
-    output('<blockquote>\n')
-    for i in warnpatterns:
-        if i['severity'] == sev and len(i['members']) > 0:
-            anchor += 1
-            i['anchor'] = str(anchor)
-            if args.byproject:
-                dumpcategorybyproject(sev, i)
-            else:
-                dumpcategory(sev, i)
-    output('</blockquote>\n')
-
-# emit all skipped project anchors for expand_collapse.
-def dumpskippedanchors():
-    output('<div style="display:none;">\n')  # hide these fake elements
-    for i in warnpatterns:
-        if i['severity'] == severity.SKIP and len(i['members']) > 0:
-            projects = i['projectwarning'].keys()
-            for p in projects:
-                output('<div id="' + i['projectanchor'][p] + '"></div>' +
-                       '<div id="' + i['projectanchor'][p] + '_mark"></div>\n')
-    output('</div>\n')
-
-def allpatterns(cat):
-    pats = ''
-    for i in cat['patterns']:
-        pats += i
-        pats += ' / '
-    return pats
-
-def descriptionfor(cat):
-    if cat['description'] != '':
-        return cat['description']
-    return allpatterns(cat)
+          w['projects'][pname] = 1
+        return
+      else:
+        # If we end up here, there was a problem parsing the log
+        # probably caused by 'make -j' mixing the output from
+        # 2 or more concurrent compiles
+        pass
 
 
-# show which warnings no longer occur
-def dumpfixed():
-    global anchor
-    anchor += 1
-    mark = str(anchor) + '_mark'
-    output('\n<br><p style="background-color:lightblue"><b>' +
-           '<button id="' + mark + '" ' +
-           'class="bt" onclick="expand(' + str(anchor) + ');">' +
-           '&#x2295</button> Fixed warnings. ' +
-           'No more occurences. Please consider turning these into ' +
-           'errors if possible, before they are reintroduced in to the build' +
-           ':</b></p>\n')
-    output('<blockquote>\n')
-    fixed_patterns = []
-    for i in warnpatterns:
-        if len(i['members']) == 0:
-            fixed_patterns.append(i['description'] + ' (' +
-                                  allpatterns(i) + ')')
-        if i['option']:
-            fixed_patterns.append(' ' + i['option'])
-    fixed_patterns.sort()
-    output('<div id="' + str(anchor) + '" style="display:none;"><table>\n')
-    for i in fixed_patterns:
-        tablerow(i)
-    output('</table></div>\n')
-    output('</blockquote>\n')
+def compile_patterns():
+  """Precompiling every pattern speeds up parsing by about 30x."""
+  for i in warn_patterns:
+    i['compiled_patterns'] = []
+    for pat in i['patterns']:
+      i['compiled_patterns'].append(re.compile(pat))
 
-def warningwithurl(line):
-    if not args.url:
-        return line
-    m = re.search( r'^([^ :]+):(\d+):(.+)', line, re.M|re.I)
-    if not m:
-        return line
-    filepath = m.group(1)
-    linenumber = m.group(2)
-    warning = m.group(3)
-    if args.separator:
-        return '<a href="' + args.url + '/' + filepath + args.separator + linenumber + '">' + filepath + ':' + linenumber + '</a>:' + warning
+
+def find_android_root(path):
+  """Set and return android_root path if it is found."""
+  global android_root
+  parts = path.split('/')
+  for idx in reversed(range(2, len(parts))):
+    root_path = '/'.join(parts[:idx])
+    # Android root directory should contain this script.
+    if os.path.exists(root_path + '/build/tools/warn.py'):
+      android_root = root_path
+      return root_path
+  return ''
+
+
+def remove_android_root_prefix(path):
+  """Remove android_root prefix from path if it is found."""
+  if path.startswith(android_root):
+    return path[1 + len(android_root):]
+  else:
+    return path
+
+
+def normalize_path(path):
+  """Normalize file path relative to android_root."""
+  # If path is not an absolute path, just normalize it.
+  path = os.path.normpath(path)
+  if path[0] != '/':
+    return path
+  # Remove known prefix of root path and normalize the suffix.
+  if android_root or find_android_root(path):
+    return remove_android_root_prefix(path)
+  else:
+    return path
+
+
+def normalize_warning_line(line):
+  """Normalize file path relative to android_root in a warning line."""
+  # replace fancy quotes with plain ol' quotes
+  line = line.replace('‘', "'")
+  line = line.replace('’', "'")
+  line = line.strip()
+  first_column = line.find(':')
+  if first_column > 0:
+    return normalize_path(line[:first_column]) + line[first_column:]
+  else:
+    return line
+
+
+def parse_input_file():
+  """Parse input file, match warning lines."""
+  global platform_version
+  global target_product
+  global target_variant
+  infile = open(args.buildlog, 'r')
+  line_counter = 0
+
+  # handle only warning messages with a file path
+  warning_pattern = re.compile('^[^ ]*/[^ ]*: warning: .*')
+  compile_patterns()
+
+  # read the log file and classify all the warnings
+  warning_lines = set()
+  for line in infile:
+    if warning_pattern.match(line):
+      line = normalize_warning_line(line)
+      if line not in warning_lines:
+        classify_warning(line)
+        warning_lines.add(line)
+    elif line_counter < 50:
+      # save a little bit of time by only doing this for the first few lines
+      line_counter += 1
+      m = re.search('(?<=^PLATFORM_VERSION=).*', line)
+      if m is not None:
+        platform_version = m.group(0)
+      m = re.search('(?<=^TARGET_PRODUCT=).*', line)
+      if m is not None:
+        target_product = m.group(0)
+      m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
+      if m is not None:
+        target_variant = m.group(0)
+
+
+# Return s with escaped backslash and quotation characters.
+def escape_string(s):
+  return s.replace('\\', '\\\\').replace('"', '\\"')
+
+
+# Return s without trailing '\n' and escape the quotation characters.
+def strip_escape_string(s):
+  if not s:
+    return s
+  s = s[:-1] if s[-1] == '\n' else s
+  return escape_string(s)
+
+
+def emit_warning_array(name):
+  print 'var warning_{} = ['.format(name)
+  for i in range(len(warn_patterns)):
+    print '{},'.format(warn_patterns[i][name])
+  print '];'
+
+
+def emit_warning_arrays():
+  emit_warning_array('severity')
+  print 'var warning_description = ['
+  for i in range(len(warn_patterns)):
+    if warn_patterns[i]['members']:
+      print '"{}",'.format(escape_string(warn_patterns[i]['description']))
     else:
-        return '<a href="' + args.url + '/' + filepath + '">' + filepath + '</a>:' + linenumber + ':' + warning
+      print '"",'  # no such warning
+  print '];'
 
-def dumpgroup(sev, anchor, description, warnings):
-    mark = anchor + '_mark'
-    output('\n<table class="t1">\n')
-    output('<tr bgcolor="' + severity.color[sev] + '">' +
-           '<td><button class="bt" id="' + mark +
-           '" onclick="expand(\'' + anchor + '\');">' +
-           '&#x2295</button> ' + description + '</td></tr>\n')
-    output('</table>\n')
-    output('<div id="' + anchor + '" style="display:none;">')
-    output('<table class="t1">\n')
-    for i in warnings:
-        tablerow(warningwithurl(i))
-    output('</table></div>\n')
+scripts_for_warning_groups = """
+  function compareMessages(x1, x2) { // of the same warning type
+    return (WarningMessages[x1[2]] <= WarningMessages[x2[2]]) ? -1 : 1;
+  }
+  function byMessageCount(x1, x2) {
+    return x2[2] - x1[2];  // reversed order
+  }
+  function bySeverityMessageCount(x1, x2) {
+    // orer by severity first
+    if (x1[1] != x2[1])
+      return  x1[1] - x2[1];
+    return byMessageCount(x1, x2);
+  }
+  const ParseLinePattern = /^([^ :]+):(\\d+):(.+)/;
+  function addURL(line) {
+    if (FlagURL == "") return line;
+    if (FlagSeparator == "") {
+      return line.replace(ParseLinePattern,
+        "<a href='" + FlagURL + "/$1'>$1</a>:$2:$3");
+    }
+    return line.replace(ParseLinePattern,
+      "<a href='" + FlagURL + "/$1" + FlagSeparator + "$2'>$1:$2</a>:$3");
+  }
+  function createArrayOfDictionaries(n) {
+    var result = [];
+    for (var i=0; i<n; i++) result.push({});
+    return result;
+  }
+  function groupWarningsBySeverity() {
+    // groups is an array of dictionaries,
+    // each dictionary maps from warning type to array of warning messages.
+    var groups = createArrayOfDictionaries(SeverityColors.length);
+    for (var i=0; i<Warnings.length; i++) {
+      var w = Warnings[i][0];
+      var s = WarnPatternsSeverity[w];
+      var k = w.toString();
+      if (!(k in groups[s]))
+        groups[s][k] = [];
+      groups[s][k].push(Warnings[i]);
+    }
+    return groups;
+  }
+  function groupWarningsByProject() {
+    var groups = createArrayOfDictionaries(ProjectNames.length);
+    for (var i=0; i<Warnings.length; i++) {
+      var w = Warnings[i][0];
+      var p = Warnings[i][1];
+      var k = w.toString();
+      if (!(k in groups[p]))
+        groups[p][k] = [];
+      groups[p][k].push(Warnings[i]);
+    }
+    return groups;
+  }
+  var GlobalAnchor = 0;
+  function createWarningSection(header, color, group) {
+    var result = "";
+    var groupKeys = [];
+    var totalMessages = 0;
+    for (var k in group) {
+       totalMessages += group[k].length;
+       groupKeys.push([k, WarnPatternsSeverity[parseInt(k)], group[k].length]);
+    }
+    groupKeys.sort(bySeverityMessageCount);
+    for (var idx=0; idx<groupKeys.length; idx++) {
+      var k = groupKeys[idx][0];
+      var messages = group[k];
+      var w = parseInt(k);
+      var wcolor = SeverityColors[WarnPatternsSeverity[w]];
+      var description = WarnPatternsDescription[w];
+      if (description.length == 0)
+          description = "???";
+      GlobalAnchor += 1;
+      result += "<table class='t1'><tr bgcolor='" + wcolor + "'><td>" +
+                "<button class='bt' id='" + GlobalAnchor + "_mark" +
+                "' onclick='expand(\\"" + GlobalAnchor + "\\");'>" +
+                "&#x2295</button> " +
+                description + " (" + messages.length + ")</td></tr></table>";
+      result += "<div id='" + GlobalAnchor +
+                "' style='display:none;'><table class='t1'>";
+      var c = 0;
+      messages.sort(compareMessages);
+      for (var i=0; i<messages.length; i++) {
+        result += "<tr><td class='c" + c + "'>" +
+                  addURL(WarningMessages[messages[i][2]]) + "</td></tr>";
+        c = 1 - c;
+      }
+      result += "</table></div>";
+    }
+    if (result.length > 0) {
+      return "<br><span style='background-color:" + color + "'><b>" +
+             header + ": " + totalMessages +
+             "</b></span><blockquote><table class='t1'>" +
+             result + "</table></blockquote>";
 
-# dump warnings in a category
-def dumpcategory(sev, cat):
-    description = descriptionfor(cat) + ' (' + str(len(cat['members'])) + ')'
-    dumpgroup(sev, cat['anchor'], description, cat['members'])
-
-# similar to dumpcategory but output one table per project.
-def dumpcategorybyproject(sev, cat):
-    warning = descriptionfor(cat)
-    projects = cat['projectwarning'].keys()
-    projects.sort()
-    for p in projects:
-        anchor = cat['projectanchor'][p]
-        projectwarnings = cat['projectwarning'][p]
-        description = '{}, in {} ({})'.format(warning, p, len(projectwarnings))
-        dumpgroup(sev, anchor, description, projectwarnings)
-
-def findproject(line):
-    for p in projectpatterns:
-        if p['pattern'].match(line):
-            return p['description']
-    return '???'
-
-def classifywarning(line):
-    global anchor
-    for i in warnpatterns:
-        for cpat in i['compiledpatterns']:
-            if cpat.match(line):
-                i['members'].append(line)
-                pname = findproject(line)
-                # Count warnings by project.
-                if pname in i['projects']:
-                    i['projects'][pname] += 1
-                else:
-                    i['projects'][pname] = 1
-                # Collect warnings by project.
-                if args.byproject:
-                    if pname in i['projectwarning']:
-                        i['projectwarning'][pname].append(line)
-                    else:
-                        i['projectwarning'][pname] = [line]
-                    if pname not in i['projectanchor']:
-                        anchor += 1
-                        i['projectanchor'][pname] = str(anchor)
-                return
-            else:
-                # If we end up here, there was a problem parsing the log
-                # probably caused by 'make -j' mixing the output from
-                # 2 or more concurrent compiles
-                pass
-
-# precompiling every pattern speeds up parsing by about 30x
-def compilepatterns():
-    for i in warnpatterns:
-        i['compiledpatterns'] = []
-        for pat in i['patterns']:
-            i['compiledpatterns'].append(re.compile(pat))
-
-def parseinputfile():
-    global platformversion
-    global targetproduct
-    global targetvariant
-    infile = open(args.buildlog, 'r')
-    linecounter = 0
-
-    warningpattern = re.compile('.* warning:.*')
-    compilepatterns()
-
-    # read the log file and classify all the warnings
-    warninglines = set()
-    for line in infile:
-        # replace fancy quotes with plain ol' quotes
-        line = line.replace("‘", "'");
-        line = line.replace("’", "'");
-        if warningpattern.match(line):
-            if line not in warninglines:
-                classifywarning(line)
-                warninglines.add(line)
-        else:
-            # save a little bit of time by only doing this for the first few lines
-            if linecounter < 50:
-                linecounter +=1
-                m = re.search('(?<=^PLATFORM_VERSION=).*', line)
-                if m != None:
-                    platformversion = m.group(0)
-                m = re.search('(?<=^TARGET_PRODUCT=).*', line)
-                if m != None:
-                    targetproduct = m.group(0)
-                m = re.search('(?<=^TARGET_BUILD_VARIANT=).*', line)
-                if m != None:
-                    targetvariant = m.group(0)
+    }
+    return "";  // empty section
+  }
+  function generateSectionsBySeverity() {
+    var result = "";
+    var groups = groupWarningsBySeverity();
+    for (s=0; s<SeverityColors.length; s++) {
+      result += createWarningSection(SeverityHeaders[s], SeverityColors[s], groups[s]);
+    }
+    return result;
+  }
+  function generateSectionsByProject() {
+    var result = "";
+    var groups = groupWarningsByProject();
+    for (i=0; i<groups.length; i++) {
+      result += createWarningSection(ProjectNames[i], 'lightgrey', groups[i]);
+    }
+    return result;
+  }
+  function groupWarnings(generator) {
+    GlobalAnchor = 0;
+    var e = document.getElementById("warning_groups");
+    e.innerHTML = generator();
+  }
+  function groupBySeverity() {
+    groupWarnings(generateSectionsBySeverity);
+  }
+  function groupByProject() {
+    groupWarnings(generateSectionsByProject);
+  }
+"""
 
 
-# dump the html output to stdout
-def dumphtml():
-    dumphtmlprologue('Warnings for ' + platformversion + ' - ' + targetproduct + ' - ' + targetvariant)
-    dumpstats()
-    dumpstatsbyproject()
-    emitbuttons()
-    # sort table based on number of members once dumpstats has deduplicated the
-    # members.
-    warnpatterns.sort(reverse=True, key=lambda i: len(i['members']))
-    # Dump warnings by severity. If severity.SKIP warnings are not dumpped,
-    # the project anchors should be dumped through dumpskippedanchors.
-    for s in severity.kinds:
-        dumpseverity(s)
-    dumpfixed()
-    dumphtmlepilogue()
+# Emit a JavaScript const string
+def emit_const_string(name, value):
+  print 'const ' + name + ' = "' + escape_string(value) + '";'
+
+
+# Emit a JavaScript const integer array.
+def emit_const_int_array(name, array):
+  print 'const ' + name + ' = ['
+  for n in array:
+    print str(n) + ','
+  print '];'
+
+
+# Emit a JavaScript const string array.
+def emit_const_string_array(name, array):
+  print 'const ' + name + ' = ['
+  for s in array:
+    print '"' + strip_escape_string(s) + '",'
+  print '];'
+
+
+# Emit a JavaScript const object array.
+def emit_const_object_array(name, array):
+  print 'const ' + name + ' = ['
+  for x in array:
+    print str(x) + ','
+  print '];'
+
+
+def emit_js_data():
+  """Dump dynamic HTML page's static JavaScript data."""
+  emit_const_string('FlagURL', args.url if args.url else '')
+  emit_const_string('FlagSeparator', args.separator if args.separator else '')
+  emit_const_string_array('SeverityColors', Severity.colors)
+  emit_const_string_array('SeverityHeaders', Severity.headers)
+  emit_const_string_array('SeverityColumnHeaders', Severity.column_headers)
+  emit_const_string_array('ProjectNames', project_names)
+  emit_const_int_array('WarnPatternsSeverity',
+                       [w['severity'] for w in warn_patterns])
+  emit_const_string_array('WarnPatternsDescription',
+                          [w['description'] for w in warn_patterns])
+  emit_const_string_array('WarnPatternsOption',
+                          [w['option'] for w in warn_patterns])
+  emit_const_string_array('WarningMessages', warning_messages)
+  emit_const_object_array('Warnings', warning_records)
+
+draw_table_javascript = """
+google.charts.load('current', {'packages':['table']});
+google.charts.setOnLoadCallback(drawTable);
+function drawTable() {
+  var data = new google.visualization.DataTable();
+  data.addColumn('string', StatsHeader[0]);
+  for (var i=1; i<StatsHeader.length; i++) {
+    data.addColumn('number', StatsHeader[i]);
+  }
+  data.addRows(StatsRows);
+  for (var i=0; i<StatsRows.length; i++) {
+    for (var j=0; j<StatsHeader.length; j++) {
+      data.setProperty(i, j, 'style', 'border:1px solid black;');
+    }
+  }
+  var table = new google.visualization.Table(document.getElementById('stats_table'));
+  table.draw(data, {allowHtml: true, alternatingRowStyle: true});
+}
+"""
+
+
+def dump_html():
+  """Dump the html output to stdout."""
+  dump_html_prologue('Warnings for ' + platform_version + ' - ' +
+                     target_product + ' - ' + target_variant)
+  dump_stats()
+  print '<br><div id="stats_table"></div><br>'
+  print '\n<script>'
+  emit_js_data()
+  print scripts_for_warning_groups
+  print '</script>'
+  emit_buttons()
+  # Warning messages are grouped by severities or project names.
+  print '<br><div id="warning_groups"></div>'
+  if args.byproject:
+    print '<script>groupByProject();</script>'
+  else:
+    print '<script>groupBySeverity();</script>'
+  dump_fixed()
+  dump_html_epilogue()
 
 
 ##### Functions to count warnings and dump csv file. #########################
 
-def descriptionforcsv(cat):
-    if cat['description'] == '':
-        return '?'
-    return cat['description']
 
-def stringforcsv(s):
-    if ',' in s:
-        return '"{}"'.format(s)
-    return s
+def description_for_csv(category):
+  if not category['description']:
+    return '?'
+  return category['description']
 
-def countseverity(sev, kind):
-  sum = 0
-  for i in warnpatterns:
-      if i['severity'] == sev and len(i['members']) > 0:
-          n = len(i['members'])
-          sum += n
-          warning = stringforcsv(kind + ': ' + descriptionforcsv(i))
-          print '{},,{}'.format(n, warning)
-          # print number of warnings for each project, ordered by project name.
-          projects = i['projects'].keys()
-          projects.sort()
-          for p in projects:
-              print '{},{},{}'.format(i['projects'][p], p, warning)
-  print '{},,{}'.format(sum, kind + ' warnings')
-  return sum
+
+def string_for_csv(s):
+  # Only some Java warning desciptions have used quotation marks.
+  # TODO(chh): if s has double quote character, s should be quoted.
+  if ',' in s:
+    # TODO(chh): replace a double quote with two double quotes in s.
+    return '"{}"'.format(s)
+  return s
+
+
+def count_severity(sev, kind):
+  """Count warnings of given severity."""
+  total = 0
+  for i in warn_patterns:
+    if i['severity'] == sev and i['members']:
+      n = len(i['members'])
+      total += n
+      warning = string_for_csv(kind + ': ' + description_for_csv(i))
+      print '{},,{}'.format(n, warning)
+      # print number of warnings for each project, ordered by project name.
+      projects = i['projects'].keys()
+      projects.sort()
+      for p in projects:
+        print '{},{},{}'.format(i['projects'][p], p, warning)
+  print '{},,{}'.format(total, kind + ' warnings')
+  return total
+
 
 # dump number of warnings in csv format to stdout
-def dumpcsv():
-    sortwarnings()
-    total = 0
-    for s in severity.kinds:
-        total += countseverity(s, severity.columnheader[s])
-    print '{},,{}'.format(total, 'All warnings')
+def dump_csv():
+  """Dump number of warnings in csv format to stdout."""
+  sort_warnings()
+  total = 0
+  for s in Severity.range:
+    total += count_severity(s, Severity.column_headers[s])
+  print '{},,{}'.format(total, 'All warnings')
 
 
-parseinputfile()
-if args.gencsv:
-    dumpcsv()
-else:
-    dumphtml()
+def main():
+  parse_input_file()
+  if args.gencsv:
+    dump_csv()
+  else:
+    dump_html()
+
+
+# Run main function if warn.py is the main program.
+if __name__ == '__main__':
+  main()
diff --git a/tools/zipalign/ZipEntry.cpp b/tools/zipalign/ZipEntry.cpp
index 2f33e23..a9c2d33 100644
--- a/tools/zipalign/ZipEntry.cpp
+++ b/tools/zipalign/ZipEntry.cpp
@@ -130,6 +130,7 @@
     if (mCDE.mFileCommentLength > 0) {
         /* TODO: stop assuming null-terminated ASCII here? */
         mCDE.mFileComment = new uint8_t[mCDE.mFileCommentLength+1];
+        assert(comment != NULL);
         strcpy((char*) mCDE.mFileComment, comment);
     }
 
diff --git a/tools/zipalign/ZipFile.cpp b/tools/zipalign/ZipFile.cpp
index 4edf0aa..98d02e0 100644
--- a/tools/zipalign/ZipFile.cpp
+++ b/tools/zipalign/ZipFile.cpp
@@ -919,6 +919,7 @@
             getSize = fread(inBuf, 1, kBufSize, srcFp);
             if (ferror(srcFp)) {
                 ALOGD("deflate read failed (errno=%d)\n", errno);
+                result = UNKNOWN_ERROR;
                 delete[] inBuf;
                 goto bail;
             }
@@ -937,6 +938,7 @@
     ALOGV("+++ writing %d bytes\n", (int)outSize);
     if (fwrite(outBuf, 1, outSize, dstFp) != outSize) {
         ALOGD("write %d failed in deflate\n", (int)outSize);
+        result = UNKNOWN_ERROR;
         goto bail;
     }